Repository navigation
cuda: sparse attention contract adds the focused case from #5166 (one head a key head, negative count, duplicate across a tile edge, unnamed entries in a nonfinite replay) - #5242
Merged
Conversation
…head, a negative count, a duplicate across a tile edge, unnamed entries in a nonfinite replay
ashhart
force-pushed
the
sparse-attn-focused-contract
branch
from
November 26, 2026 23:13
de04fcb to
ecd5da8
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. |
ashhart
added a commit
to gilby/TensorFold
that referenced
this pull request
Nov 26, 2026
ashhart
added a commit
that referenced
this pull request
Nov 26, 2026
ashhart
added a commit
to jschmied/TensorFold
that referenced
this pull request
Nov 26, 2026
ashhart
added a commit
that referenced
this pull request
Nov 26, 2026
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.
Follow-up to #5166 (review comment 7187194600).
Head:
de04fcb555, on mainc21d201714. Test only: no kernel or wrapper change.What changes
zig/tests/cuda/contract_sparse_attn.ziggains a third sparse attention case next to the 48-heads-over-4 case and itsplanted control. It runs with the block attention cells as before. The case:
G == 1;keysat slots 2 and 3. The nonfinite fill makes that head's valuesinfinite, so the kernel replays it. The decoys are real memory holding +inf at value element 11, so a replay that
reads an unnamed entry gives +inf where float64 gives a finite value.
Shape: 3 rows, 4 heads, 70 listed keys (three 32-key tiles). The 48-head case and its served shapes are unchanged.
Evidence
Kernel contract on
de04fcb555(tf-cuda-test kernel-contract 'sparse attention' 'block attention', GB10, nvcc 13.0), exit code 0:Planted break, red as intended: the same contract with the replay's key filter dropping its named-entry check
(
seeninsparse_attention.cuwithoutnamed(key)) fails only the new case; the 48-head case passes with the break:A planted break in the negative-count clamp cannot be caught by any input: with n < 0 the tile count is 0 or 1 and no key
passes
k < n, so the output equals a count of 0 either way. The case still pins that a negative count gives NaN.Full CI set (x86 lane) on
de04fcb555: ci, cuda-host, pr-check, fmt, diff-check and lean all rc 0. Lean check: 0 new.Seeded, resume, concurrency: not applicable, a contract test with fixed inputs and no server. Against main: on
c21d201714; main has moved 19 commits since, none touchingcontract_sparse_attn.zigorsparse_attention.cu, and thebranch merges cleanly.
Proposed CHANGELOG line:
cuda: sparse attention contract adds a focused case (one head a key head, a negative count, a duplicate across a tile edge, unnamed entries in a nonfinite replay).