Skip to content

cuda gemma4: admission counts vision and the drafter, init cleanup, DFlash config bounds, contract build fix - #1245

Closed
jschmied wants to merge 4 commits into
ashhart:mainfrom
jschmied:gemma4-cuda-hardening
Closed

jschmied wants to merge 4 commits into
ashhart:mainfrom
jschmied:gemma4-cuda-hardening

Conversation

@jschmied

Copy link
Copy Markdown
Contributor

Follow-ups to the Gemma 4 CUDA stack (#1174, #1181-#1186) from a review pass on main, one commit each:

  • Admission counts vision and the drafter. Plan.bytes covered only the model and the backend. The vision workspace was allocated after fit() had picked the stream count, and the drafter after that, so --parallel auto under a tight budget could end in a CUDA OOM instead of admitting fewer streams.
    • Vision: the tower and embedder workspaces now enter the plan. A host test shows 3 streams admitted where 4 were before.
    • Drafter: Options.drafter lets open() add an estimate of the drafter's weights. The estimate is the safetensors sizes, with DFlash's bf16 linears counted at 4 bits. It is a floor, since scratch and per-stream state are not counted.
    • openDrafter checks the remaining room first and refuses with error.DrafterPastMemory.
  • A failed init frees the buffer lists too (tower, vision, DFlash). The errdefers freed the device buffers but not the lists' storage.
  • The DFlash config is range-checked before it is cast. Negative or oversized counts, and num_key_value_heads: 0, used to trap on @intCast or the modulo. They now return error.BadDraftConfig. New tests in cuda_dflash_test.zig cover them.
  • The contract builds again. tf_ctl_softcap called tf_act_round above the act_round.cuh include, so nvcc failed on contract_controls.cu.

Checks:

  • zig build test green, lean 0 new.
  • Kernel contract on a GB10 (nvcc 13.0): 280/280 kernels pass gates 1-4, and 53/53 controls are red, including both softcap controls.
  • The limit-problem count is unchanged from main (1542 pending records).

@ashhart

ashhart commented Oct 24, 2026

Copy link
Copy Markdown
Owner

Thank you @jschmied for catching this. We landed your contract build fix on its own as 91eab7d, since main's kernel contract did not compile without it; it now compiles with nvcc 13.0 on a GB10. The rest of #1245 (admission counting vision and the drafter, init cleanup, DFlash config bounds) is next, after a GB10 Gemma startup check.

- Synthema, Ash's AI Assistant.

@ashhart

ashhart commented Oct 25, 2026

Copy link
Copy Markdown
Owner

Fully landed. The contract-include fix went in earlier as 08212dd, and the other three records went in now, under your authorship, in 0a13bd4..bcfaea6: admission counts the vision workspace and the drafter, a failed init frees the buffer lists too, and the DFlash config is range-checked before it is cast. Thank you, @jschmied.

On a GB10 with gemma-4-31b-it-4bit @ 696d436c, the landed tree loads at 46.5 GiB with 8 streams at a 32k window. Prefill is 1,043 / 950 / 853 tok/s at 2k / 8k / 16k, and repeats are hash-equal. The sweep runs, and chat qualifies with thinking off and on.

- Synthema, Ash's AI Assistant.

@ashhart ashhart closed this Oct 25, 2026
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