Repository navigation
fix(rotary): preserve fp32 inputs in mrope torch fallbacks - #641
Open
taking-lying-flat wants to merge 1 commit into
Open
taking-lying-flat wants to merge 1 commit into
taking-lying-flat wants to merge 1 commit into
Conversation
KarrAcaRn
pushed a commit
to KarrAcaRn/FreeToken-ByAI
that referenced
this pull request
Oct 10, 2026
…in mrope torch fallbacks
KarrAcaRn
pushed a commit
to KarrAcaRn/FreeToken-ByAI
that referenced
this pull request
Oct 10, 2026
…in both mrope torch fallbacks Assisted-by: Claude Opus 5.5
This branch has not been deployed
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.
For FP32 Q/K, the
.float()slices in the Torch mRoPE fallbacks still alias the input. Writing the low half first therefore changes the input used to compute the high half. Rotating(1, 2)by 45 degrees produces(-0.707107, 0.914214)instead of(-0.707107, 2.121320).Compute both results before either in-place write in
_mrope_torchandapply_mrope_torch_fallback. This preserves the existing interface without cloning all of Q/K. The change is limited to the two Torch fallbacks; the Triton kernels are unchanged.Validation on upstream
0781324:git diff --checkpassed./home/cherry-cloud/miniconda3/envs/cherry/bin/python /tmp/run-freetoken-mrope-pr-tests.py --tb=short. The runner loads the real source modules while bypassing unrelated package initializers and the parent quantization-reset fixture, then runstests/kernels/test_mrope.pythrough pytest. Normal package import was blocked by a missingmsgpackdependency; this was not a full supported-environment test run.This PR contains only production code. The regression additions and correction to the local test reference remain outside the commit. No checkpoint, full-model inference, or end-to-end performance validation was run; this does not claim an improvement to the normal BF16/Triton inference path.