mirror of
https://github.com/Comfy-Org/comfy-kitchen.git
synced 2026-11-04 23:37:42 +00:00
[PR #236] Validate sol_attn binding arguments on CUDA like the HIP binding does #245
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#245
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/236
Author: @Many0therFunctions
Created: 10/10/2026
Status: 🔄 Open
Base:
main← Head:sol-attn-cuda-binding-checks📝 Commits (1)
3099629Validate sol_attn binding arguments on CUDA like the HIP binding does📊 Changes
1 file changed (+68 additions, -25 deletions)
View changed files
📝
comfy_kitchen/backends/cuda/dlpack_bindings.cpp(+68 -25)📄 Description
Problem
tests/test_sol_attn.py::test_bindings_*(12 cases) fail on the CUDA backend withDID NOT RAISE RuntimeError. The CUDA_C.sol_attn/sol_attn_core/sol_producer_begin/sol_producer_chunkbindings check element counts and the q/k/v staging layout, but not:threshold,key_bias,out, the producer operands and the stats buffers — a bfloat16thresholdof the right count, a stridedthresholdview, a float16key_biasor an int8outall get through,batch/seq_len/num_heads(they size the workspace plan and every grid),[start, end)sink ranges (a negative start makes the routing kernel emit extra entries as wrapped uint16 block ids and overrun the per-query row).Because the kernels take bare pointers sized from
(B, T, H), each of these is an out-of-bounds device access rather than an exception, followed by a sticky CUDA error for the rest of the process — in the test suite the first such case cascades into hundreds oftorch.AcceleratorErrorfailures. The HIP binding (backends/hip/dlpack_bindings.cpp) already rejects all of them with the messages the tests match on.Change
One file,
backends/cuda/dlpack_bindings.cpp, mirroring the HIP binding's helpers:need_elemstakes the expectedmap_dtype_to_codevalue and also requires a packed layout (reusingneed_contiguous, moved above it).need_extentsandneed_sinksadded;need_workspaceadditionally requires uint8.sol_attn,sol_attn_core,sol_producer_beginandsol_producer_chunkcall them in the same order as the HIP binding. Thesol_attn_corestats check becomes threeneed_elemscalls so the message names the offending buffer.Dtype codes per operand match what
backends/cuda/__init__.pyalready passes (threshold/key_bias/fab/kmean/vscale/stats fp32,qkv/qw/kw/outbf16, workspace uint8), so production callers are unaffected.Tests
A6000, sm86 build:
tests/test_sol_attn.py105 passed (before: 12 failed, plus the cascade when run without-x).tests/test_int8_attention.pyunchanged (the twolong_sequence_and_partial_tile[scale<=0]failures are the pre-existing torch-reference-NaN cases).🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.