Repository navigation
core: rope_freq, transformers' RoPE inverse frequencies; Gemma 4's CUDA global table uses it - #1853
Merged
Merged
Conversation
ashhart
force-pushed
the
rope-freq-core
branch
from
November 2, 2026 01:58
3588ae1 to
dc5f92c
Compare
ashhart
added a commit
to jschmied/TensorFold
that referenced
this pull request
Nov 2, 2026
Owner
|
Our GB10 run on Gemma 4 31B (main against this change) is GREEN: prompt tokens identical in all 20 rows, 2K prefill 994.7 -> 995.7 tok/s (+0.1%), and decode 26.6 -> 26.5 tok/s (base's own runs were 26.66 and 26.49, so that's within noise). The gate passes on current main too, so like #1864, it lands as soon as it's marked ready for review. |
jschmied
marked this pull request as ready for review
November 2, 2026 03:48
…frequencies in fp32 1 / theta^(f32(2i) / dim) with theta^e rounded once from f64 and an fp32 reciprocal: torch's words wherever its pow is correctly rounded (its default CPU path everywhere). Tests: transformers 5.22.1's words for four real configs as literals, and a planted control (the fp32-pow form misses 15 of 32 words).
The replaced expression and the helper give the same 256 words for Gemma 4's global layers (theta 1e6, 64 of 256 pairs over 512); the test keeps the old expression and checks it word for word.
ashhart
force-pushed
the
rope-freq-core
branch
from
November 2, 2026 08:31
dc5f92c to
ad58c92
Compare
Owner
|
Thank you @jschmied. This is merged into main with your commits under your own name, so you're listed as a TensorFold contributor. It ships in the next release, credited to you in the changelog and the release notes. |
laudney
added a commit
to laudney/TensorFold
that referenced
this pull request
Nov 2, 2026
Upstream main added the ashhart#1853 entry at the top of the Unreleased section after the last merge, so CHANGELOG.md conflicted again. This merge keeps main's entries and this branch's one entry above them; the other files merged without a change from this branch.
9 tasks done
Owner
|
Thanks @jschmied! This is in TensorFold 1.2.2, out now: https://github.com/ashhart/TensorFold/releases/tag/v1.2.2 |
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.
Part of #1852. One RoPE inverse-frequency helper in core, and the one copy whose words don't change moved onto it.
core/rope_freq.zig:inverseFrequencies(theta, dim, out)(default rope; partial rotary = the rotated width) andproportional(theta, dim, rotated, out)(Gemma 4's global rope, zeros pastrotated). Form:1 / f32(pow_f64(theta, f32(2i) / f32(dim))), transformers' words under torch's scalar CPU path.powform misses 15 of 32 words, by up to 5 ulp.gemma4/cuda_forward.zig: the global table callsrope_freq.proportional. Its words are unchanged: a test keeps the old expression and checks all 256 words against the helper for the served config (the same in the E4B, 12B, 31B and assistant fixtures). Swapping the old expression for the f64-reciprocal form makes that test fail.No other copy changes here: the ones in #1852 change words, so they move only if you want them to.
spark25/config.zigandglm/vision.zigalready equal the helper, but needcorereachable from their module trees first.Checks: lean 0 new,
zig build testand the CI set pass,git diff --checkclean,test-gemma4-cuda-host54/54 (GB10 host).