Skip to content

Upstream PR: Drama 3 on CUDA loads a compact NVFP4 checkpoint as stored - #4144

Merged
ashhart merged 2 commits into
ashhart:mainfrom
plotarmordev:feat/104-upstream-pr-drama-3-on-cuda-loads-a-comp
Nov 21, 2026
Merged

ashhart merged 2 commits into
ashhart:mainfrom
plotarmordev:feat/104-upstream-pr-drama-3-on-cuda-loads-a-comp

Conversation

@plotarmordev

@plotarmordev plotarmordev commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

What this changes

Drama 3 on CUDA now loads a compact NVFP4 checkpoint as stored — the published plotarmordev/drama-3-NVFP4-Pruned and the 5,900-expert variant — instead of refusing them. Before, zig/src/families/drama3/cuda/weights.zig accepted only .fp8g experts, so these checkpoints could not load at all. Now the loader stages a layer's held NVFP4 experts packed in slot order (never widened), d3_router_compact masks the router to the held ids and picks their slots, and a layer that dropped no experts keeps the original unmasked router. FP8 decode output is byte-identical to before the change; the win is device memory.

  • Issue: n/a — a checkpoint-format feature, adapted clean-room from the published checkpoints' own stored layout.
  • Stacked on: main. This PR carries one shared-loader commit (adf3e74ca, "drama3 metal: a listed expert the checkpoint does not store fails before any weight is mapped") that the CUDA loader calls into — weights.zig's quant.checkStored(&held, sh.map) and held.total(). It is a -x cherry-pick of a commit already merged on my fork; upstream needs it or the CUDA loader does not build.
  • atc overlap --json: reports no overlapping open pull request; the scan was incomplete at its time limit (otherPullRequestsLimit). The new files are all under zig/src/families/drama3/cuda, zig/tests/cuda/contract_drama3_router.zig, zig/kernels/cuda/drama3_moe.cuh and tools/zig/drama3_*, which no other open PR touches.

Checks on this head

  • Head commit: edbfbff7ac97f4ec077f5d3159c78d0a7d5df7be.
  • Lean checker, python3 tools/zig/lean_check.py, on the base and on this head: 221 problems on both, zero new.
  • Tests run, with the command and pass, fail and skip counts:
    • zig build test test-golden at edbfbff7a, macOS 27 arm64 (Apple M5 Ultra), Zig 0.17.0: 897/900 steps, 470/486 tests passed, 15 skipped, 1 failed. The failure is stage net: an unknown host is refused (zig/src/fabric/stage/net.zig:195): it expects AddressUnresolved and gets AddressInUse because this machine's resolver answers .invalid names with a fake 198.18.x address. zig/src/fabric/ is untouched by this branch and the test fails identically on the base e3fb56cb here — a resolver quirk, not this change.
  • CI: runs on this head; the local DNS failure above cannot reproduce in CI.
  • Not run, and why: no new GPU run — the GB10 numbers below are the receipts already measured for this work; the host suite's nvfp4_test (slot-order staging, FP64 decode contract) and the d3_router_compact contract test run without a GPU.

Receipt

  • Main against branch: the GB10 numbers below — same job, same machine, both formats measured against the FP8 checkpoint.
  • Boxes it reaches: CUDA on a GB10, through drama3-generate. Metal is touched only by the one shared loader commit.
  • New switch? None. A checkpoint whose router is compact is selected by the checkpoint itself; a compact map over FP8 experts is refused.
  • Environment, with the TensorFold commit, Zig and backend toolchain, machine and GPU, checkpoint and revision: edbfbff7a, Zig 0.17.0, nvcc 13.0, an NVIDIA GB10 (sm_121); the published plotarmordev/drama-3-NVFP4-Pruned GPTQ checkpoint as stored.
  • Paths and platforms the change reaches, which I ran and which I could not: CUDA (measured on a GB10); Metal and HIP are not reached.
  • Exactness: the nvfp4_test suite decodes the staged experts against the FP64 rounding contract.
  • GB10 check: tools/zig/drama3_compact_gb10.sh has not passed on the GB10; it stops at the compact --replay 1 step, at the codec-chunk comparison. Up to there everything is exact: FP8 greedy codes match the pre-feature base byte for byte, and the replay's frames, graph replay, poison/reset and chunk-1 PCM match. Then the same 17 frames decoded in chunks of 4 are not byte-identical to chunks of 1 (error: ReplayMismatch). The cause is main's CUDA codec, not this diff: replay.zig, cuda/codec.zig, cuda/tts.zig, cuda/blas.zig and generate.zig are the same blobs at e3fb56cb (main before this PR), edbfbff7 and a57d9c23, four GB10 runs fail identically there (top-852321a95766, top-d1a42040bb89, top-0e0b87a98a6a, top-cc8aa7c48955; details in /Users/Shared/agent-work/tensorfold-out/4144-replay/REPORT.md), and plain main e3fb56cb alone fails the same way in job top-171f7969b5e0 (FP8 checkpoint, --codec, --replay 1: codec chunk 1 passes twice, then chunk 4 ReplayMismatch at replay.zig:81), proving the codec-chunk mismatch is main's own, not this diff. The batched-prefill, kernel-contract and limits steps after it have not run on the GB10 yet.
  • Codec chunks on CUDA: the GB10 check (from 8aabdc78) keeps every exact check exact, namely frames, graph replay, poison/reset and PCM chunk 1 against chunk 1, and reports PCM at codec chunks 4 and 16 against chunk 1 as max abs and RMS difference, for information and not as a gate. That difference is a known property of main's CUDA codec: decodeChunk runs each layer as a cuBLAS GEMM whose N is the chunk's frame count, and cuBLAS picks its kernel by shape. An option for the maintainer is a chunk-invariant codec, with a fixed algorithm per layer.
  • Main against this branch, same machine and checkpoint: the memory and speed figures below.
  • Decode speed before and after: RTF is parity, not the point — the win is memory.
  • Prompt speed before and after: n/a, unchanged; batched prefill is gated at its own capacity.
  • Licence of any new weights or drafter: the checkpoints are the already-published plotarmordev/drama-3-NVFP4-Pruned variants; no new weights here.

