Fix RoPE broadcast mismatch in apply_rope - #87
Open
helpdeskdcp wants to merge 1 commit into
Open
helpdeskdcp wants to merge 1 commit into
helpdeskdcp wants to merge 1 commit into
Conversation
apply_rope no longer sliced freqs_cis to x's sequence length internally (removed in 18cca89 when start_pos offsetting was added at the top-level OpenMythos.forward). That top-level caller already pre-slices freqs_cis to exactly T rows via [start_pos:start_pos+T], so the change is a no-op there. But GQAttention/MLAttention/TransformerBlock/RecurrentBlock unit tests call the attention modules directly with the full, unsliced max_seq_len-length freqs table, causing a broadcast mismatch (e.g. T=8 vs max_seq_len=32). Restoring the internal freqs_cis[:T] slice fixes both call paths since it is idempotent when the input is already exactly T rows long.
This was referenced Aug 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
apply_rope()no longer slicedfreqs_cisto the input's sequence lengthTinternally — that slicing was removed in 18cca89 whenstart_posoffsetting was moved toOpenMythos.forward, which now pre-slicesfreqs_cisto exactlyTrows before calling down into layers.GQAttention/MLAttention/TransformerBlock/RecurrentBlockunit tests call the attention modules directly with the full, unslicedmax_seq_len-length freqs table, causingRuntimeError: The size of tensor a (8) must match the size of tensor b (32)at the RoPE broadcast multiply.freqs_cis = freqs_cis[: x.shape[1]]insideapply_rope, which is a no-op when the caller already passes an exactly-T-length window (preserving the 18cca89 decode-position fix) and correctly truncates when a longer table is passed directly.Test plan
.venv/bin/python -m pytest -q— before: 62 passed, 14 failed; after: 75 passed, 1 failedTestLTIInjection::test_spectral_radius_stable_after_large_grad_step) confirmed pre-existing and flaky/non-deterministic (no seed set), unrelated to this change — reproduced fail/pass/fail across 3 standalone reruns onmainbefore this fix.🤖 Generated with Claude Code