Repository navigation
kolibri1: tree-attention cache offsets are signed, so a cache placed below the origin no longer overflows - #3561
Merged
Conversation
…low the origin no longer overflows On main a copy-drafts-only server (ReleaseSafe) panics at its first one-row step graph: offsets computed m.k[i] + at - m.origin in u64, and attach's sliding rings can be allocated below origin. The kernel reads the offsets as long long, so a negative one is valid.
ashhart
force-pushed
the
kolibri1-offsets-signed
branch
from
November 17, 2026 03:02
9a8fd9b to
3e1ace6
Compare
Owner
|
Thank you @jschmied. This is merged into main with your commits under your own name, so you're listed as a TensorFold contributor. It ships in the next release, credited to you in the changelog and the release notes. |
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.
On main (
9b2f2ca12d), a Kolibri-1 server with default flags (paged full-layer caches, copy drafts, prompt cache) panics on its first request in a ReleaseSafe build:offsetscomputes each layer's cache offset from the tree origin as(m.k[i] + at - m.origin) / 2in u64. With paged caches,attachfrees and reallocates the sliding layers' rings afterModel.initallocatedorigin, so a ring can land beloworigin, and the subtraction goes negative. Whether it does depends on where the allocator puts the rings: with linear caches (TENSORFOLD_KOLIBRI_KV_PAGES=0) main serves fine. A ReleaseFast build has no check. There the u64 wraps, and the kernel probably gets a wrong offset for those layers. I have not checked what a ReleaseFast build serves in that case.Change: a helper,
elementsFrom(origin, at), takes the difference as a wrapping u64 subtraction, bit-casts it to i64 and divides by 2 exactly.tree_attention.cu:78already reads the offsets aslong long, so a negative offset is valid there. No kernel changes and no.cufile touched. Served behaviour is unchanged wherever main didn't overflow.Evidence on
9a8fd9b936(GB10, sm_121):forward_offsets_test.zig, run byzig build test-kolibri-host): offsets above, below and equal to the origin.test-kolibri-hostgives 26 passed, 1 skipped.elementsFromreverted to main's unsigned arithmetic, the same test crashes:panic: integer overflowatforward_offsets_test.zig:6, the below-origin case. That gives 25 passed and 1 crashed; with the fix, 26 passed.9a8fd9b936(served binary md5eae8441c) serves all 24 prompts copy-only with no empty reply. 4 and 8 concurrent streams give the same replies as solo. The control, main9b2f2ca12dbuilt the same way (md5ff46eda4), panics on the first rounds with the overflow above.TENSORFOLD_KOLIBRI_KV_PAGES=0,b3e6e511ac84e921.forward.zigis 600 lines.Found while bringing the Kolibri-1 drafters to main (#3491). That PR builds on this one.
Proposed CHANGELOG line (Fixed):
Kolibri-1 on CUDA no longer panics on its first request when paged caches place a sliding layer's ring below the tree origin.