Update modeling_qwen2.py
#33
by
Wannabtl
- opened
Pull Request Title
Fix padding_idx bug when use_position_embedding=false and use_position_idx=true
Description
This PR fixes a bug where self.padding_idx is undefined if use_position_embedding=false and use_position_idx=true, since its initialization only happens inside the if self.use_position_embedding: block.
Changes made:
Added a conditional check around lines 178β179 to avoid accessing
self.padding_idxwhen position embeddings are disabled.Moved
position_indices = position_indices.reshape(pc, self.patch_size)into the
use_position_embeddingblock for consistency.
These changes prevent runtime errors and keep position index reshaping aligned with the intended design.
πππ
xiezhe24
changed pull request status to
merged