Repository navigation
metal: Flash Next's hyper-connection stream RMS from one source (#2251) - #5060
Merged
Merged
Conversation
Owner
|
Thanks @jschmied. The shared RMS keeps the same additions and rsqrt, and both Flash Next callers and Qwen4's extraction use it correctly. The recorded compiler and width comparisons support this source move; the separate baseline contract failure stays recorded. This looks ready to land through the usual checks.
|
…art#2251) fn_rows_hc.metal's stream_rinv and fn_prompt.metal's pf_rinv had the same body. core/stream_rinv.metal now holds it, ahead of both libraries in sources.zig; the Qwen4 HC source reads it from there.
ashhart
force-pushed
the
dedup-2251-stream-rinv
branch
from
November 25, 2026 16:29
cbcadb0 to
5ef3946
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. |
ashhart
added a commit
to jschmied/TensorFold
that referenced
this pull request
Nov 25, 2026
ashhart
added a commit
that referenced
this pull request
Nov 25, 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.
Part of #2251 (group:
stream_rinv). Head cbcadb0, one commit on main 0a5c699.What changes
decode/fn_rows_hc.metal,stream_rinv) and its prompt glue (prefill/fn_prompt.metal,pf_rinv) had the same hand-written stream RMS:rsqrt(sum of nt partial sums / dims + eps).stream_rinv, in the newcore/stream_rinv.metal.sources.zigputs it ahead offlashnext_promptandflashnext_rows_hc;pf_rinv's one call is renamed. The file includesmetal_stdlibitself, becausefn_rows_hc's defines come before its own include.pf_hc_normed,pf_hc_mixand the RMS out of the prompt glue (flashnext/hybrid_hc_sources.zig). It now readsstream_rinvfromqwen4/metal_hc.zig'sprompt, which iscore/stream_rinv.metalfollowed byfn_prompt.metal, assources.flashnext_promptholds them;source_test.ziguses the same constant.qa_hc_*files keep their own copies, as you asked.Core vs backend-only:
core/stream_rinv.metalis the shared Metal piece; the rest is Flash Next's and Qwen4's Metal sources and their assembly. No CUDA files.Same bits (M3 Pro, no tensor units; macOS 27.2, metal 32023.921, Zig 0.17.0; main 0a5c699 against this head)
IR,
-std=metal4.1 -S -emit-llvmunder the libraries' flags (-fmetal-math-mode=safe -fmetal-math-fp32-functions=fast), with and without tensor units. The emitted runtime libraries change only in these, and every function is identical, in the same order:runtime_sources/flashnext.zig:56andreplay_prompt.zig:96's header withflashnext_prompt): 16 functions each;emit-qwen4-metal-sourceswrites): 4 functions each.Kernel contract,
tf-kernel-contract --only, main = head (logs identical apart from timings):--only flashnextstops witherror: UnknownLaunchafterPASS limits: 42 ... 0 problemson main as on this head (as in metal: the two pairs of u32 copy kernels from one source (#2251) #4740), and its labels don't cover the prompt glue or the HC rows. Sotf-flashnext-widthsran on both arms with identical output: HC rows 726 checks and prompt 637 checks PASS, every row's bits equal in every window, its negative control red.Family checks:
test-qwen4-host test-qwen4-native-mixers-host test-qwen4-metal-sources test-qwen4-prefill-widths-host test-flashnext-prefill-pairs-host test-flashnext-scheduling-host test-kernel-symbols-hoston the Mac: 117/117 steps, 212/212 tests. On Linux arm64,test-qwen4-host test-qwen4-native-mixers-host: 17/17 steps, 135/135 tests.Served hash: not run. Every served library's IR is identical, so no reply can change; for the same reason no seeded, resume, concurrency or refusal checks against main.
x86 CI green on a merge of this head with two sibling metal: unify duplicated kernels (attention partials, norms, gemm_nax wrappers, glue, RoPE) #2251 groups: merge e239bd5c70 of cbcadb0 (stream_rinv), 3d6950a (rotary scalar) and 36cd5f9 (quantized embed) on main 0a5c699.
zig build -Dfixed-cpu test-host test test-golden test-kernel-contract test-server-security test-pull-security fuzz-cortheon check-release-paths: 2622/2622 steps, 27591/27761 tests (170 skipped);check-native-cuda-host compile-cuda-tests21/21;zig fmt --checkandgit diff --checkclean. pr_check on this head alone: 0 errors, lean 164 vs 164 on main, 0 new.Proposed CHANGELOG line (for you to place):