fix(doc_vlm): remove ROCm BF16 _keep_in_fp32_modules workaround in PaddleOCR-VL#5077
Open
fchange wants to merge 1 commit intoPaddlePaddle:developfrom
Open
fix(doc_vlm): remove ROCm BF16 _keep_in_fp32_modules workaround in PaddleOCR-VL#5077fchange wants to merge 1 commit intoPaddlePaddle:developfrom
fchange wants to merge 1 commit intoPaddlePaddle:developfrom
Conversation
Remove _keep_in_fp32_modules = ["visual", "mlp_AR"] from PaddleOCRVLForConditionalGeneration. This workaround was added to avoid MIOpen BF16 convolution bugs on ROCm 7.0 by forcing the visual encoder to FP32, which doubled VRAM usage and reduced throughput. The Paddle framework now registers BF16 conv kernels for HIP backend, making this workaround unnecessary. See: PaddlePaddle/Paddle#78587 Signed-off-by: fchange Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
|
Thanks for your contribution! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Remove ROCm BF16 _keep_in_fp32_modules workaround in PaddleOCR-VL
Summary
Removes the
_keep_in_fp32_modules = ["visual", "mlp_AR"]workaround fromPaddleOCRVLForConditionalGeneration, enabling BF16 precision inference for the vision encoder on AMD GPUs (ROCm).Related Issue: #5076
Depends on: PaddlePaddle/Paddle#78587
Problem
The
_keep_in_fp32_modulesworkaround forces the SigLIP vision encoder to run in FP32 on ROCm, even when the model is loaded with BF16 dtype. This was necessary because Paddle's HIP backend did not register BF16 convolution kernels.Impact:
Change
class PaddleOCRVLForConditionalGeneration(Ernie4_5PretrainedModel): _tied_weights_keys = ["lm_head.weight"] config_class = PaddleOCRVLConfig _no_split_modules = ["Ernie4_5DecoderLayer", "SiglipEncoderLayer"] - _keep_in_fp32_modules = ["visual", "mlp_AR"] + _keep_in_fp32_modules = None base_model_prefix = ""Dependency
This PR requires the Paddle framework fix to be merged first:
phi::bfloat16to HIP conv kernel registrations (conv2d,conv3d,depthwise_conv2d)Verification
Environment
Test: Native Backend Inference
cd /opt/PaddleX paddlex --pipeline PaddleOCR-VL-native.yaml --input /tmp/test_ocr.pngResult: Successfully processed boarding pass image with correct OCR output:
Test: Vision Encoder BF16 Verification
After this change, the vision encoder runs in BF16 (no longer forced to FP32):
Before vs After
Notes
conv2d_add_act_fuse_pass,conv2d_add_fuse_passinstatic_infer.py) is unchanged — these depend on cuDNN and are correctly disabled on HIP.is_bfloat16_available()function inmisc.pydoes not have a ROCm override in the upstream develop branch, so no changes needed there.