Repository navigation
RFC: zig cuda: serve through tensorfold-native, with a CUDA family registry (Nemotron first) - #443
Conversation
…ne CUDA registry native/cuda.zig owns the device, the lane round loop and the lane host; each CUDA family brings only its lane backend through `open` (families/nemotron/cuda_native.zig, as `tensorfold lanes` loads it). The lane host's thread gets the context made current on its first backend call. `zig build native` on Linux installs tensorfold-native with these engines; core takes the tokenizer as a module so the server shares it, and the server's key-file checks use statx on Linux, whose libc has no stat.
|
Thank you, @jschmied. We want this shape and we're building on it: your commit is now the base of our Zig CUDA serving branch, under your name, and the work is running on GB10 and RTX PRO 6000. The registry stays as you designed it: |
|
Receipts for this branch on a DGX Spark (GB10), in case they help the review. I did not change any code. Environment
Build and tests
Exactness, through the server (
Exactness, command line ( Speed (single run each, not alternated)
From Not run
|
|
Thank you, @jschmied. To your design question: the registry is the right shape, and it has held up. We built a dozen commits on your commit unchanged, and a lone-stream driver, graph capture per draw mode and shared rounds all fit without changing it. It's merged into |
…h tensorfold-native with a CUDA family registry
RFC, draft. ZIG-PREVIEW.md lists "the CUDA backend … needs the server wiring and more families". This is a proposal for that wiring. Before I go further, I'd like to know whether the shape suits you.
Design question
native/metal.zigopens each family inline (if model_type == …). For CUDA this PR puts the device, the lane round loop and the lane host in one generic file,zig/src/native/cuda.zig. Each family is one entry in itsregistryand bringsonly its lane backend through
open:families/nemotron/cuda_native.zig, about 60 lines, loads the engine, MTP head andLanesthe waytensorfold lanesdoes. Flash Next (NVFP4) or another family would then add an entry and itslanes.Backend, with no server code. Would you rather keep the per-family pattern ofmetal.zig?What changes
zig/src/native/cuda.zig(new):backends,families(built from the registry), andchip()(nvidia-sm<capability>, e.g.nvidia-sm121on aGB10);
open()checks the context, finds the kernel set (TENSORFOLD_CUDA_KERNELS, elseshare/tensorfold/cuda/sm<cc>beside the binary, as the CLI does), readsTF_CUDA_DEVICE, then buildslanes.Config,lanes.EngineandLaneHost.wrapped so that its first call on a thread makes the context current; the family code doesn't see it.
zig/src/families/nemotron/cuda_native.zig(new), andnemotron.nativeexported fromcuda.zig.zig/build/cuda.zig:zig build nativeon Linux installszig-out/native/bin/tensorfold-nativewith these engines.The adapter's tests join the host tests.
zig/src/core/root.zig:coretakes the tokenizer as a module (@import("tokenizer")). Otherwise the server'stokenizermodule andcorewould both owntokenizer.zig, which Zig refuses. The Metal build doesn't buildcore.zig/src/server/auth.zig: the key-file checks usestatxon Linux, because Zig 0.17'sstd.chas nofstat/statthere. Every other OS keeps the existing
stat/fstatpath unchanged.Tested
zig-flashnext88c424e.zig build,zig build nativeandzig build test(the host tests, including the two new ones) all pass.tensorfold-native capabilities --jsonon the GB10 reports"chip": "nvidia-sm121","backends": ["cuda"],"families": {"nemotron_h": ["mlx-q4g64"]}, and--backendtakesautoandcuda.Not tested yet
"draft": false, concurrent againstsolo, and server against
tensorfold run/gate.pytoken hashes. That needs the kernel capture(
zig/tests/cuda/nemotron/box) and the checkpoint on the box. I'll add the receipts here if the design is welcome.auth.zigchange keeps the non-Linux path as it was, but I haven't compiled it on a Mac.Open points, besides the design question
nvidia-sm121, or something else?prefill_stepis the engine's 2,048-row chunk. Graphs stay off, as intensorfold lanes, because lane windows vary.