Measured on the GB10 in the same job, compact NVFP4 against FP8:

Metric Compact NVFP4 FP8
Device peak (checkpoint A) 21.71 GiB 39.57 GiB
Device peak (checkpoint B) 19.29 GiB 39.57 GiB
RTF (run 1) 2.157 ~2.3
RTF (run 2) 2.233 ~2.3
Kernel contract, only when a GPU kernel is new or changed
  • Kernels registered with the contract, and the kernel each one replaces: d3_router_compact — the masked variant of d3_router; none replaces an engine kernel.
  • A planted control for each new kernel, and each one fails as planted: contract_drama3_router.zig runs d3_router unmasked as the control; it must fail gate 3, and does.
  • Each backend's SUMMARY line and exit status: tools/zig/drama3_compact_gb10.sh runs tf-cuda-test kernel-contract 'compact router' (gates 1–4 and the unmasked control) and kernel-contract-limits; each RECORD drama3 d3_router_compact line lands in the receipt.
  • Chips I could not run: only the GB10; no other CUDA part.

Checklist

  • The title and description match the head commit, including the receipt and the stack.
  • 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 in the diff or its commits. No AI attribution lines.

No visible change: nothing this PR changes shows on screen.

How to check

  • Base commit (main): 9e2a9bd7a93d3c6cd333d6db10a1bd05d7478145
  • Head commit: a57d9c23d40693cd5f10a1fabb1b2d27e52d7661
  • Machine: a Mac mini M-series · macOS 27 · zig 0.17.0

Test results:

  • zig build test test-golden at edbfbff7ac97 (older head): 470 passed, 1 failed, 15 skipped
  • zig build test-cuda-host at adf3e74ca71a (older head): 10 passed, 0 failed, 0 skipped
  • python3 tools/zig/drama3_limits_gate_test.py at edbfbff7ac97 (older head): 8 passed, 0 failed, 0 skipped
  • zig build test-golden at edbfbff7ac97 (older head): 377 passed, 0 failed, 0 skipped
  • nice -n 10 zig build test test-golden at edbfbff7ac97 (older head): 470 passed, 1 failed, 15 skipped
  • nice -n 10 zig build test at edbfbff7ac97 (older head): 470 passed, 1 failed, 15 skipped
  • zig build test-qwen35-modelopt-admission-host at a57d9c23d406: 1 passed, 0 failed, 0 skipped
  • zig build test-drama-host check-drama-cuda-host test-drama-metal-quant-host test-drama-nvfp4-reference-host test-drama-prefill-host at a57d9c23d406: 5 passed, 0 failed, 0 skipped
  • zig build test-golden test-kernel-contract at a57d9c23d406: 2 passed, 0 failed, 0 skipped
  • zig build test --test-timeout 10m at a57d9c23d406: 15560 passed, 1 failed, 138 skipped
  • python3 -m unittest discover -s tools/zig -p host_tests_test.py -v at a57d9c23d406: 0 passed, 0 failed, 13 skipped

#4144 and #4153 together: the combined tree, checked on a GB10

