Skip to content

cuda: skip unused sample probability outputs for GLM and MiniMax - #4665

Draft
tacosta wants to merge 3 commits into
ashhart:mainfrom
tacosta:feat/3711-unused-prob-output
Draft

tacosta wants to merge 3 commits into
ashhart:mainfrom
tacosta:feat/3711-unused-prob-output

Conversation

@tacosta

@tacosta tacosta commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

What this changes

GLM and MiniMax M3 CUDA samplers do not consume tf_draw's optional probability output. They now pass a null device pointer and drop the unused allocation and cleanup. Full-vocabulary sampling can skip the post-selection probability-mass reduction; candidate sampling keeps the normalization needed to select a token. The CUDA sample suite checks that the optional output does not change selected token IDs.

  • Issue: Fixes GLM/MiniMax CUDA: unused probability outputs force an extra full-vocabulary reduction #3711.
  • Rebased onto main snapshot b6ab6dbfd7c6f7cde6e524433ee67dc7fc664c31 (the head at rebase time); main has since advanced to 777f3bb7624007a2e13ea1632d917582aa78592e. The three commits are 8e1a646cf, 34e33fd81 and 7628c54e7. The worktree is clean.
  • Rebase conflict: rebasing onto b6ab6db had one content conflict in docs/optimization-ledger.md. I kept upstream’s new snloop column and row 39, then added the sampler optimization as row 40 in all five tables. The rebase completed cleanly after that resolution. GitHub currently reports the PR mergeable; its PR API base SHA is b6ab6db, while the live main ref has advanced to 777f3bb. The current atc overlap --json scan is incomplete (otherPullRequestsLimit, pullFilesUnavailable, pullRequestsLimit, timeLimit): it reports a one-file conflict with PR flashnext cuda: the opt-in --tp 2 decode graph takes the dense split and keeps its graph across drafted verifies #2982 and conflict overlaps in worktrees 3, 4, 8 and 11. It scanned 16 worktrees, but file paths are unavailable. atc who for all seven changed files also reports pullFilesUnavailable; additional PR overlaps may be missing from the scan.

Checks on this head

  • Rebased source head: 7628c54e7e42a22c507e09171b9a5411efb5b91c, based on main snapshot b6ab6dbfd7c6f7cde6e524433ee67dc7fc664c31; current main is 777f3bb7624007a2e13ea1632d917582aa78592e. The seven-file review patch SHA-256 is eaecee3b132fcf0b294de9e352ec715e568c3960b244b0f1119aa248cd33f27a (18,021 bytes; LocalATC artifact art_3711-unused-prob-output_job_20261125_090226_581dd8_f7819b).
  • Red/green evidence from the first rebase (LocalATC job job_20261124_194548_10e199, base 7ea9ec2): both pre-change wrappers failed at the intended !@hasField(Sampler, "prob") assertion; patched targets passed 13/13 tests (GLM 11/11, MiniMax 2/2). On current head 7628c54 / base b6ab6db, the focused GLM/MiniMax host targets passed 13/13 tests again, with zig fmt --check and git diff --check passing in LocalATC job job_20261125_090226_581dd8 (2 CPUs, 4 GiB RAM, no GPU). Host memory increased 0.21 GiB, below the 1.53 GiB threshold. Promoted artifacts: patch _f7819b, script _2cc615, log _fdc724 under that job ID.
  • Full-suite status: on current base b6ab6db, focused host targets and static checks passed. The full build and GPU sample were not rerun because the worktree filesystem is 100% full (3.5 GiB free at the latest check). A previous full build on an earlier main snapshot stopped at NoSpaceLeft.
  • Previous complete qualification, before main advanced, was on base 2686dde41a3415ae7e09b15888c32c0881064c66 and head 0c1e33b898151e38195b1c31c7b60e8323aee40f (same source patch): zig fmt --check, git diff --check, and lean comparison passed (165 vs 165, 0 new); zig build -j4 -Dnvcc=/usr/local/cuda/bin/nvcc -Dsm=120 install test test-golden test-cuda-host exited 0; goldens were 69/69 and 324/337 equal with 0 unexpected differences; zig-out/bin/tf-cuda-test sample exited 0 with 2,880/2,880 host-reference matches, all 8 optional-probability configurations matching IDs, and pitched proposal checks 54/54.
  • python3 tools/pr_check.py --base origin/main --pr 4665: run against current main 777f3bb7624007a2e13ea1632d917582aa78592e; merge base b6ab6dbfd7c6f7cde6e524433ee67dc7fc664c31; 0 errors, 1 advisory (no Unreleased bullet naming this PR), 7 changed files, lean results 165 vs 165 with 0 new problems.
  • Previous successful LocalATC evidence is retained under job job_20261122_182950_84f035; qualification log artifact art_3711-unused-prob-output_job_20261122_182950_84f035_bd138d.
  • Hosted CI for previously published heads e8ab859, 858065873 and 99f35107 predates the current rebase; for 99f35107, Zig format and No GPU passed in runs 45481186028 and 45481186074. Fresh CI for head 7628c54 will start after the branch update; no CUDA-specific hosted job was listed.
  • Requested GLM-model exactness evidence remains outstanding: compare drafted output with drafter-off output, resumed-prompt output with a fresh-prompt run, and concurrent output with solo output on a supported served GLM. The available GLM checkpoint revision 98b0362133bda9ee3b1b875636636c07861f5947 is unsupported by the current native CUDA engine, so these model runs have not been completed. The synthetic-logit parity test is expected to pass on base because the kernel's null-pointer contract predates this wrapper optimization; the new host regression separately verifies the wrapper-level change.
  • Requested GB10 performance evidence remains outstanding: compare main and this branch on the same supported GLM checkpoint for prompt and decode performance on GB10, at one stream and the widest admitted, greedy and sampled, with and without --drafter. The available local GPU is an RTX 5090 Laptop GPU, not GB10; no GB10 performance run or speedup claim is included.

