Skip to content

Return true initial batch size information#1190

Merged
jlarson4 merged 2 commits intodev-3.x-canaryfrom
bug/pos-embed-hook-firing
Mar 3, 2026
Merged

Return true initial batch size information#1190
jlarson4 merged 2 commits intodev-3.x-canaryfrom
bug/pos-embed-hook-firing

Conversation

@jlarson4
Copy link
Collaborator

@jlarson4 jlarson4 commented Mar 3, 2026

Description

HuggingFace's GPT-2 generates position_ids with shape [1, seq_len] regardless of batch size, relying on PyTorch broadcasting when adding to token embeddings. TransformerBridge's PosEmbedBridge wraps the HF wpe module, so the hook fires on wpe's output before broadcasting — capturing [1, seq, d_model] instead of [batch, seq, d_model].

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have not rewritten tests relating to key interfaces which would affect backward compatibility

@jlarson4 jlarson4 merged commit 6662189 into dev-3.x-canary Mar 3, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant