Skip to content

metal: Flash Next's rotary scalar from fn_rotary_scalar.metal in the three prompt libraries that copied it (#2251) - #5061

Merged
ashhart merged 5 commits into
ashhart:mainfrom
jschmied:dedup-2251-rotary-scalar
Nov 25, 2026
Merged

ashhart merged 5 commits into
ashhart:mainfrom
jschmied:dedup-2251-rotary-scalar

Conversation

@jschmied

Copy link
Copy Markdown
Contributor

Part of #2251 (group: tf_rotary_scalar). Head 3d6950a, one commit on main 0a5c699.

What changes

  • prefill/fn_select.metal, fn_pool_pos.metal and fn_mrope.metal each carried fn_rotary_scalar.metal's text verbatim (the TF_RotaryScalar struct and tf_rotary_scalar).
  • Each now has #include "fn_rotary_scalar.metal" in its place. sources.zig's withRotaryScalar puts the file in at that line at comptime, as sources.drama3.codec does for its include, because the runtime compiler has no include path.
  • So flashnext_select, flashnext_pool_pos and flashnext_mrope are byte-identical to main's. rotary_cache.zig:23 needs no change: it still finds flashnext_rotary_scalar's text exactly once in each of them.
  • The hash-named q4_attn_prep_* and q4_idx_pool_* copies stay as recorded.
  • 4 files, +13 −27.

Core vs backend-only: prefill/fn_rotary_scalar.metal was already the shared Metal piece (the rotary cache and sweep use it); only Flash Next's Metal sources and their assembly change. 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)

  • Source text: emit-metal-runtime-sources without tensor units (1044 files) and with them (1070), and emit-qwen4-metal-sources (81): diff -r main against this head, 0 files differ. Every assembled library is byte-identical, so no IR step was needed.

  • Kernel contract, tf-kernel-contract --only, main = head (logs identical apart from timings): flashnext rotary 10 pass gates 1-4, 0 fail, 0 limit problems; flashnext vision 3 pass, 0 fail, 0 limit problems.

  • Family checks: test-flashnext-rotary-bound-host test-flashnext-vision-contracts-host test-flashnext-precise-host test-flashnext-bound-probes-host test-rotary-sweep-host test-kernel-symbols-host on the Mac: 21/21 steps, 79/79 tests. On Linux arm64, test-flashnext-rotary-bound-host test-flashnext-vision-contracts-host: 7/7 steps, 33/33 tests.

  • Served hash: not run. The compiled texts are byte-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-tests 21/21; zig fmt --check and git diff --check clean. pr_check on this head alone: 0 errors, lean 164 vs 164 on main, 0 new.

Proposed CHANGELOG line (for you to place):

  • No personal data, machine names, internal hosts or local paths in the diff or its commits. No AI attribution lines.

@ashhart

ashhart commented Nov 25, 2026

Copy link
Copy Markdown
Owner

Thank you @jschmied. The three assembled libraries are byte-identical, and each still contains the exact scalar text once for the rotary-cache replacement. No arithmetic or caller change remains open.

This looks ready to land through the usual checks. Thank you for keeping the hash-named copies separate.

  • Synthena

ashhart and others added 5 commits November 25, 2026 16:29
…three prompt libraries that copied it (ashhart#2251)

fn_select, fn_pool_pos and fn_mrope each carried fn_rotary_scalar.metal's text verbatim. They now include it, and
sources.zig puts the file in at that line, so the assembled libraries are byte-identical to before.
@ashhart
ashhart force-pushed the dedup-2251-rotary-scalar branch from 3d6950a to 1a6e989 Compare November 25, 2026 16:29
@ashhart
ashhart merged commit 70bd302 into ashhart:main Nov 25, 2026
ashhart added a commit that referenced this pull request Nov 25, 2026
@ashhart

ashhart commented Nov 25, 2026

Copy link
Copy Markdown
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.

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.

2 participants