Receipt

  • Main against branch: No timing cells; neither available model path could be served by the native CUDA engine, so no speedup is claimed.
  • Boxes it reaches: GLM and MiniMax M3 CUDA sampled decode. Full-vocabulary sampling skips the probability-mass pass after token selection. Candidate sampling still normalizes for selection and avoids the unused probability output.
  • New switch? None; defaults and profiles are unchanged.
  • Environment: Rebase base b6ab6dbfd7c6f7cde6e524433ee67dc7fc664c31; current main 777f3bb7624007a2e13ea1632d917582aa78592e; head 7628c54e7e42a22c507e09171b9a5411efb5b91c; Zig 0.17.0; CUDA Toolkit/NVCC 13.3.73; Linux x86_64. Current-head qualification was host-only and used no GPU. Earlier CUDA synthetic-logit runs used an RTX 5090 Laptop GPU (SM 12.0, 24 GB VRAM; driver 595.99); the available GLM checkpoint unsloth/GLM-4.7-Flash-NVFP4 at revision 98b0362133bda9ee3b1b875636636c07861f5947 is unsupported by the current native CUDA engine. No MiniMax checkpoint was available.
  • Paths and platforms the change reaches, which I ran and which I could not: GLM and MiniMax M3 CUDA sampler wrappers and the CUDA sampling test. Built and ran on Linux x86_64, SM 12.0. Other CUDA SMs, Metal, HIP and Windows were not run.
  • Exactness: The CUDA test compared IDs with a valid probability-output pointer versus null for 8 configurations (top-k 0, 20, 1024 and 1500; top-p 1.0 and 0.95); all IDs matched. The separate 2,880-draw sampler suite had 0 differences from host references. These are synthetic-logit checks, not served-model token identity.
  • Main against this branch, same machine and checkpoint: Not run because the available GLM checkpoint is unsupported and no MiniMax checkpoint is available.
  • Decode speed before and after: Not run for the same checkpoint-availability reason; no decode speedup is claimed.
  • Prompt speed before and after: n/a; the change affects sampled decode only and does not touch prompt processing.
  • Licence of any new weights or drafter: n/a; no weights or drafter are added.

Checklist

  • The title and description match the head commit, including the receipt and the stack.
  • New tests fail before the change and pass after it. Both pre-change wrapper targets fail at the prob-field assertion; the patched targets passed 13/13 tests on current base b6ab6db (GLM 11/11, MiniMax 2/2). They assert the unchanged seven-argument launch ABI, null PROB, and an eight-byte final argument; no model, CUDA driver, runtime or GPU is needed.
  • Comments and docstrings are one line. No measurements or history in the source.
  • No personal data, machine names, internal hosts or local paths are included in the diff or commit; the outgoing commit uses the public noreply identity.
  • Every token still follows the existing sampling selection path; no serial fallback or draft-disable behavior was added.
  • Drafted output equals "draft": false, a resumed prompt equals a fresh one, and concurrent equals solo. Requested on a supported served GLM model; no compatible checkpoint was available. No draft or prompt-cache code changed.
  • No precision was traded for speed; the CUDA kernel and its arithmetic are unchanged, and token IDs match with the optional pointer present or null.
  • Decode and prompt processing are no slower than main at one stream and the widest admitted; with --drafter, no slower than without it, greedy and sampled. Requested on GB10 with the same GLM checkpoint and configurations on main and this branch; no GB10 run is available yet, so this gate is unmeasured.

@tacosta

tacosta commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Hi @ashhart, the published head’s listed CI checks have passed; the host-nightly checks were skipped. The GLM and MiniMax wrapper regression tests pass without CUDA hardware. The requested served-GLM parity and GB10 performance runs remain outstanding and are documented in the PR. Are those runs required before I mark this ready for review, or is the source-level patch ready for review?

@tacosta
tacosta force-pushed the feat/3711-unused-prob-output branch 2 times, most recently from 8580658 to 99f3510 Compare November 24, 2026 20:28
@tacosta

tacosta commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto main at 3942d68 and resolved the optimization-ledger row collision by preserving upstream row 39 and placing the sampler entry at row 40. Main has since advanced to d30325d; GitHub reports the PR mergeable.

@tacosta
tacosta force-pushed the feat/3711-unused-prob-output branch from 99f3510 to 7628c54 Compare November 25, 2026 09:07

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.

GLM/MiniMax CUDA: unused probability outputs force an extra full-vocabulary reduction

1 participant