Skip to content

nemotron metal: chips without tensor units load when the packed kernels cannot build - #955

Merged
ashhart merged 1 commit into
ashhart:mainfrom
jishnuvenugopal:fix/nemotron-packed-kernels-optional
Oct 18, 2026
Merged

ashhart merged 1 commit into
ashhart:mainfrom
jishnuvenugopal:fix/nemotron-packed-kernels-optional

Conversation

@jishnuvenugopal

Copy link
Copy Markdown
Contributor

Thank you, @ashhart, for the row projections that took Nemotron's dense projections off the tensor-op kernels on
chips without tensor units (e473ec8), and for the load-time probe and prebuilt metallib you added for #451 the same
morning. This builds on both, and thanks to @omar16100 for the #451 report that started it.

What this changes

kernels.load (zig/src/families/nemotron/kernels.zig) failed the whole load with KernelCompile when any pipeline
failed to build, including the 36 packed coop_* and up_relu2_* kernels, which a chip without tensor units never
dispatches (device.tensorUnits() false, GPU generation below 17): Forward.coop and upRelu2 return through
rowCall there, and MTP's fused prep is off (k.rows != null).
On such a chip a packed kernel that fails to build now stays null, Pipeline.initOptional
(zig/src/metal/library.zig) logs its reason as info, and one warning gives the count. Any other kernel, and any
kernel on a chip with tensor units, still fails the load as before. Kernels.get panics by name on a null kernel;
deinit, the profiler (encoder.zig) and wide_probe.pipelines skip it, and byPrefix returns null.

Verified outcome

  • Why: with macOS 26.3.1, Nemotron does not start on a Mac without tensor units (M1 to M4; tested on an M4). On this M4, before it moved to 27.0.1, 1.0.11
    stopped at load because 36 kernels failed to link, and these chips never use those kernels. macOS 26.3.1's
    tensor-op library has none of the 4-bit operations they call (0 of its 1,592 entries); they arrive in 26.4.
  • What was done: on chips without tensor units, those kernels are now optional at load.
  • Result: on an emulated 26.3.1 (this M4, with that operation taken out of the prebuilt kernels), the main branch
    stops after 12 s and this branch serves. Every reply equals the main branch's on the normal path: 132 of 132,
    across 8 prompt lengths, drafted and plain, and 1, 2 or 4 requests at once. Decode and prompt speed are unchanged.

Receipt

  • Environment: main at 46a08c1 (1.0.12), Zig 0.17.0, Apple M4 (no tensor units), macOS 27.0.1,
    TensorFold/NVIDIA-Nemotron-3.5-Lightning-30B-A3B-MLX-4bit at d9d758fb.

  • macOS 26.3.1 on this M4 (before the update): 1.0.11's serve logged 36 pipeline errors, Undefined symbols: __tensorops_impl_matmul2d_op_run_cooperative_dv_b16_dv_ui4_f32, then exited with KernelCompile.

  • macOS 26.3.1: libTensorOps.rtlib from Apple's 26.3.1 (25D2128) restore image has 1,592 entries and no ui4
    operation (__tensorops_impl_matmul2d_op_run_cooperative_dv_b16_dv_ui4_f32 and its _v2 are both absent). The
    26.4 (25E246) and 26.6.2 (25G83) images have it (90 ui4 entries each) and 27.0.1's has both names among 180, so
    the failure is 26.3.x's (26.3.2 and earlier 26.x not checked). All 36 packed entry points in 1.0.11's embedded
    metallib call that operation.

  • Emulated 26.3.1, the same build with the packed metallib compiled with
    -D__tensorops_impl_matmul2d_op_run_cooperative_dv_b16_dv_ui4_f32_v2=__tensorops_impl_absent_for_test (a build on
    macOS 27 calls the _v2 name) and the probe made to take it, served with tensorfold-native serve <model dir> --name local-model --parallel 4 --context 16384 --temperature 0 --no-thinking --no-update-check --prompt-cache-gib 0:

    • main: 36 Undefined symbols pipeline errors, then KernelCompile, exit after 12 s, as on 26.3.1.
    • This branch: 36 info lines, 36 packed kernels did not build; this chip takes the row projections instead, then
      healthy. A request that reached a packed kernel would panic by name; none did.
  • Exactness, --parallel 4, prompt cache off, token_sha per reply:

    Requests main vs this branch main vs this branch, emulated 26.3.1
    8 prompt lengths (23 to 4,194 tokens: under and over 128 rows, 1 to 3 chunks), temperature 0 and 1.0, drafted and "draft": false 48 of 48 equal 48 of 48 equal
    bench_concurrent.py --alone --serial --levels 1,2,4 (code and chat, temperature 0 and 1.0) 84 of 84 equal 84 of 84 equal

    On each of the three builds, alone equals concurrent (84 of 84) and drafted equals "draft": false (30 of 30 and
    24 of 24).

  • Speed before and after, --parallel 4, prompt cache off. Each build times its own window-cost table at first load,
    so both read one table (main's) and the runs alternate. Decode is bench_openai.py (256 tokens, temperature 0,
    median of three); prompt is bench_cache.py --require-cold on a 5,310-token prompt (median cold ttft_s of three
    repeats):

    Run Build fibonacci-raw gpu-chat-no-think 5,310-token prompt
    1 this branch 47.7 tok/s 47.6 tok/s 13.03 s
    2 main 48.0 tok/s 47.7 tok/s 12.94 s
    3 this branch 48.2 tok/s 47.8 tok/s 13.58 s
    4 main 48.2 tok/s 48.0 tok/s 13.54 s

    The same within run-to-run spread, and every reply's token_sha is equal between the builds.

  • Tests run:

    • New, without tensor units the kernels load when the packed ones cannot link, as on macOS 26.3
      (kernels.zig): the packed kernels' library is a stub whose functions call a [[visible]] function that nothing
      defines, so the library loads and each packed pipeline fails to link, as on 26.3.1. It checks the load succeeds,
      the packed kernels are null and every other kernel is there. With the load's behaviour as on main it fails
      (36 link errors, KernelCompile); it passes on this branch. It skips on chips with tensor units and without a GPU.
    • zig build test test-golden -Dcpu=apple_m1, uncached: 208 of 208 steps, 2990 of 3000 tests pass, 10 skip, 0
      fail (46a08c1: 2989 of 2999, 10 skip); the one more is the new test. zig build fuzz-cortheon passes.
      zig fmt --check build.zig zig is clean. Lean: 517 problems on the base and 517 on this branch, 0 new
      (lean_new.py). zig build test-kernel-contract passes, 18 of 18, on 46a08c1 and on this branch.
      zig build -Dcpu=apple_m1 (every program, including the Nemotron tools) builds.
  • Unchanged: chips with tensor units (M5 and later), whose packed kernels still must build; the kernels' sources, the
    prebuilt metallib and sourceHash.

  • Lands on its own: no open PR touches these four files.

  • Not run, and why: no macOS 26.3.x machine or M5 here, so 26.3.1 is emulated as above and the M5 path is unchanged
    code. An M5 on 26.3.x does dispatch these kernels, so it still stops at load; that needs a different route and an
    issue first. CUDA: no change.

