Skip to content

cuda: DeepSeek release FP8 and BF16 projection kernels (#3527 3/5) - #3532

Draft
laudney wants to merge 5 commits into
ashhart:mainfrom
laudney:dsv41-rel-3-proj-kernels
Draft

laudney wants to merge 5 commits into
ashhart:mainfrom
laudney:dsv41-rel-3-proj-kernels

Conversation

@laudney

@laudney laudney commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Step 3 of #3527: the release's FP8 and BF16 projections on GB10, prompt rows and decode rows bit-equal by construction.

main this PR
FP8 E4M3 x UE8M0 32x32 block projections none block-scaled mxf8f6f4 MMA, one FP32 accumulator a column, K split fixed by (K, N)
BF16 projections (compressor, indexer wk, head) none m16n8k16 BF16 MMA, FP32 accumulation
Activation FP8 round trip (+ fused RMSNorm) none byte-equal to the reference's act_quant
Decode GB/s (large FP8 shapes, cold weights) n/a 239-248 GB/s at 1-16 rows
Prompt TFLOPS (2,048 rows) n/a 113-120 (FP8 Engram wkv / main_proj), 66 (BF16 head)

Why

Serving the checkpoint as DeepSeek released it is crucial for benchmarking and for adoption: SGLang, vLLM and TRT-LLM serve these same bytes, so comparisons are like for like with no conversion step, and users run the checkpoint they already download, with no TensorFold-specific requant (#3527).

What this changes

Adds release_mma.cuh / release_tile.cuh (fragments, scale lanes, the cp.async stage pipeline), release_proj.cu, release_glue.cu, the launches (kernels_release.zig, served split table release_split.zig), a separate sm_121a image set loaded by Kernels.loadRelease only for release checkpoints, the contract files and the release bench.

Checks on this head

  • Head commit: c4d2144
  • Lean checker on the base and on this head: 337 and 337, 0 new.
  • Tests run: zig build test test-golden test-dsv41-cuda-host test-dsv41-forward test-dsv41-device-host test-kernel-contract compile-dsv41-cuda compile-dsv41-server on the stack head: 5296/5334 passed, 37 skipped, 1 failed (cli_config_test "serve --config: expand ...", which fails identically on main e7e2424 on the same host: inherited). zig fmt --check build.zig zig and git diff --check pass at every stack head. Each commit ran the family host suites when it was made (on main 811c384).
  • CI: pending on this head.
  • Not run: the full unfiltered zig build kernel-contract (the release filter dsv41_rel ran; see the kernel section); other SMs (the release images are sm_121a only).

Receipt

  • n/a for serving on its own (kernels without callers until step 5); kernel speed from tf-dsv41-test release-bench in the table.
  • Environment: TensorFold main e7e2424 + this stack, Zig 0.17.0, nvcc 13.5 (V13.5.37; contract records also for 13.0), four GB10 (sm_121a), driver 580.178.04, NCCL 2.30.7; deepseek-ai/DeepSeek-V4.1-Flash-1017 @ 08c8657f02291e11b6f6b63e0e16014f8e748518
Kernel contract, only when a GPU kernel is new or changed
  • Kernels registered: tf_dsv41_rel_fp8 / _mid / _prompt, tf_dsv41_rel_bf16 / _mid / _prompt, the stage-free _fp8_warp / _bf16_warp, tf_dsv41_rel_sum, tf_dsv41_rel_actq, tf_dsv41_rel_rms_actq (new; they replace nothing: release checkpoints were refused).
  • Planted controls: launches into 0xFF-poisoned outputs and partials; a launch missing a row tile must differ (red 5/5); a sum over unwritten partials must differ (red).
  • tf-cuda-test kernel-contract dsv41_rel (nvcc 13.5, GB10): (filtered) SUMMARY 9 kernels: 9 pass gates 1-4, 0 fail, 0 known findings; 0 controls: 0 red as planted, 0 missed; 0 limit problems, exit 0. Extra checks: prompt == decode bytes at M = 1, 5, 16, 17, 100 and offsets 0, 15, 16, 2047 of 2,048 (5 shapes); one row at every position of 16-, 64- and 128-row tiles with 5 neighbour sets (3 x 1,040 launches); one CTA and the warp form equal the served bytes; wo_a group views equal contiguous copies; cancellation [2^25, 0, -2^25, 1] inside the bound at S = 1, 2, 4.
  • Limits: records for nvcc 13.0 and a 13.5 set; kernel-contract-limits audits report no stale release record (their other findings are inherited).
  • Chips not run: every SM but sm_121a (the image set is sm_121a only and refused by name elsewhere).

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.

  • 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. (Drafts and concurrency: equal, receipt above. Resume: not run, sessions are off at 4 slots.)

  • No precision traded for speed. The release arithmetic is the checkpoint's own (DeepSeek-V4.1-Flash release weights (FP8 + MXFP4) on CUDA at world 4 on four GB10s #3527); EXL3 bits are unchanged.

  • Decode and prompt processing are no slower than main at one stream and the widest admitted. (n/a for the release checkpoint: main refuses it. EXL3 paths are untouched by format gating; not re-measured, no EXL3 pack on the test machines.)

@laudney

laudney commented Nov 16, 2026

Copy link
Copy Markdown
Contributor Author

@ashhart updated this stack (#3532 → #3533 → #3534) for the Shared CUDA primitive copies check.

PR Old head New head
#3532 585c469 c4d2144
#3533 11d21d6 85ced53
#3534 993faef 3a5c09b

@ashhart

ashhart commented Nov 16, 2026

Copy link
Copy Markdown
Owner

Thanks @laudney. The shared CUDA primitives are reused correctly, and the release projections have FP64 references, fixed splits and prompt/decode equality checks.

The red zig-b check is in unchanged real-clock bring-up code: that test passes on current main with this series and the later heads are green, so we will rerun it on this head. The new inline comments in zig/build/cuda.zig and zig/build/dsv41_units.zig that pass 120 columns are ours to move, and that commit is ready. We will also repeat the projection contracts and shape timings on a GB10, along with the full CUDA contract summary at compiler-matched limits, since the filtered release run covers only part of that gate.

  • Synthena

@laudney
laudney force-pushed the dsv41-rel-3-proj-kernels branch from c4d2144 to 200e86a Compare November 17, 2026 07:51
@laudney

laudney commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

@ashhart rebased onto main 699094f705 (#3388 landed), head 200e86a5af (was c4d214406b). No content change: git range-diff shows every commit equal. The split-rows plan commit is now dropped from the top of the stack (#3534), which takes the fix from main; checks and the 4 × GB10 receipt are in #3534.

@ashhart

ashhart commented Nov 20, 2026

Copy link
Copy Markdown
Owner

Thanks @laudney for the shared-primitive refactor and patch-identical rebase. The common MMA/cp.async/ldmatrix reuse, FP64 references, fixed (K, N) splits and explicit image gating resolve the earlier implementation asks. The filtered nine-kernel GB10 receipt remains useful contributor evidence.

One coverage issue remains in contract_release_checks.zig:14-21: the comment claims FP8 S=8/S=2/S=1, but the cases exercise S=4/S=1/S=1. release_split.zig:22-37 serves FP8 S=8 for wkv and shared w1/w3. The ordinary FP64 gates cover staged S=8, but the prompt-versus-decode and served/one-CTA/warp byte-equality matrix does not. Please add a served FP8 wkv case and correct the case-table comment. Also remove the measured “a fifth” bandwidth claim from the source comment at release_tile.cuh:92.

The cumulative diff conflicts in zig/build/cuda.zig, zig/src/core/contract/registry.zig, and zig/tests/cuda/contract_family_sets.zig. Current main moved the later compiler sets to zig/src/core/contract/registry_cuda_sets.zig, so carry the nvcc-13.5 entry there while preserving current main's other registrations.

After that revision and rebase, we still owe the GB10 sm_121a repetition: the filtered release contract with the new case, the full unfiltered zig build kernel-contract summary and limit results, and tf-dsv41-test release-bench across the served shapes and rows.

  • Synthena

@laudney

laudney commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

@ashhart updated: head 9033c95e3c (was 200e86a5af), rebased onto main a0f809ea09 with the lower steps.

Ask Change Proof
A served FP8 wkv case (S = 8) in the prompt-versus-decode and served/one-CTA/warp matrix 9033c95e3c: an fp8 wkv case (K 5120, N 512, S 8, BF16 out) runs prompt == decode, row independence and the launch shapes PASS dsv41_rel prompt == decode fp8 wkv (K 5120 N 512 S 8); PASS dsv41_rel independence fp8 wkv (1,040 launches byte-identical); PASS dsv41_rel launch shapes fp8 wkv (its missing-row-tile control red)
The case-table comment now "FP8 S = 4 (wq_a), 1 (wo_b, shared w2) and 8 (wkv); BF16 S = 8 and 1", as the cases run contract_release_checks.zig:14
The measured "a fifth" claim at release_tile.cuh:92 removed: the comment says only that stages start 128-byte aligned comment only
Conflicts in cuda.zig, registry.zig, contract_family_sets.zig the nvcc 13.5 entry is in registry_cuda_sets.zig; main's idol, idol decoder, GLM MoE, muse and inkling2 registrations stay beside release git range-diff: the step's other commits have the same added and removed lines

GB10 (sm_121a) repetition at this head, nvcc 13.5 unless named:

Check Result
tf-cuda-test kernel-contract dsv41_rel (filtered) SUMMARY 9 kernels: 9 pass gates 1-4, 0 fail, 0 known findings; 0 controls: 0 red as planted, 0 missed; 0 limit problems
Full zig build kernel-contract, this head vs main a0f809ea09 (same GB10 model) this head SUMMARY 841 kernels: 839 pass gates 1-4, 2 fail, 12 known findings; 521 controls: 521 red as planted, 0 missed; 1039 limit problems; main SUMMARY 832 kernels: 830 pass gates 1-4, 2 fail, 12 known findings; 521 controls: 521 red as planted, 0 missed; 1039 limit problems. The 9 more kernels are the release ones. The failure, known-finding and limit lines are main's: the only differences are the registered-launch count (1762 against 1751, the same 242 problems) and the first differing byte of the planted atomic-add control (red in both). No line names a dsv41_rel kernel
kernel-contract-limits (sm_121 fatbins), nvcc 13.0 and 13.5 4290 and 5037 problems, line-equal to main's (diff of the problem lines empty); the 20 release records are current under both (PASS limits sm_121 dsv41_rel ...). The other problems are missing sm_80/86/89/120 images in this sm_121-only build and main's own records
tf-dsv41-test release-bench 20 at the stack head 541354be0b (these kernels unchanged there), the served shapes at 1-2048 rows 86 cells; median time ratio to the earlier run 1.00 (each cell 0.85-1.40, the spread of cold weights). One row:
Shape K N S us GB/s
wq_a 5120 1280 4 37.9 173.2
wkv 5120 512 8 19.7 133.6
wq_b 1280 8192 1 56.7 185.3
ix_wq_b 1280 4096 1 35.4 148.5
wo_a group 4096 1024 4 25.8 163.0
wo_b 2048 5120 1 53.3 197.0
shared w1/w3 5120 576 8 24.3 122.0
shared w2 576 5120 1 20.6 143.5
engram wkv 6144 25600 1 704.5 223.6
main_proj 15360 5120 1 354.6 222.1
head 5120 32384 1 1464.3 226.6
compressor r2 5120 512 8 32.0 164.2
ix_wk 512 128 1 10.5 12.6

Host checks on the stack head: zig build test 13153/13240 (87 skipped, 0 failed), test-kernel-contract 315/315, the DeepSeek host suites pass; lean 165 = main, 0 new.

The CUDA plan typed every projection as an EXL3 group, so another
weight format would have to thread branches through every reader.
GroupPlan and ExpertsPlan now hold their stored form in a tagged union
with an EXL3 arm, readers go through it, and the expert width splits
on a per-format block (expertShare: 128 for EXL3, 64 for the release
format). EXL3 plans, emitted calls and pinned fingerprints are
unchanged; block.Options gains the checkpoint format for the release
arms to come.
The CUDA reader opens engram-l<L>-r<R>of<W>.bin, but the packer wrote
only rank 0 of 1, so a four-rank release had no tables to read from
SSD. A rank's rows are now its whole hash columns (rankRows, the
reader's headShard), the packer, verifier and manifest work on that
span with shard-relative offsets, the tool takes --rank and --world,
and checkShards validates a rank's shards against its span at boot.
DeepSeek's own checkpoint stores FP8 32x32 blocks, MXFP4 experts and
BF16 matrices that the CUDA plan could not express. The plan gains
FP8, BF16 and MXFP4 forms with the rank's rows, columns and expert
ids, cut on the mesh (release_shard over fabric/mesh), the Engram
tables are checked and left on disk, and staging uploads the stored
bytes unchanged. The real release plans at worlds 1, 2 and 4 with no
tensor left over: 72.31 GiB a rank at world 4. Serving still refuses
the format until its kernels land.
The release checkpoint's dense projections need GB10 kernels that
multiply its FP8 block-scaled and BF16 weights as stored, with prompt
and decode rows bit-equal; this adds block-scaled mxf8f6f4 and BF16
MMA tiles (decode, mid, prompt and a stage-free warp form) over one
per-element K order and a row-independent split, the FP8 activation
round trip with and without RMSNorm, the fixed split sum, a separate
sm_121a image set loaded only for release checkpoints, contract
checks (prompt equals decode, every tile position, one-CTA grids,
group views, cancellation) and records for nvcc 13.0 and 13.5.
The release contract's prompt-versus-decode, row-independence and
launch-shape checks ran FP8 only at splits 4 and 1, while the world-4
plan serves wkv and the shared w1/w3 at split 8. A wkv case (K 5120,
N 512, BF16 out) now runs every check at split 8, the case table's
comment names the splits it covers, and the tile comment no longer
quotes a bandwidth measurement.
@laudney
laudney force-pushed the dsv41-rel-3-proj-kernels branch from 9033c95 to e325f31 Compare November 24, 2026 22:19
@laudney

laudney commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

@ashhart main moved again, so the stack is rebased once more onto a15c7b0603: head e325f31bfa (was 9033c95e3c). It also merges cleanly with today's 95591a94f8.

Item Change
registry_joins.zig main's h3_image_cuda_records import kept beside dsv41_release_records
contract_finish.zig main's -WORD filter (a0f7530cf4) kept; the release checks now use its contract_after.wanted("dsv41_rel", only), so a full run with -words still runs them, -dsv41_rel drops them, and a filter naming other kernels skips them
Other commits the same added and removed lines (git range-diff)

At this head on a GB10: kernel-contract dsv41_rel 22 kernels pass gates 1-4, 0 limit problems, the release checks (with the fp8 wkv S 8 case) pass; kernel-contract dsv41_rel -dsv41_rel_ex runs the 9 projection kernels and still runs those checks. Host: zig build test 13006/13091 (85 skipped, 0 failed), test-kernel-contract 310/310, the DeepSeek host suites pass, lean 0 new. The earlier pytest failure (tools/tests/test_bench_prose.py, a timing check) is outside this stack's files; this push reruns it.

This branch has not been deployed

No deployments
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.

2 participants