Repository navigation
kolibri1 cuda: decode rounds of several rows replay CUDA graphs - #4884
Merged
Merged
Conversation
ashhart
force-pushed
the
lead/kolibri-round-graphs
branch
from
November 24, 2026 13:08
4aa1ad2 to
2f51fd4
Compare
A lone row already runs its slot's captured step graph, but a round of two or more rows (several streams, or a verify window) launched every layer eagerly. Such a round now replays a graph from graph_cache, captured at the first round of its shape and keyed by its rows, its streams and tree attention's key groups. forward() splits into stage() and launch(). stage() uploads the round's ids, positions, slots, plan, paths, cache offsets and page table on the stream as before. launch() reads only device memory: a tree plan's offsets depend on its rows and streams alone, and the key groups are part of the key. So a replayed round makes the same launches with the same arguments as the eager round, and every row keeps its bits. attach drops these graphs along with the step graphs. With TENSORFOLD_KOLIBRI_GRAPHS=0 every round stays eager, and TF_GRAPH_CACHE=0 runs the cache's rounds eagerly. The f64 angle-table test moves unchanged to forward_rope_test.zig, which keeps forward.zig under the 600-line cap.
ashhart
force-pushed
the
lead/kolibri-round-graphs
branch
from
November 24, 2026 21:49
2f51fd4 to
520eddf
Compare
ashhart
added a commit
that referenced
this pull request
Nov 25, 2026
…at a CUDA start Kolibri-1 read it with getenv outside the registry (backend.zig's envOff): exact 0 turned the one-row step graphs and, since #4884, the multi-row decode round graphs off, and every other text, blank, 1, "false" or "off" included, kept them on. It is now a .cuda flag row in platform/environment.zig, read once in Kolibri.init through the registry: - unset, blank and 1 keep the graphs (the default, as before); 0 runs both eager (as before); - any other text, which read as on before, is refused by name at a CUDA start, like every registered setting. docs/environment.md documents it in the CUDA table; tokens are the same either way. Tests: environment_kolibri_test.zig (blank and unset keep the default, 0 and 1 accepted, other text refused by name on CUDA and ignored on Metal), and the setting in environment_test.zig's table of every row.
ashhart
added a commit
that referenced
this pull request
Nov 25, 2026
…at a CUDA start Kolibri-1 read it with getenv outside the registry (backend.zig's envOff): exact 0 turned the one-row step graphs and, since #4884, the multi-row decode round graphs off, and every other text, blank, 1, "false" or "off" included, kept them on. It is now a .cuda flag row in platform/environment.zig, read once in Kolibri.init through the registry: - unset, blank and 1 keep the graphs (the default, as before); 0 runs both eager (as before); - any other text, which read as on before, is refused by name at a CUDA start, like every registered setting. docs/environment.md documents it in the CUDA table; tokens are the same either way. Tests: environment_kolibri_test.zig (blank and unset keep the default, 0 and 1 accepted, other text refused by name on CUDA and ignored on Metal), and the setting in environment_test.zig's table of every row.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes
A lone Kolibri-1 row already replays its slot's captured step graph. A round of two or more rows (several streams, or a verify window) launched every layer eagerly. Such a round now replays a graph from
cuda.graph_cache, captured at the first round of its shape. The key is the round's rows, its streams and tree attention's key groups. The cache's usual policy applies: at most 48 graphs, the memory floor, andTF_GRAPH_CACHE=0runs it eagerly.forward.Model.forwardsplits intostageandlaunch:stageuploads ids, positions, slots, the tree plan, paths, cache offsets and the page table on the stream, as before;launch, unchanged, reads only device memory ("a graph can hold them").rounds.zigholds the cache, made at the first round where the backend's address is final. It replayslaunchover every row, which is whatverifyasked the eager forward for.attachdrops these graphs along with the step graphs.TENSORFOLD_KOLIBRI_GRAPHS=0, every round stays eager.Exactness
A replayed round makes the same launches with the same arguments as the eager round of that shape. The rest is device-indirect:
attach.So every row keeps its bits.
Checked
On a Linux x86_64 host with no GPU, using Zig 0.17.0, at this head:
zig fmt --checkandzig ast-checkon every changed Zig file;python3 tools/zig/lean_check.py: 165 problems, the same count as main; the push gate's scanner: safe.zig build test-kolibri-host(the new plan-offset test and the moved angle-table test): passzig build check-native-cuda-host: pass, and a compile probe inrounds.Rounds.forwardconfirmed the step reaches itNot run
No device run: graph capture, replay and the device suite are unrun.
Device cells that decide it
Run each as an A/B of main against this head, with an A/A first and a balanced order, dropping run 1. Give each stream its own prompt.
TENSORFOLD_KOLIBRI_GRAPHS=0; decode tok/sThe device suite
zig/tests/cuda/kolibri_tests.zigshould also pass on the GB10.