Skip to content

metal: Nemotron's, Qwen3.8-27B's and LFM2's prompt pick from one source (#2251) - #4739

Merged
ashhart merged 3 commits into
ashhart:mainfrom
jschmied:dedup-2251-prompt-pick
Nov 23, 2026
Merged

ashhart merged 3 commits into
ashhart:mainfrom
jschmied:dedup-2251-prompt-pick

Conversation

@jschmied

Copy link
Copy Markdown
Contributor

Part of #2251 (group: the two prompt picks). Head 7cd71d9, two commits on main b192eaa.

What changes

  • nemotron_prompt_pick (nemotron/prompt_pick.metal) and q27_attn_prompt_pick (qwen27/attention_prompt.metal) had the same body: after the non-finite scan, write the indirect grids for the finite or the masked prompt kernel, then clear the flag.
  • Both now come from TF_PROMPT_PICK(NAME) in the new core/prompt_pick.metal. Nemotron keeps its max_total_threads_per_threadgroup(1); the 27B's had none and still has none. Names, buffer indices and signatures are unchanged.
  • The macro reaches the libraries that compile the picks:
    • Nemotron: nemotron/prompt_masked.zig's picker (both masked libraries);
    • Qwen3.8-27B: the runtime sources module (zig/build/qwen27.zig puts it ahead of attention_prompt) and the paged twin (qwen27/paged.zig).
  • Second commit: lfm2_prompt_pick was the same body with a uint loop counter; it uses the macro too (lfm2/prompt_masked.zig). It is a separate commit so it can be dropped on its own; the IR below shows the counter type changes nothing.
  • 8 files, +19 −22.

Core vs backend-only: core/prompt_pick.metal is the shared Metal piece; the rest is each family's Metal source assembly.

Same bits (M3 Pro, no tensor units; run on a3e5359, which differs from this head only in core/prompt_pick.metal's comment; macOS 27.2, metal 32023.921, Zig 0.17.0; main b192eaa against this head)

  • IR: every runtime library assembled by zig build emit-metal-runtime-sources on both arms, with and without tensor units (1040 and 1066 libraries, manifests identical). Exactly the libraries holding a pick changed in text (8 and 11), each compiled with -std=metal4.1 -S -emit-llvm under its manifest's flags:

    • without units: Nemotron masked contiguous and masked paged; the 27B attention library paged and unpaged, with prompt kernels, at G = 4, 6, 8: all identical;
    • with units: Nemotron masked contiguous, its fp32-PV form, masked paged and its fp32-PV form; the 27B attention library paged and unpaged at G = 4, 6, 8: all identical;
    • LFM2's masked prompt library (45 functions): identical.
    • Only ModuleID, source_filename and source-path metadata differ.
  • Kernel contract, tf-kernel-contract --only, main = head:

    • nemotron: 67 pass gates 1-4, 0 fail, 1 known; 29/29 controls red; 0 limit problems;
    • qwen27: 34 pass, 0 fail; 6/6 red; 0 limit problems;
    • q27: 24 pass, 0 fail; 0 limit problems;
    • lfm2: 4 pass, 0 fail; 6/6 red; 0 limit problems.
  • Family checks: test-qwen27-paged-contract-host test-qwen27-masks-host test-lfm2-load-host test-kernel-symbols-host: 15/15 steps, 30/32 tests (2 skipped). zig build test-qwen27 (which reaches attention_pick_test.zig): 48/48 steps, 205/207 (2 skipped) on head and main.

  • Served hash: not run. Every library that compiles a pick has identical IR, so no served 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 three sibling metal: unify duplicated kernels (attention partials, norms, gemm_nax wrappers, glue, RoPE) #2251 groups: merge 72b153f490 of b83b26a, a3e5359, 478fcb6 and ebf6db7 on main b192eaa (the groups touch separate files, apart from separate hunks of sources.zig in the copy and vision groups). zig build -Dfixed-cpu test-host test test-golden test-kernel-contract test-server-security test-pull-security fuzz-cortheon check-release-paths: 2431/2431 steps, 16239/16350 tests (111 skipped); check-native-cuda-host compile-cuda-tests 17/17; zig fmt --check and git diff --check clean. pr_check and lean flagged one new multi-line comment in the prompt-pick group's core/prompt_pick.metal; on the merge with that one-line fix (16ea8fe6e4, prompt pick at 7cd71d9): pr_check 0 errors, lean 165 vs 165 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.

jschmied and others added 3 commits November 23, 2026 18:45
…art#2251)

nemotron_prompt_pick and q27_attn_prompt_pick had the same body: the indirect grids for the finite or the masked
prompt kernel after the non-finite scan, then the flag cleared. Both now come from TF_PROMPT_PICK in
core/prompt_pick.metal; Nemotron keeps its one-thread reservation, names and signatures are unchanged.
lfm2_prompt_pick differed from the other two only in its loop counter's type (uint, not int).
@ashhart
ashhart force-pushed the dedup-2251-prompt-pick branch from 7cd71d9 to 45c4598 Compare November 23, 2026 18:45
@ashhart
ashhart merged commit b89f574 into ashhart:main Nov 23, 2026
2 of 12 checks passed
@ashhart

ashhart commented Nov 23, 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