Repository navigation
perf(qwen35/hip): the prompt's residual add and post-mixer norm in one launch - #2099
Merged
Merged
Conversation
Owner
|
Thanks @AbrahamCete. Calling the fused add-and-norm that Nemotron already uses is a clean win: prompt logits byte-identical on both checkpoints, served tokens equal, and the byte test now covers Qwen's 2048 and 5120 widths. Ready to land. |
ashhart
force-pushed
the
perf/hip-qwen-prompt-add-rms
branch
from
November 4, 2026 17:06
79724b5 to
579d850
Compare
ashhart
added a commit
to AbrahamCete/TensorFold
that referenced
this pull request
Nov 4, 2026
…e launch The prompt forward ran tf_add and then tf_rms for the mixer's residual and the post-mixer norm. reduce.residualNorm takes both in tf_add_rms, as Nemotron's forward does, with the same bytes. The add + rms byte test now also covers Qwen 3.5's 2048 and 5120 widths.
ashhart
force-pushed
the
perf/hip-qwen-prompt-add-rms
branch
from
November 4, 2026 17:52
579d850 to
aa97f91
Compare
Owner
|
Thank you @AbrahamCete. 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. |
Owner
|
Thanks @AbrahamCete! This is in TensorFold 1.2.3, out now: https://github.com/ashhart/TensorFold/releases/tag/v1.2.3 |
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.
What this changes
For each layer and span of rows, Qwen 3.5's HIP prompt forward (
forward.span) ran the mixer's residual add (tf_add), then the post-mixer RMS norm (tf_rms), as two launches. Nemotron's forward already takes both in one launch throughreduce.residualNorm, with the same bytes as the two kernels. This PR callsreduce.residualNormthere.residualRmsstill runstf_addandtf_rmswheretf_add_rmsdoesn't apply: under the reference policy, or for widths outside 1025 to 8192.reduce.residual.forward.span.The add + rms byte test (
kernel_tests/nemotron/fused.zig) now also covers Qwen 3.5's widths, 2048 (35B-A3B) and 5120 (27B). It runs 192 cases where it ran 128, and every one writes the bytes oftf_addandtf_rms.Receipt
Environment: Ryzen AI Max+ 395 (gfx1151), Ubuntu 26.04, Zig 0.17.0, hipcc with HIP 7.1.52801 and Ubuntu clang 21.1.8 (rocprofv3 from ROCm 7.13). Checkpoints: Qwen3.8-27B-MLX-4bit and Qwen3.6-35B-A3B-MLX-4bit-MTP. Base: main 70ede48. Both sides were built from
git archivetrees.Kernel time, rocprofv3 over a 2048-token
tf-qwen35-test prefillrun, per prefill:tf_addruns 64 times instead of 128 andtf_rms65 instead of 129, plus 64tf_add_rmslaunches.tf-qwen35-test prefill, one prefill after a warm-up, alternated B C B C B C, seconds:The 27B's 38 ms at 2048 tokens is 0.7% of the pass, which is about the spread between runs there.
Served, one fresh server a run, alternated B1 C1 B2 C2:
tools/bench_cache.py --require-cold --tokens 16,--context 34816 --parallel 1 --prompt-cache-gib 0,ttft_s:Every cold request's
token_shais the same on both sides, with 0 cached tokens. At 32,768 tokens the difference is inside the spread between runs.tools/bench_concurrent.py --levels 1,4 --tokens 256 --reps 3 --temperatures 0 --alone --serial,--parallel 4: token hashes are equal on every server (35B code9f2923ac14d0, chata8c28b8297b4; 27B code2b28aa2108de, chata06fab348fbe), 0 failed. Decode is unchanged: code at 4 streams 228.6 / 230.2 on main and 230.1 / 230.7 here on the 35B; 43.9 / 43.7 and 43.9 / 43.6 on the 27B.Exactness:
tf-qwen35-test logits, 2048 tokens) are byte-identical to main's on both checkpoints, bf16 and--f32(27Bdcc85692582d/232dd4cf1fcd, 35B18bee11563f1/84fbaeb871d7).tf-qwen35-test check --only invariants: 27B 42 passed, 0 failed, 5 skipped; 35B-A3B 46 passed, 0 failed, 1 skipped, the same on both trees.Tests run:
zig build test -Dhip=true --summary all: 546/546 steps, 7046/7103 tests passed, 57 skipped.zig build hip-kernel-test --summary all: 129/130 passed, 1 skipped, 0 failed.SUMMARY gfx1151 82 kernels: 82 pass gates 1-4, 0 fail, 2 known findings; 7 controls: 7 red as planted, 0 missed; 145 limit problems, the same as main.tools/zig/lean_check.py: 425 problems, the same as main.zig fmt --checkis clean.Not run, and why:
residualNormsums the ranks' fp32 shares asreduce.residualdid, then takes the fp32 (wide) form of the add, which the byte test covers.