mirror of
https://github.com/Comfy-Org/comfy-kitchen.git
synced 2026-11-04 23:37:42 +00:00
[GH-ISSUE #241] CUDA sol_attn token_aug overflow: atomic reservations select nondeterministic retained IDs despite histogram parity #69
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#69
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?
Originally created by @xmarre on GitHub (Oct 12, 2026).
Original GitHub issue: https://github.com/Comfy-Org/comfy-kitchen/issues/241
Summary
CUDA Sol-Attn token augmentation has a reproducible real-model over-budget reservation case on the installed
comfy-kitchen==0.2.37H3 chunked-producer path. Two frozen A/A′ replays have identical reservation-count and score-histogram SHA256 digests at one attention block but different retained token-ID digests. The CUDA implementation sorts the IDs it retained, but its capped list is populated using anatomicAddreservation across independent split CTAs. Sorting cannot make a scheduling-dependent subset deterministic once more thann_tokslots were requested.This issue distinguishes confirmed over-budget counts and retained-list changes from the still-unproven attribution of the full downstream MiniMax-H3 visual artifact to this one mechanism.
Real GPU evidence (2026-10-12)
comfy-kitchen==0.2.37, H3 50-block transformer.sol_attn_chunked,t=36445,h=56,token_aug=256,groups=15960.tokCnt,tokHistand the initialized portion only oftokIdxfrom the installed Core workspace after a verified successful Python wrapper return; it does not replay or monkeypatch Core.complete=true; 12 groups over budget, 282 exactly at budget, max reservations = 2218, max top-bin population = 2283, max histogram-window population = 29908.tokCnthashf166919c...and identical fulltokHisthash4066ac26..., yet the canonical retained-ID hashes differ: A658bd3fd...vs A′9205548f....Owner evidence/protocol: Flow PR #99. This is a Core comfy-kitchen issue; a Flow-side threshold workaround or attention-backend gate is not proposed.
Source-level failure mechanism
In CUDA
sol_attn_token.cu:hist_bin(line ~52). Pass-2's whole-bin threshold walk (lines ~207–223) can exceedn_tokin this case, despite the normal bin-selection budget rule.atomicAdd(&tok_cnt[group], total), populatetok_idxonly whenslot < n_tok, and put surplus scores back into the approximate tail. The list membership depends on which CTA reserves the first 256 slots.sol_token_sort_kernel(lines ~380–402) sorts that selected subset, but does not restore the tokens excluded by scheduling.tokCntandtokHistcan be identical while the selected IDs differ.The existing upstream
test_token_aug_surplus_over_the_budget_stays_in_the_tailalready explicitly documents 1,952 reservations for a 256-token budget and asserts that the surplus remaining in the approximate tail is critical for accuracy. Thus dropping the entire overflowing highest bin to force zero admitted tokens is not a fidelity-preserving solution and can regress this test.Requested fix / acceptance criteria
Please make overflow handling deterministic without sacrificing accurate token-vs-tail accounting:
token_augAPI.sol_attn_chunkedand cold/direct paths, plus ordinary non-overflow performance. Avoid a broad backend fallback or token augmentation disablement.I can prepare a dedicated fork/mirror CUDA correction once the required accuracy and performance invariants are agreed, but this issue records the real hardware evidence and test contract without prematurely changing numerical semantics.
@xmarre commented on GitHub (Oct 12, 2026):
Real-model before/after validation: run 01907 fixes observed nondeterministic admission (2026-10-12)
Owner retested the same MiniMax H3 chunk-2 A/B/A′ witness using corrected comfy-kitchen CUDA numerical PR #242 in the Torch 2.10.0+cu130 Blackwell environment, alongside build #244 and diagnostic matched CUDA13 shared runtime #246. Run 01906 previously had 12 overflow groups in A and A′, equal histogram and reservation hashes but unequal retained-token SHA256 and divergent output at low step 5.
In owner run 01907 the actual Core
sol_attn_chunkedat logical low step 5/block 45 hasT=36445, H=56, token_aug=256, 15960 groups. A and A′ each still produce 12 over-budget groups (max reservation count 2282, max top-bin occupancy 2312), but count, histogram and canonical retained-token hash are now exactly equal. The record reportscomplete=true, entries=1, calls=1for every arm, andretained_ids_equal=truefor A/A′; B's altered prefix correctly differs with 11 over-budget groups. Both first actual low prediction and clean suffix A/A′ are bitwise equal, RMS=0, maximum=0,reproduction_verified=true, and all 103/103 observed low native/solver boundary records match. The owner separately qualified 7/7 CUDA numerical tests (0 skips) with installed extension via pytest--import-mode=importlibfrom/tmp. The owner-supplied RAR was independently decoded and all 35 tensor + 2 manifest hashes validated.Conclusion: compelling controlled Blackwell evidence that #242 corrects the actual over-budget admission nondeterminism reproduced in #241 and removes the associated A/A′ H3 low-sampler replay divergence in this run. Remaining unobserved physical model/cache state cannot be declared isolated, and audiovisual frame/tone seam is not proven fixed by one A render. Keep #242 draft until broader GPU/packaging qualification. The separate runtime linkage #246 has a nonportable absolute
INSTALL_RPATH, so do not merge it as a release default. Detailed receipts in Flow PR #99.