Skip to main content

Module prime_graph

Module prime_graph 

Source
Expand description

PrimeGraph (task #14, design v3): a per-bucket CUDA graph of the FULL fresh-prime trunk, bound to a dedicated SCRATCH cache; serving replays it (one cuGraphLaunch, ~23ms vs ~26ms eager at bucket 512) and COPIES the outputs into the session’s cache (KV rows + conv rings + recurrent states, ~tens of us D2D — the copy-out beats both table-indirect kernels and graphExec node patching, ledger design v3).

Correctness story (all bit-proven by prime-graph-smoke + the gate):

  • fresh-prime semantics are BAKED as graph-head memset nodes (state/ring/len_d zero);
  • pads past the true length are invisible (gdn_pad_mask identity steps, causal attention, device-indexed last-row gathers) — replay logits are bit-identical to the eager true-length prime;
  • the GRAPH-OUTPUT CONTRACT: only the stable IO buffers and the scratch cache’s resident state survive a launch (in-graph transient addresses recycle).
  • ssm ping-pong: the capture-time core swapped the scratch cache’s host fields; after capture they name exactly the buffer the graph WRITES, and no further swaps happen, so scratch.recur[il].ssm_state is the copy-out source on every replay.

Structs§

PrimeGraph