Repository navigation
Nemotron on HIP: admit and load a bf16 token table beside quantized matrices - #3575
Conversation
|
Thanks @gilby for this, and for the careful refusal tests around it. What's good:
Must fix:
Optional:
Device cells: Strix Halo gfx1151 (HIP): the stock checkpoint unchanged against main plus #3242, and a bf16-table checkpoint loading and serving the same tokens. We will run the device check on our side.
|
50487b4 to
94e51ba
Compare
|
Updated #3575 on head
Re-verified on |
94e51ba to
5af5d05
Compare
|
Thanks @gilby. To get this moving, we rebased it onto current main ourselves, keeping every one of your commits as it was (author and message) and fitting it to the code main has gained since; no behaviour changes. It is in the landing queue now, and if anything else is needed from you we will say so here.
|
Gates 1-4 run the relu^2 stream tile at every width Nemotron's oQ checkpoints store it (4, 5, 6 and 8 bits in groups of 64), each wider width with a planted control that reads its codes as 4-bit and goes red at gate 3. Gate 5 records the 24 launches at 5, 6 and 8 bits on the four RDNA chips. The 1x8 tile at those widths spills to scratch on gfx1100; the records name it as a known finding and a host test holds the list to the records.
The loader, the memory plan and admission read config.json's per-module widths: MLX affine 4, 5, 6 and 8 bits in groups of 64, one width per tensor. Routed stacks are checked against their stated width. Other widths, unquantized projections and an MTP head inside the model's shards are refused by name. The uniform 4-bit checkpoint reads as before. The MTP head file is still read at the model's own width, so admission refuses it by name beside a model not stored 4-bit in groups of 64.
5af5d05 to
7a6d3af
Compare
|
Thank you @gilby. 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. |
What this changes
Nemotron 3.5 Lightning checkpoints can leave
backbone.embeddingsunquantized in BF16 (either"backbone.embeddings": falseinconfig.jsonor omitted fromquantizationalongside BF16 weights with no.scales/.biases), as mixed-precision exports do when keeping embeddings in 16-bit while quantizing the 52 layers' projections and routed experts. Before this, HIPconfig.parse, admission andload.zigrefused any Nemotron checkpoint without MLX affinescales/biasesonbackbone.embeddings.With this change (follow-on to #3242, as noted in #3061):
config.Config.readWith(gpa, io, dir, allow)andconfig.parseWith(..., .{ .bf16_embed = true })admit"backbone.embeddings": falsewhile keepingconfig.Config.read/config.parsestrict for non-HIP callers (config_test.zig);engine.zigcallsconfig.Config.readWithwhen opened without pre-admitted config.tensors.hasBf16Embeddefines the shared scale-less BF16 token-table rule once.admit.zig,plan.zigandwidths.zigadmit"backbone.embeddings": falseor scale-lessbackbone.embeddingsshards, count[vocab, hidden]2 * vocab * hiddenbytes at stored BF16 precision across--tpranks, label the startup line+bf16-embed(e.g.mlx-q4g64+q5g64+q6g64+q8g64+bf16-embed), and still refuse every other unquantized or unsupported tensor by name.native.zigpasses.cfg = v.configtoengine.Engine.load, andengine.zigpassesadmitted = (o.cfg != null)intoload.loadIntosohasBf16Embedruns once when opening viaadmit(and once inloadIntoonly when opened withoutadmit), keepinge.cfg.embed_bf16single-sourced andreadEmbedreading onlyc.embed_bf16.embedding.zig(readand devicegather, sharingcore.quant.dense.readStoredso weights stay un-widened BF16 on device) loads and gathers[vocab, hidden]BF16 token tables across--tp 1..8; prompt lookupembedRowsinzig/src/hip/kernels/andzig/src/families/nemotron/hip/forward.zigalready dispatches BF16 dense vs MLX affine embeddings fromTensormetadata.Issue: Refs Nemotron on HIP: read oQ mixed-width MLX checkpoints (4, 5, 6 and 8 bits, a width per tensor) #3061.
Stacked on: Nemotron on HIP: read each matrix at its own oQ width (part 2 of 3) #3242 (
be9fe6237).Published BF16-embedding checkpoint: https://huggingface.co/unigilby/NVIDIA-Nemotron-3.5-Lightning-30B-A3B-oQ4e-bf16embed-HIP (revision
928dc0b670dd4b9002991c136ecf0833e37b475c, genuineBF16backbone.embeddings.weight[131072, 2688]fromnvidia/NVIDIA-Nemotron-3.5-Lightning-30B-A3B-BF16@a9904d24bcc1d289a1950fa9d2b978c47cf903b9with"backbone.embeddings": falsebeside the mixed-widthunigilby/NVIDIA-Nemotron-3.5-Lightning-30B-A3B-oQ4e-HIPlayers andmtp-4bit.safetensors).Checks on this head
94e51ba9b(583e09fa6code +94e51ba9bchangelog stamp for Nemotron on HIP: admit and load a bf16 token table beside quantized matrices #3575, binary sha256ab0ec182396a...), stacked linearly on#3242be9fe6237(binary sha256b119d289c8cc...).python3 tools/zig/lean_check.py: 341 onbe9fe6237and 341 on94e51ba9b, 0 new findings;zig/src/families/nemotron/config.zigis 598 lines.python3 tools/pr_check.py --base be9fe6237 --pr 3575: 0 errors, 0 warnings.git fmt --check zig/andgit diff --check be9fe6237..HEADclean.94e51ba9b):zig build -Dhip=true hip-host-test check-native-hip-host test-native-hip-host --summary all): 18 of 18 steps succeeded;zig test zig/src/families/nemotron/config.zig: 12 passed, 1 skipped (Bolt local checkpoint absent), 0 failed.zig build -Dfixed-cpu -Dhip=true test-host-ci-linux-hip --summary all): 100 of 100 steps succeeded; 296 of 298 tests passed (2 skipped), 0 failed (test-native-hip-host26/26).gfx1151,94e51ba9b):zig build hip-kernel-test: 20 of 20 steps succeeded; 216 of 222 tests passed (6 skipped), 0 failed.tf-nemotron-hip-test loadon publishedunigilby/NVIDIA-Nemotron-3.5-Lightning-30B-A3B-oQ4e-bf16embed-HIP, an unlisted-config copy (with"backbone.embeddings": falseomitted),Lightning-oQ4e-user3892r4, andLightning-30B-A3B-MLX-4bit: all four load cleanly (18.41 GiBin 768 buffers foroQ4e-bf16embed-HIP,18.14 GiBin 770 buffers foruser3892r4,17.34 GiBin 770 buffers forMLX-4bit), pass the 128-row attention split check (0e0diff, finite true), and produce top logits13.813 at token 3267(bf16embed/ unlisted),13.625 at token 3267(user3892r4), and14.438 at token 44184(MLX-4bit).#3242(be9fe6237) refusesNVIDIA-Nemotron-3.5-Lightning-30B-A3B-oQ4e-bf16embed-HIPby name:tensorfold: config.json leaves backbone.embeddings unquantized; the native Nemotron kernels read it only as an MLX affine matrix(exit 1).config_test.zig:"a bf16 token table (false) is read only where a backend allows it, by its own name"(fails under defaultconfig.parse).admit.zig:"a bf16 token table beside quantized projections is admitted, its bytes counted as stored"and"with a bf16 token table, every other unquantized or unread tensor is still refused by name".plan.zig&widths.zig:"the plan counts a bf16 token table at the bytes its header gives, in both modes and on every rank"and"a bf16 token table has no width: its matrix is unnamed, never unserved, and its label says so".embedding.zig&load.zig:"the gathered rows are the file's bytes, first row and last, widened exactly; an id past the table is refused","a table that is not bf16 [vocab, hidden] is refused", and"Config.readWith admits backbone.embeddings false on disk while Config.read and parseWith reject invalid heads; readEmbed reads bf16 once decided".gfx1151tested), multi-rank GPUserve(tp=2plan byte split is checked by unit tests inplan.zigandtf-nemotron-hip-test load), andhip-kernel-contracton94e51ba9b(kernels unchanged frombe9fe6237).Receipt
gfx1151, 128 GiB unified RAM,performancepower mode), HIP 7.1, Zig 0.17.0. Raw receipts and sanitized summaries: https://gist.github.com/gilby/1bf33a7d9434cfaba703afd620189c32.TENSORFOLD_MEMORY_RESERVE_GIB=4 --context 131072 --parallel 4 --prompt-cache-gib 0, runningbench_cache --require-coldat 2K (2,048 tokens), 8K (7,099 tokens), and 32K (28,333 tokens),bench_concurrent --levels 1,2,4 --tokens 256 --reps 2 --alone --serial --temperatures 1.0,0, andbench_openai --tokens 256 --reps 2, preceded by a discarded warm-up.Receipt A — Same checkpoint (
Lightning-oQ4e-user3892r4with 8-bit embeddings): base#3242(be9fe6237) vs this PR (94e51ba9b) (B1 = oq8-b1,T1 = oq8-t1,T2 = oq8-t2,B2 = oq8-b2, tok/s except TTFT in s):B1(#3242)T1(n4)T2(n4)B2(#3242)bench_concurrentT=0.0 L=1bench_concurrentT=0.0 L=2bench_concurrentT=0.0 L=4[B_min, B_max]bench_concurrentT=1.0 L=1bench_concurrentT=1.0 L=2bench_concurrentT=1.0 L=4T2 > B1)bench_openaifibonacci-raw T=0.0[B_min, B_max]bench_openaigpu-chat-no-think T=0.0bench_openaifibonacci-raw T=1.0100.21..101.70)bench_openaigpu-chat-no-think T=1.0[B_min, B_max]bench_cache2K (2,048) coldttft_s[B_min, B_max]bench_cache2K cold 16-tok decode< 0.3%)bench_cache8K (7,099) coldttft_s[B_min, B_max]bench_cache8K cold 16-tok decodeT1, T2 > B1, B2)bench_cache32K (28,333) coldttft_s[B_min, B_max]bench_cache32K cold 16-tok decode[B_min, B_max]Lightning-oQ4e-user3892r4, every request'stoken_sha256/token_shamatchesoq8-b1(28/28bench_concurrent,8/8bench_openai,3/3bench_cachecold/repeated/concurrent rows,28/28concurrent-vs-alone,24/24alone-vs-"draft": falseper arm,0unequal,0failed). Planned weight memory is18.14 GiB(27,043,627,008B =25.19 GiBidle GTT) in all 4 arms.Lightning-30B-A3B-MLX-4bit,mlx-b#3242vsmlx-t#3575): identical17.34 GiBplanned (26,223,607,808B =24.42 GiBidle GTT),28/28bench_concurrent(28/28alone,24/24serial),8/8bench_openai, and3/3bench_cachehashes equal.Receipt B — Published BF16-embedding checkpoint
unigilby/NVIDIA-Nemotron-3.5-Lightning-30B-A3B-oQ4e-bf16embed-HIP(928dc0b670dd4b9002991c136ecf0833e37b475c,bf16-t1,bf16-t2, plussmoke-unlisted):19,771,766,528B (18.41 GiBin768buffers, labeledmlx-q4g64+q5g64+q6g64+q8g64+bf16-embed), idle GTT27,316,260,864B (25.44 GiB). Unlistedconfig.jsonsmoke also loads at18.41 GiB+bf16-embedand produces matching prefix text (fibonacci-raw,gpu-chat-no-think).bf16-t1andbf16-t2match each other28/28onbench_concurrent(14/14T=0,14/14T=1.0),8/8onbench_openai, and3/3onbench_cache(qualified: true), with28/28concurrent-vs-alone and24/24alone-vs-"draft": falseserial equal in each arm (0unequal,0failed).bf16-t1/bf16-t2):bench_concurrentT=0L=1,2,4122.5 / 134.2-135.0 / 167.3-168.0and T=1.0L=1,2,4106.7 / 110.3-111.2 / 144.6-146.0tok/s;bench_openaifibonacci-raw121.85-121.87(T=0) /103.54-103.60(T=1.0) andgpu-chat94.14-94.93(T=0) /82.72-83.48(T=1.0);bench_cachecold TTFT (2K / 8K / 32K)0.744-0.750 / 2.710-2.722 / 13.366-13.427s.Checklist
"draft": false, a resumed prompt equals a fresh one, and concurrent equals solo.