Checklist

  • Every token still goes through the lane rounds. No serial path, and nothing that needs drafts off.
  • Drafted output equals "draft": false, a resumed prompt equals a fresh one, and concurrent equals solo.
    (Drafted and concurrent re-run above; resumed not re-run, the prompt cache is untouched.)
  • No precision traded for speed. If the bits change, the description says which sums change and why. (No
    arithmetic changes; every reply's tokens are equal.)
  • A new or changed GPU kernel is registered with the kernel contract (docs/kernel-contract.md); each backend's
    SUMMARY line is in the receipt. (n/a: no GPU kernel is added or changed. The new test's stub library exists only
    inside the test.)
  • Prompt processing is no slower than the last release. (Above.)
  • The description says which platforms I ran, Metal M1 to M5 and CUDA, and which I could not.
  • New tests fail before the change, pass after it, and skip cleanly without their dependency.
  • Comments and docstrings are one line. No measurements or history in the source.
  • No personal data, machine names, internal hosts or local paths. No AI attribution lines.

…ls cannot build

On a chip without tensor units Nemotron's dense projections run through core/row_projection (Forward.rowCall), so
the 36 packed coop and up_relu2 kernels are never dispatched, yet kernels.load failed the whole load with KernelCompile
when any of them failed to build. On macOS 26.3, whose tensor-op library has no bf16 x uint4 operation, every one
fails to link. On such a chip a packed kernel that fails to build now stays null, Pipeline.initOptional logs its
reason as info, and one warning gives the count; any other kernel, and every kernel on a chip with tensor units, still
fails the load. Kernels.get panics by name on a null kernel; deinit, the profiler and wide_probe skip it.

@cwschroeder cwschroeder left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Source review of c0b5ee44 on 46a08c18, covering the four changed files. No new material source issue found in that scope.

The optional path is limited to packed kernels on devices without tensor units. Required failures still abort loading, and M5 keeps required packed pipelines. The nullable entries are handled by get, byPrefix, profiling, wide_probe and deinit. The normal projections return through rowCall; the direct MTP coopParts path is excluded by fused = k.rows == null.

All four current-head CI checks pass. This is a source review; I did not execute this branch's Metal test or independently reproduce the M4 load/output receipts. The new stub-library test covers failed packed-pipeline creation and the presence of row pipelines; numerical equivalence remains in your device receipts.

@ashhart ashhart mentioned this pull request Oct 17, 2026
@ashhart
ashhart merged commit 2496881 into ashhart:main Oct 18, 2026
4 checks passed
@ashhart

ashhart commented Oct 18, 2026

Copy link
Copy Markdown
Owner

Thank you, @jishnuvenugopal, for allowing optional packed kernels to remain absent on Macs without tensor units.

We merged your work for 1.1.0 in 2496881. Our integration releases pipelines already built when a required kernel or row-pipeline load fails, using the null-initialized table and joined workers for safe cleanup.

Packed kernels remain required on chips with tensor units.

Apple M3 Ultra served parity and cleanup/optional-kernel host checks passed; tensor-unit model configurations retain their own gates.

Posted by Ash's AI Assistant Synthena

@jishnuvenugopal
jishnuvenugopal deleted the fix/nemotron-packed-kernels-optional branch October 19, 2026 05:40
EugeneClaw added a commit to EugeneClaw/TensorFold that referenced this pull request Oct 19, 2026
…ide path when the pipeline cannot build (the packed-kernel pattern of ashhart#955); on chips where it builds, the default path is unchanged
BlivionIaG pushed a commit to BlivionIaG/TensorFold that referenced this pull request Oct 20, 2026
…its when its packed kernels cannot build there
ashhart pushed a commit that referenced this pull request Oct 21, 2026
…ide path when the pipeline cannot build (the packed-kernel pattern of #955); on chips where it builds, the default path is unchanged
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.

3 participants