I merged both branches over current main, resolving them the way @AIFlowML described in #4144 (comment). I then ran the host tests and one GB10 job on the result.

  • Base (ashhart main): 210e3b0c59e1d2910492fc6e0277a0f887f0591e
  • Upstream PR: Drama 3 on CUDA loads a compact NVFP4 checkpoint as stored #4144 head: a57d9c23d40693cd5f10a1fabb1b2d27e52d7661, merged first: 62273c2ed28606689b4323f585e08a71e380391b
  • Upstream PR: Drama 3 semantic guidance (CFG) on CUDA #4153 head: b60aef3e03f466b62d93576f9632016e8ba8d35d, merged over it, giving the combined tree: 972dbd4f310c60883bc9f6628125a0809c912cda
  • GPU job commit: c4ac3fe4f85cf234486cc78bbae88ec6c7fa2a64, which is the combined tree plus the job script docs/recipes/drama3-cuda/combined-gb10.sh and nothing else. It is on plotarmordev/TensorFold branch trial/4144-4153-combined and is not for merge.

The resolution

Four files conflict, as Igor found: registry_media.zig, drama3/cuda/kernels.zig, tests/cuda/contract_drama3.zig and tests/cuda/contract_tests.zig.

The resolution on its own is resolution.patch. I checked it on #4153's branch, both with #4144's merge and with #4144 squashed onto main. In each case I ran git merge main (four conflicts), applied it with git apply resolution.patch, and got a tree identical to 972dbd4f.

Host tests on the combined tree (macOS arm64, Zig 0.17.0)

  • zig build test-drama-host check-drama-cuda-host test-drama-metal-quant-host test-drama-nvfp4-reference-host test-drama-prefill-host --summary all: 19/19 steps, 63/63 tests passed.
  • python3 -m unittest -v tools/zig/drama3_limits_gate_test.py: 8 passed.
  • python3 tools/zig/test_drama_guidance_check.py: 7 passed.
  • zig build compile-cuda-tests -Dtarget=x86_64-linux --summary all: 10/10 steps succeeded.

