Skip to content

qwen4: take the rotary table from core's exact helper - #2223

Merged
ashhart merged 4 commits into
mainfrom
lead/qwen4-rope
Nov 6, 2026
Merged

ashhart merged 4 commits into
mainfrom
lead/qwen4-rope

Conversation

@ashhart

@ashhart ashhart commented Nov 5, 2026

Copy link
Copy Markdown
Owner

The Qwen4 half of #2000: its rotary table now comes from core's exact helper, rope_freq.inverseFrequencies, so its FP32 values match transformers' bits. Every moved word is a 1-ulp move, pinned by literals. The refusals and header words stay.

Qwen4's table and oracle passed the host gates (test-qwen4-host 114/114, -reference-host 7/7, -device-host 10/10, -cuda-nodes-host 6/6), and #2000 reports test-qwen4-metal 86/86 on an M3 Ultra. No Qwen4 checkpoint is on a box here, so no tokens were compared. Replies can change where a token was a near-tie. #2000 keeps the Qwen3.8-27B on XPU half, which needs an Arc GPU.

rotary_table.fill keeps its refusals and the three header words and now
writes the frequencies with rope_freq.inverseFrequencies(theta,
head_dim * partial_rotary_factor), the words transformers' default RoPE
uses. Metal and CUDA upload the same table, so both backends move
together. The Qwen4 reference oracle takes the same FP32 scalar form,
and the Qwen4 core facades export rope_freq where they lacked it. Every
moved word is a 1-ulp move to transformers' bits, pinned by literals in
the tests; the CUDA open test's 1e4/32 words take the new values. The
XPU half of the original change stays separate.
@ashhart
ashhart merged commit 40e38f7 into main Nov 6, 2026
9 of 11 checks passed
ashhart added a commit that referenced this pull request Nov 6, 2026
@ashhart
ashhart deleted the lead/qwen4-rope branch November 10, 2026 16:34
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