Update modeling_qwen2.py

#33

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_idx when position embeddings are disabled.

  • Moved

    position_indices = position_indices.reshape(pc, self.patch_size)
    

    into the use_position_embedding block for consistency.

These changes prevent runtime errors and keep position index reshaping aligned with the intended design.

bytedance-research org

πŸ‘πŸ‘πŸ‘

xiezhe24 changed pull request status to merged

Sign up or log in to comment