Repository navigation
nemotron metal: chips without tensor units load when the packed kernels cannot build - #955
Conversation
…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
left a comment
There was a problem hiding this comment.
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.
|
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 |
…ide path when the pipeline cannot build (the packed-kernel pattern of ashhart#955); on chips where it builds, the default path is unchanged
…its when its packed kernels cannot build there
…ide path when the pipeline cannot build (the packed-kernel pattern of #955); on chips where it builds, the default path is unchanged
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 withKernelCompilewhen any pipelinefailed to build, including the 36 packed
coop_*andup_relu2_*kernels, which a chip without tensor units neverdispatches (
device.tensorUnits()false, GPU generation below 17):Forward.coopandupRelu2return throughrowCallthere, 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 anykernel on a chip with tensor units, still fails the load as before.
Kernels.getpanics by name on anullkernel;deinit, the profiler (encoder.zig) andwide_probe.pipelinesskip it, andbyPrefixreturnsnull.Verified outcome
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.
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:
mainat 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-4bitat d9d758fb.macOS 26.3.1 on this M4 (before the update): 1.0.11's
servelogged 36 pipeline errors,Undefined symbols: __tensorops_impl_matmul2d_op_run_cooperative_dv_b16_dv_ui4_f32, then exited withKernelCompile.macOS 26.3.1:
libTensorOps.rtlibfrom Apple's 26.3.1 (25D2128) restore image has 1,592 entries and noui4operation (
__tensorops_impl_matmul2d_op_run_cooperative_dv_b16_dv_ui4_f32and its_v2are both absent). The26.4 (25E246) and 26.6.2 (25G83) images have it (90
ui4entries each) and 27.0.1's has both names among 180, sothe 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 onmacOS 27 calls the
_v2name) and the probe made to take it, served withtensorfold-native serve <model dir> --name local-model --parallel 4 --context 16384 --temperature 0 --no-thinking --no-update-check --prompt-cache-gib 0:main: 36Undefined symbolspipeline errors, thenKernelCompile, exit after 12 s, as on 26.3.1.36 packed kernels did not build; this chip takes the row projections instead, thenhealthy. A request that reached a packed kernel would panic by name; none did.
Exactness,
--parallel 4, prompt cache off, token_sha per reply:mainvs this branchmainvs this branch, emulated 26.3.1"draft": falsebench_concurrent.py --alone --serial --levels 1,2,4(code and chat, temperature 0 and 1.0)On each of the three builds, alone equals concurrent (84 of 84) and drafted equals
"draft": false(30 of 30 and24 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 isbench_openai.py(256 tokens, temperature 0,median of three); prompt is
bench_cache.py --require-coldon a 5,310-token prompt (median coldttft_sof threerepeats):
mainmainThe same within run-to-run spread, and every reply's token_sha is equal between the builds.
Tests run:
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 nothingdefines, 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
nulland every other kernel is there. With the load's behaviour as onmainit 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, 0fail (46a08c1: 2989 of 2999, 10 skip); the one more is the new test.
zig build fuzz-cortheonpasses.zig fmt --check build.zig zigis clean. Lean: 517 problems on the base and 517 on this branch, 0 new(
lean_new.py).zig build test-kernel-contractpasses, 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
"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.)
arithmetic changes; every reply's tokens are equal.)
SUMMARYline is in the receipt. (n/a: no GPU kernel is added or changed. The new test's stub library exists onlyinside the test.)