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.
预防性的修复 #4636
虽然本地尚未成功复现该 issue 描述的报错场景,但在排查
from_pretrained加载流程时发现确实存在潜在的未绑定变量使用风险:transpose_weight_keys仅在部分分支被赋值,在未走入get_transpose_weight_keys()的情况下仍会于load_state_dict(..., transpose_weight_keys=...)中被引用,从而可能触发UnboundLocalError。变更说明
在
paddlex/inference/models/common/vlm/transformers/model_utils.py:1800提前初始化:保持原有逻辑:若模型实现
get_transpose_weight_keys(),则在后续分支中覆盖该值。属于预防性修复,避免潜在路径下的未绑定变量错误,不改变现有行为。