mirror of
https://github.com/Comfy-Org/comfy-kitchen.git
synced 2026-11-04 23:37:42 +00:00
[PR #242] CUDA Sol-Attn: deterministic overflow retry with exact-tail preservation #249
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Comfy-Org/comfy-kitchen#249
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Comfy-Org/comfy-kitchen/pull/242
Author: @xmarre
Created: 10/12/2026
Status: 🔄 Open
Base:
main← Head:fix/sol-token-overflow-deterministic-20261012📝 Commits (1)
b2346b8Make CUDA Sol token overflow admission deterministic without losing tail mass📊 Changes
3 files changed (+90 additions, -11 deletions)
View changed files
📝
comfy_kitchen/backends/cuda/sage_attention/sol_attn.cu(+6 -5)📝
comfy_kitchen/backends/cuda/sage_attention/sol_attn_token.cu(+58 -6)📝
tests/test_sol_attn.py(+26 -0)📄 Description
Summary
Fixes #241: in CUDA Sol-Attn with
token_aug > 0, multiple split CTAs usedatomicAddto reserve more exact tokens than the fixed capacity. The firstn_tokarrivals depended on scheduling, so sorting the surviving IDs did not make membership deterministic. This caused the real MiniMax-H3 A/A′ low-source replay to diverge despite equal histogram/count hashes.Numerical change only (3 files):
sol_attn.cu,sol_attn_token.cu,tests/test_sol_attn.py. No feature flag, attention-backend gate, host sampler change or change to Flow/VDN/Spectrum defaults.Algorithm
tokCnt > n_tok. For each flagged group, reset its count and neutralize earlier split tail states.tokOverflowworkspace slot, exposed bysol_attn_plan. Existing C++/Python wrapper ABI signatures are otherwise unchanged. This affects both direct and chunked Sol-Attn.Reproduction and evidence
The source-of-truth H3
T=36445, H=56, token_aug=256Core trace has 15,960 groups, with 12 groups exceeding the 256-token capacity. Previously (run 01906), A/A′ had matching reservation/histogram hashes but different retained-ID hashes, first native prediction RMS 0.018553374, and low-clean suffix RMS 0.110349394.With this patch in the owner’s installed GPU stack (run 01907), all 12 real overflowing A/A′ groups now have equal retained-ID, histogram and reservation hashes. A/A′ has 103/103 identical observed native/sampler boundary hashes, a bitwise-identical first actual low prediction and bitwise-identical final clean suffix (RMS and max error 0). B's deliberately changed prefix retains a meaningful different trajectory, so the A/B intervention is not accidentally masked. Frozen archive hashes were independently verified. Full H3 evidence.
GPU tests: RTX PRO 6000 Blackwell, PyTorch
2.10.0+cu130, CUDA 13, actual installed_C.abi3.so: 7/7 targeted numerical tests passed, no skips, including repeated saturated top-bin admission, retained surplus/tail fidelity, dense-reference accuracy, direct/chunked parity, and token-budget/no-tail validation. Invocation used--import-mode=importlibfrom outside the checkout, to import the installed native wheel rather than uncompiled source. Test report. Linux/Windows wheel build in fork CI passed; additional combined overlay wheel test in run 38201552241 passed.Dependencies and scope
This PR is independently reviewable. Companion build-system fix #244 addresses source-wheel CMake cache/toolchain reuse; #246 independently addresses a separate native CUDA/PyTorch resource-handle failure on the owner's CUDA13 environment. The owner qualified the full H3 result with all three overlays, so results do not imply this numerical PR alone fixes cross-runtime linkage.
For reviewers: inspect fallback tail reset and one-CTA replay semantics (no double-count/lost mass), overflow-only scope/launch overhead,
tokOverflowworkspace ABI, and compatibility/performance on other SM architectures. SM120 functional replay is validated, but dedicated SM80 numerical performance, compute-sanitizer/racecheck and non-overflow microbenchmarking have not yet been reported. Do not infer final audiovisual seam continuity from deterministic low-source replay.Patch structure: one commit on upstream
mainbe9985bf2977133fb5a48aac4a9df8b6760194c8; no merge/release performed.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.