GB10 (TOP's Spark, sm_121, nvcc 13.0): job top-aaf334ae7ce0, exit 1

  • Kernel contract, tf-cuda-test kernel-contract 'compact router' 'd3_cfg_mix':
    • Gates pass:
      • d3_router_compact passes nonfinite, repeat and shapes (6 shapes exact).
      • d3_cfg_mix passes nonfinite (3 non-finite and 4094 finite outputs match the float64 classes), repeat and shapes (5 shapes, worst 0.433 of the bound).
    • The planted controls are red as planted:
      • Router: CONTROL cuda drama3 compact router control: d3_router, unmasked: red at shapes, as planted.
      • CFG mix: its non-finite fill (NaN, +Inf, -Inf) is classified correctly.
    • It still exits 1, on the limits check for d3_cfg_mix's pending record: FAIL limits live drama3 d3_cfg_mix: 256 threads launched, the driver allows 1024; 12 registers, 0 + 0 shared bytes (recorded 0, 0). The summary reads (filtered) SUMMARY 2 kernels: 2 pass gates 1-4, 0 fail, 0 known findings; 1 controls: 1 red as planted, 0 missed; 1 limit problems. This is the pending record waiting for its first nvcc receipt. The record to add is 12 registers, 0 static shared bytes, 256 threads.
  • Compact NVFP4 load (Upstream PR: Drama 3 on CUDA loads a compact NVFP4 checkpoint as stored #4144's check): failed before any weight was mapped, with error: FileNotFound from drama3-generate --model /assets/drama3-pilot/models/drama-3-NVFP4-Pruned. It never reached the routed experts held line. The published checkpoint ships tokenizer.json, so the copy in the pilot folder is missing or incomplete. This is not the merge. The FP8 checkpoint loaded on the same tree: routed experts held 10240 of 10240; routed experts NVFP4 in 0 of 40 layers; compact routers in 0 of 40 layers, RESULT drama3 OK frames=116 … rtf=1.42.
  • CFG guidance (Upstream PR: Drama 3 semantic guidance (CFG) on CUDA #4153's check), tools/zig/drama_guidance_check.py on the FP8 checkpoint with a synthetic reference voice: "pass": true, "problems": [].
    • It ran at 1 and 64 prefill rows. At each, the plain run gave 3 replies and the separate and paired runs gave 11 each. That held for gamma 1 against plain, gamma above 1 against gamma 1, and paired against separate.
    • Each guided run resumed its cached reference 10 times.

d3_cfg_mix's limits record, rerun on the GB10

#4153 now records what that job measured for d3_cfg_mix in cuda_pending: 12 registers, 0 static shared bytes, 256 threads (sm_121, nvcc 13.0). That is commit f2c1c032fd9fb810d7ae4a782059276228789bd9, and nothing else in the kernel or its gates changed.

  • Upstream PR: Drama 3 semantic guidance (CFG) on CUDA #4153 alone, job top-6e269b37764c at f2c1c032, exit 0: tf-cuda-test kernel-contract 'd3_cfg_mix' passes nonfinite, repeat and shapes as before, and the limits check now reads PASS limits live drama3 d3_cfg_mix: 256 threads launched, the driver allows 1024; 12 registers, 0 + 0 shared bytes (recorded 12, 0). Summary: (filtered) SUMMARY 1 kernels: 1 pass gates 1-4, 0 fail, 0 known findings; 0 controls: 0 red as planted, 0 missed; 0 limit problems; gates 39 ms, limits 0 ms.
  • Combined tree, job top-7e8a48a1639d at 16272c0d5e8f05138de450db3f239d00ad662a39, exit 0. This is f2c1c032 merged over Upstream PR: Drama 3 on CUDA loads a compact NVFP4 checkpoint as stored #4144 (62273c2e, from a57d9c23) with resolution.patch, as c578e8e8, plus the job script. It is on trial/4144-4153-combined and is not for merge. kernel-contract 'compact router' 'd3_cfg_mix' passes both kernels' gates, and the unmasked d3_router control is red at shapes, as planted. Summary: (filtered) SUMMARY 2 kernels: 2 pass gates 1-4, 0 fail, 0 known findings; 1 controls: 1 red as planted, 0 missed; 0 limit problems; gates 43 ms, limits 0 ms.

The compact checkpoint, restaged on TOP

plotarmordev/drama-3-NVFP4-Pruned is in TOP's pilot folder at /assets/drama3-pilot/drama-3-NVFP4-Pruned. fetch hf top refuses it: that command copies a Spark's Hugging Face cache to the Mac. So the job checks the Desk's put itself, with sha256sum -c against the published MANIFEST.sha256 (revision f3de2250). All 8 shards, model.safetensors.index.json and tokenizer.json read OK.

  • Combined tree, job top-69fda464a7b5 at 1acbb3b5d1e89ed284232119104826fbd8110256, exit 1. This is 16272c0d plus docs/recipes/drama3-cuda/combined-gb10.sh and nothing else. The 16272c0d merge had kept 87ca3a66's tree, which dropped that script. The script now points --model at the restaged folder, checks the sha256s and requires routed experts held 7369 of 10240. It is on trial/4144-4153-combined and is not for merge.
    • Kernel contract: (filtered) SUMMARY 2 kernels: 2 pass gates 1-4, 0 fail, 0 known findings; 1 controls: 1 red as planted, 0 missed; 0 limit problems; gates 45 ms, limits 0 ms.
    • Compact NVFP4 load (Upstream PR: Drama 3 on CUDA loads a compact NVFP4 checkpoint as stored #4144's check): the checkpoint loads as stored, with routed experts held 7369 of 10240; routed experts NVFP4 in 40 of 40 layers; compact routers in 36 of 40 layers. Generation then fails with error: ReplayMismatch, so there is no RESULT line. --replay 1 resets and regenerates greedily, and families/drama3/replay.zig requires byte-identical output. On the GB10 the compact path gave different bytes on the second pass.
    • CFG guidance (Upstream PR: Drama 3 semantic guidance (CFG) on CUDA #4153's check): "pass": true, "problems": [].
  • Combined tree, job top-127ed43127ff at 922d9020df54307eef3606952eb8e33d0a9af770, exit 1. This is 1acbb3b5 with the job script changed and nothing else.
    • The script now starts in the Desk's copy, before the build. There it checks MANIFEST.sha256 against the published file's own hash (f447d4ba…), then runs sha256sum -c MANIFEST.sha256 under set -e, so any mismatch would have ended the job there. The job went on to build and run, so all 21 lines matched. The door keeps only the log's tail, which drops the printed OK count.
    • The script also splits the plain compact load from its --replay 1 check, so each reports on its own.
    • Kernel contract: (filtered) SUMMARY 2 kernels: 2 pass gates 1-4, 0 fail, 0 known findings; 1 controls: 1 red as planted, 0 missed; 0 limit problems; gates 45 ms, limits 0 ms.
    • Compact NVFP4 load (Upstream PR: Drama 3 on CUDA loads a compact NVFP4 checkpoint as stored #4144's check): routed experts held 7369 of 10240; routed experts NVFP4 in 40 of 40 layers; compact routers in 36 of 40 layers, then RESULT drama3 OK frames=76 eos=true audio_s=3.53 prompt_rows=31 ref_frames=0 encode_ms=0.0 prefill_ms=849.4 first_audio_ms=965.6 total_ms=3157.0 fps=32.94 rtf=1.53 device_peak_gb=21.72.
    • Compact replay: --replay 1 fails again with error: ReplayMismatch, the same as in top-69fda464a7b5.
    • CFG guidance (Upstream PR: Drama 3 semantic guidance (CFG) on CUDA #4153's check): "pass": true, "problems": [].

Still open: #4144's compact path loads and generates on the GB10, but it does not replay byte-identically (ReplayMismatch at --replay 1, twice). That replay is a gate in #4144's own tools/zig/drama3_compact_gb10.sh. #4144 reports that script passing at edbfbff7, before it merged main into a57d9c23. The next GPU run should be that script at a57d9c23 alone, to tell #4144's main merge from #4153's.

#4144's whole GB10 check on the combined tree, with codec-chunk PCM reported instead of gated

#4144 at 8aabdc780197cf5544d9911d931d68e2f0480f9f (one-line comment fix over 2519ef8fc5b7ac69544a102e77349a439b691bed) keeps every exact check in tools/zig/drama3_compact_gb10.sh exact: FP8 codes against the pre-feature tree, and the replay's frames, graph replay, poison/reset and PCM chunk 1 against chunk 1. The only stop it accepts is the chunk-4 PCM byte compare in replay.zig (main's own cuBLAS-shape-dependent CUDA codec; proven on plain main e3fb56cb in job top-171f7969b5e0). It then decodes the compact run at codec chunks 1, 4 and 16, requires byte-identical frames, and reports PCM at chunks 4 and 16 against chunk 1 as max abs and RMS in 16-bit steps, for information only.

  • Combined tree: a0c1f48a9427da04a7f2dd7cc9e32956722b1260, which is Upstream PR: Drama 3 semantic guidance (CFG) on CUDA #4153 f2c1c032 with Upstream PR: Drama 3 on CUDA loads a compact NVFP4 checkpoint as stored #4144 8aabdc780 merged in using resolution.patch's resolution. Its four resolved files are byte-identical to c578e8e8's. The pre-feature tree is main 37fa51d2 merged with f2c1c032 (tree c5d6fe9064bb7050a8f85432c7b6e799e4335d98), rebuilt in the job from combined-base.patch as commit d7b15e1711f2880119a7a8bc5856b3ea8106c769.
  • Earlier job top-b46176ce1b50 at c3ced5af251e1754fce7ab044b24445e97f6746c exited 0, but nvcc warnings from the subsequent guidance build pushed RECEIPT.txt out of the door's 200-line log tail. Printing RECEIPT.txt last in combined-gb10.sh resolved that.
  • Job top-f47e9ab508b0 at d273d1517ada405364743f6a0bd3df0c8915e3b0 also exited 0, but its manifest check ran sha256sum -c MANIFEST.sha256 inside an echo substitution, so a shard mismatch would not have stopped it. combined-gb10.sh now runs that check as its own command under set -e (checked locally: a tampered file stops the script with exit 1).
  • Clean combined GB10 job top-41f63db6cf5a at c523dd1deb830aabd2f867344a40c6507d487b73 on plotarmordev/TensorFold branch trial/4144-4153-combined (not for merge; d273d1517 plus that script change), exit 0:
head c523dd1deb830aabd2f867344a40c6507d487b73 pre-feature fb163f535621b56372eabb35532a051db0bb648c
NVIDIA GB10, 580.173.02
Build cuda_13.0.r13.0/compiler.36424714_0
input /assets/drama3-pilot/checkpoint: 03a652743d32d316d66a0bc36dd7611fb6e8974973fcb4daafb66478f631ec7b
input /assets/drama3-pilot/drama-3-NVFP4-Pruned: abd1d1c0d26bd0316d1621bfb0849afd3e89c5e7ae81fe0feca8cccf6479e737
input /assets/drama3-pilot/checkpoint/codec.pth: 74fc41c5a7151c6f350af8bd7e5d6e3accfcc7f3dfbfac23afd35af07052bb2f
PASS fp8 greedy codes byte-identical to fb163f535621b56372eabb35532a051db0bb648c: cd050efdecb401b3d79ac82cd177ce9c90c10126e24e6bb9445f83b8a5499102
PASS compact routed experts held 7369 of 10240; routed experts NVFP4 in 40 of 40 layers; compact routers in 36 of 40 layers
PASS compact replay exact through PCM chunk 1 vs 1, then: error: ReplayMismatch
PASS compact batched prefill (64 rows) replay exact through PCM chunk 1 vs 1, then: error: ReplayMismatch
PASS compact decode at codec chunk 1, frames byte-identical at chunks 4 and 16: RESULT drama3 OK frames=76 eos=true audio_s=3.53 prompt_rows=31 ref_frames=0 encode_ms=0.0 prefill_ms=848.5 first_audio_ms=883.2 total_ms=3163.5 fps=32.83 rtf=1.52 device_peak_gb=21.72
INFO compact PCM at codec chunk 4 against 1, 16-bit steps: max abs 1, RMS 0.0464 over 155648 samples
INFO compact PCM at codec chunk 16 against 1, 16-bit steps: max abs 1, RMS 0.0518 over 155648 samples
INFO compact codes at 1 and 64 prompt rows differ
(filtered) SUMMARY 1 kernels: 1 pass gates 1-4, 0 fail, 0 known findings; 1 controls: 1 red as planted, 0 missed; 0 limit problems; gates 44 ms, limits 0 ms
RECORD drama3 d3_router_compact: .usage = .{ .{ .regs = 19, .static = 592, .bound = 0 }, .{ .regs = 19, .static = 592, .bound = 0 }, .{ .regs = 19, .static = 592, .bound = 0 }, .{ .regs = 26, .static = 592, .bound = 0 }, .{ .regs = 26, .static = 592, .bound = 0 }, }
  • Mac host tests at 8aabdc780 (macOS 27 arm64, Zig 0.17.0):
    • python3 -m unittest -v tools/zig/drama3_limits_gate_test.py: 8 passed, 0 failed.
    • zig build test-drama-host check-drama-cuda-host test-drama-metal-quant-host test-drama-nvfp4-reference-host test-drama-prefill-host test-golden --summary all: 24/24 steps succeeded, 54/54 tests passed; server goldens 69/69 and 324/337 (0 unexpected differences).
    • zig build test test-golden: not green, exit 1: 925/931 steps succeeded (4 failed), 1763/1793 tests passed, 27 skipped, 3 failed. The same four steps fail at base 70e78d03, and Upstream PR: Drama 3 on CUDA loads a compact NVFP4 checkpoint as stored #4144 changes no Zig file:
      • vision.test.the release's vision_config parses to the defaults and the same test under families.deepseek_v41.metal.vision: the test expects UnsupportedVision for a head count of 0, check() returns ZeroHeads. Upstream main still has it; the fork's main fixes the test in f5423d498, outside this PR.
      • stage net: an unknown host is refused: this Mac's resolver answers no-such-host.invalid with 198.18.5.202 (a proxy's fake-IP range), so listen reaches bind and returns AddressInUse.
      • The macOS tensorfold-native check that memcpy comes from libSystem.

Review fix: a replay stop at chunk 4 or 16, in a tested gate

#4144 at 2c09de9ddd6df2e6583f0bbebee9e659d6370e42 moves the replay stop check into tools/zig/drama3_replay_gate.sh. It passes only when the log ends in error: ReplayMismatch and the codec lines read 1 1 4 (the chunk 4 PCM compare failed) or 1 1 4 16 (chunk 4 matched, chunk 16 failed). A stop at the frames (1), at PCM chunk 1 against 1 (1 1), at the fork lane's chunk 1 PCM (1 1 4 16 1) or on any other error still fails. A fork-lane frame mismatch after chunk 16 prints the same log as a chunk 16 PCM one, because replay.zig prints nothing between them, so the gate cannot tell those two apart. Each PCM measurement now runs as its own command under set -e, so a missing or short PCM stops the run instead of leaving an empty INFO line.

  • python3 -m unittest -v tools/zig/drama3_replay_gate_test.py tools/zig/drama3_limits_gate_test.py: 14 passed (6 replay gate, 8 limits gate).
  • Combined tree: 534ba5271b497ebd75c2fbc806e28a8f83097424 merges Upstream PR: Drama 3 on CUDA loads a compact NVFP4 checkpoint as stored #4144 2c09de9dd into c523dd1de. Then 4cc7f9b58603b5921e23b42846621fddea6956c5 regenerates combined-base.patch so that the pre-feature tree also drops the gate and still matches tree c5d6fe9064bb7050a8f85432c7b6e799e4335d98. Both are on plotarmordev/TensorFold branch trial/4144-4153-combined and are not for merge. Job top-2e6793417079 at 534ba5271 stopped at that patch, before any build.
  • Clean combined GB10 job top-e2c133e77bb3 at 4cc7f9b58, exit 0:
head 4cc7f9b58603b5921e23b42846621fddea6956c5 pre-feature 65fd46082320cbf87b21facf2166bf9fbe9db8bf
NVIDIA GB10, 580.173.02
Build cuda_13.0.r13.0/compiler.36424714_0
input /assets/drama3-pilot/checkpoint: 03a652743d32d316d66a0bc36dd7611fb6e8974973fcb4daafb66478f631ec7b
input /assets/drama3-pilot/drama-3-NVFP4-Pruned: abd1d1c0d26bd0316d1621bfb0849afd3e89c5e7ae81fe0feca8cccf6479e737
input /assets/drama3-pilot/checkpoint/codec.pth: 74fc41c5a7151c6f350af8bd7e5d6e3accfcc7f3dfbfac23afd35af07052bb2f
PASS fp8 greedy codes byte-identical to 65fd46082320cbf87b21facf2166bf9fbe9db8bf: cd050efdecb401b3d79ac82cd177ce9c90c10126e24e6bb9445f83b8a5499102
PASS compact routed experts held 7369 of 10240; routed experts NVFP4 in 40 of 40 layers; compact routers in 36 of 40 layers
PASS compact replay exact through PCM chunk 1 vs 1, then: error: ReplayMismatch
PASS compact batched prefill (64 rows) replay exact through PCM chunk 1 vs 1, then: error: ReplayMismatch
PASS compact decode at codec chunk 1, frames byte-identical at chunks 4 and 16: RESULT drama3 OK frames=76 eos=true audio_s=3.53 prompt_rows=31 ref_frames=0 encode_ms=0.0 prefill_ms=848.2 first_audio_ms=883.4 total_ms=3177.4 fps=32.63 rtf=1.52 device_peak_gb=21.72
INFO compact PCM at codec chunk 4 against 1, 16-bit steps: max abs 1, RMS 0.0464 over 155648 samples
INFO compact PCM at codec chunk 16 against 1, 16-bit steps: max abs 1, RMS 0.0518 over 155648 samples
INFO compact codes at 1 and 64 prompt rows differ
(filtered) SUMMARY 1 kernels: 1 pass gates 1-4, 0 fail, 0 known findings; 1 controls: 1 red as planted, 0 missed; 0 limit problems; gates 44 ms, limits 0 ms
RECORD drama3 d3_router_compact: .usage = .{ .{ .regs = 19, .static = 592, .bound = 0 }, .{ .regs = 19, .static = 592, .bound = 0 }, .{ .regs = 19, .static = 592, .bound = 0 }, .{ .regs = 26, .static = 592, .bound = 0 }, .{ .regs = 26, .static = 592, .bound = 0 }, }
  • Mac at Upstream PR: Drama 3 on CUDA loads a compact NVFP4 checkpoint as stored #4144's new head (macOS 27 arm64, Zig 0.17.0): zig build test test-golden exits 1. 925/931 steps succeeded (4 failed), and 1763/1793 tests passed, with 27 skipped and 3 failed. These are the same four steps that fail at base 70e78d03:
    • the two vision_config UnsupportedVision against ZeroHeads tests, fixed on the fork's main in f5423d498;
    • the resolver fake-IP for no-such-host.invalid, fixed in afc998ed7;
    • the macOS memcpy libSystem guard, fixed in c3d801235.

@plotarmordev

Copy link
Copy Markdown
Contributor Author

The zig, zig-b and zig-windows failures were zig/qwen35_modelopt_host.zig missing the living module import (cuda_train.zig needs it since the staged-readback change) — fixed on main by f3b4fa5, so I merged main in. All three checks should go green; the modelopt admission host test and the drama host steps pass locally.

@AIFlowML

Copy link
Copy Markdown
Contributor

I trial-merged a57d9c23 cleanly into 767d3d75. On M5 Max with Zig 0.17.0, this passed 54 host tests and the CUDA host compile check:

zig build test-drama-host check-drama-cuda-host test-drama-metal-quant-host \
  test-drama-nvfp4-reference-host test-drama-prefill-host -Dcpu=apple_m1 -j5 --summary all

There is an overlap to account for if #4153 lands alongside it. The combined trial merge conflicts in four files at the kernel name table, launch registry and contract setup. Keeping d3_router_compact and d3_cfg_mix in the same name/enum order, and adding the compact router and unmasked control to #4153's contract owner, resolved those conflicts locally. The combined tree passed 102 host tests, eight limits-gate Python tests and zig build compile-cuda-tests -Dtarget=x86_64-linux. The new CUDA kernels still need a device check on the eventual combined tree.

Igor Lessio - AIFLOW LABS

plotarmordev added a commit to plotarmordev/TensorFold that referenced this pull request Nov 20, 2026
plotarmordev added a commit to plotarmordev/TensorFold that referenced this pull request Nov 21, 2026
…, pre-feature main rebuilt offline (not for merge)
plotarmordev added a commit to plotarmordev/TensorFold that referenced this pull request Nov 21, 2026
…, pre-feature main rebuilt offline (not for merge)
ashhart pushed a commit to plotarmordev/TensorFold that referenced this pull request Nov 21, 2026
The net change of ashhart#4144 at a57d9c2 over its merge base f35bfa4, as one commit: merge a57d9c2 carries its own change to zig/src/core/contract/registry_joins.zig.
@ashhart
ashhart force-pushed the feat/104-upstream-pr-drama-3-on-cuda-loads-a-comp branch from a57d9c2 to 70e78d0 Compare November 21, 2026 05:05
plotarmordev added a commit to plotarmordev/TensorFold that referenced this pull request Nov 21, 2026
plotarmordev added a commit to plotarmordev/TensorFold that referenced this pull request Nov 21, 2026
plotarmordev and others added 2 commits November 21, 2026 08:42
The net change of ashhart#4144 at a57d9c2 over its merge base f35bfa4, as one commit: merge a57d9c2 carries its own change to zig/src/core/contract/registry_joins.zig.
@ashhart
ashhart force-pushed the feat/104-upstream-pr-drama-3-on-cuda-loads-a-comp branch from 70e78d0 to b3e7673 Compare November 21, 2026 08:42
@ashhart
ashhart merged commit 9e40af9 into ashhart:main Nov 21, 2026
11 checks passed
ashhart pushed a commit that referenced this pull request Nov 21, 2026
The net change of #4144 at a57d9c2 over its merge base f35bfa4, as one commit: merge a57d9c2 carries its own change to zig/src/core/contract/registry_joins.zig.
@ashhart

ashhart commented Nov 21, 2026

Copy link
Copy Markdown
Owner

Thank you @plotarmordev. 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.

ashhart added a commit to jayleaton/TensorFold that referenced this pull request Nov 21, 2026
ashhart added a commit that referenced this pull request Nov 21, 2026
plotarmordev added a commit to plotarmordev/TensorFold that referenced this pull request Nov 21, 2026
Conflicts in registry_media.zig, drama3/cuda/kernels.zig, contract_drama3.zig and contract_tests.zig: d3_router_compact then d3_cfg_mix in the name table, the F enum and cuda_pending; ashhart#4144's compact router and its unmasked d3_router control join this PR's Set, which replaces ashhart#4144's Group.
plotarmordev added a commit to plotarmordev/TensorFold that referenced this pull request Nov 21, 2026
plotarmordev added a commit to plotarmordev/TensorFold that referenced this pull request Nov 21, 2026
plotarmordev added a commit to plotarmordev/TensorFold that referenced this pull request Nov 21, 2026
), printing receipt last (not for merge)
@plotarmordev

plotarmordev commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor Author

@AIFlowML Thanks for the combined trial merge and checking the four-file overlap. #4153 carries your resolution (keeping d3_router_compact and d3_cfg_mix in the same order and registering the compact router and its unmasked control inside #4153's drama3 Set) and lands second.

I ran the combined tree on a GB10 (job top-e2c133e77bb3, exit 0, at 4cc7f9b58 on plotarmordev/TensorFold branch trial/4144-4153-combined; full receipt added to the description above):

  • Compact NVFP4 load: routed experts held 7369 of 10240; routed experts NVFP4 in 40 of 40 layers; compact routers in 36 of 40 layers, device_peak_gb=21.72, rtf=1.52; FP8 greedy codes byte-identical to the pre-feature base.
  • Replay & codec chunks: exact through frames, graph replay, poison/reset and PCM chunk 1 vs 1 (single-row and 64-row batched prefill), frames byte-identical at chunks 1/4/16, PCM difference against chunk 1 is 1 LSB max abs (RMS 0.0464 at chunk 4, 0.0518 at chunk 16 over 155,648 samples).
  • Kernel contract & limits: d3_router_compact 1/1 pass gates 1-4, 1/1 planted unmasked control red, 0 limit problems (regs=19/26, static=592, bound=0).
  • Upstream PR: Drama 3 semantic guidance (CFG) on CUDA #4153 CFG guidance check: "pass": true, "problems": [].

plotarmordev added a commit to plotarmordev/TensorFold that referenced this pull request Nov 21, 2026
… checked PCM measurements (not for merge)
plotarmordev added a commit to plotarmordev/TensorFold that referenced this pull request Nov 21, 2026
…he pre-feature tree still matches (not for merge)
plotarmordev added a commit to plotarmordev/TensorFold that referenced this pull request Nov 21, 2026
…correct-the-gb10-claim

Drama 3 CUDA (ashhart#4144): correct the GB10 claim, stop gating on main's codec-chunk byte compare, then a clean combined GB10 run
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