Skip to content

Conversation

@scyyh11
Copy link
Collaborator

@scyyh11 scyyh11 commented Nov 10, 2025

预防性的修复 #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 提前初始化:

    transpose_weight_keys = None
  • 保持原有逻辑:若模型实现 get_transpose_weight_keys(),则在后续分支中覆盖该值。

  • 属于预防性修复,避免潜在路径下的未绑定变量错误,不改变现有行为。

@paddle-bot
Copy link

paddle-bot bot commented Nov 10, 2025

Thanks for your contribution!

@paddle-bot paddle-bot bot added the contributor External developers label Nov 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor External developers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant