mirror of
https://github.com/Comfy-Org/comfy-kitchen.git
synced 2026-11-04 23:37:42 +00:00
[GH-ISSUE #245] Sol-Attn repeated call invalid resource handle on Blackwell with CUDA 13 source wheel #67
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#67
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/245
Reproduction status (2026-10-12)
An owner building comfy-kitchen
0.2.37from source in a managed WSL Condacomfy312environment (PyTorch2.10.0+cu130, NVIDIA RTX PRO 6000 Blackwell, CUDA 13.0.88 NVCC) observestorch.AcceleratorError: CUDA error: invalid resource handleon subsequent Sol-Attn calls.Critical scope: This was first observed while testing draft Sol token-overflow PR #242, stacked with independent build-only PR #244. It also reproduces with
token_aug=0, which bypasses every new token/retry kernel in #242. There is no clean wheel baseline A/B yet; do not conclude this is an upstream baseline defect or introduced by #242. #242'stoken_aug=0changes are limited to an extra zero-byte workspace slot.Controlled isolation
_C.abi3.soimports, advertises CUDA availability and exposes the addedtokOverflowworkspace field.cuda.quantize_int8_rowwise; one plainck.sol_attn(q,k,v,tau=4.,token_aug=0)+torch.cuda.synchronize().t=4096,h=2,d=128, BF16 QKV, identical seed,CUDA_LAUNCH_BLOCKING=1, synchronization before and after each call: all 6 first Sol calls synchronize successfully; all 6 second calls fail on_block_lengths -> torch.full(...device='cuda'), before a second native launch.torch.cuda.init()before importing Kitchen. All exhibit identical first-success / second-failure, so import order does not explain it./proc/self/mapsreports bothnvidia/cu13/lib/libcudart.so.13andnvidia/cuda_runtime/lib/libcudart.so.12; coexistence is an observation, not proven causal. Native extension linksCUDA::cudart_staticand passes the PyTorch current CUDA stream handle.Next diagnostic
Keep input and CUDA environment fixed, and compare in fresh processes:
ck.sol_attn(creates a temporary internalworkspaceper call).cuda._C.sol_attnwith externally allocated persistent workspace/output and explicit synchronization + tiny allocator probes after each call.Do not change H3 defaults, gate Sol, alter numerical overflow code, or merge the draft on the basis of this failure. A separate clean upstream wheel A/B remains necessary to establish provenance.
@xmarre commented on GitHub (Oct 12, 2026):
Additional isolation: non-Sol Kitchen CUDA also poisons a subsequent PyTorch operation (2026-10-12)
Owner supplied
kitchen-workspace-lifetime.log, five fresh processes withCUDA_LAUNCH_BLOCKING=1, same BF16 QKV, sync after first native operation, andtorch.full((64,),1.,device='cuda')plus sync as the PyTorch probe:copy_(twice)cuda.quantize_int8_rowwiseck.sol_attn(...token_aug=0)cuda._C.sol_attnretaining workspaces/outputscuda._C.sol_attndropping workspaceAll failures occur at same script line in the probe stage after successful synchronization of the first native call. This is not specific to Sol, #242's overflow retry, import order, or short-lived workspace. The error could originate in the PyTorch probe's allocation or its subsequent synchronization (current traceback line alone must be cross-checked with exact script).
Likely shared layer to investigate: extension links
CUDA::cudart_static; the owner previously reportedlibcudart.so.13andlibcudart.so.12mapped alongside PyTorch2.10.0+cu130. There is an analogous NVIDIA CUDA-Q issue #4236 for distinct runtimes interacting with PyTorch and causing invalid resource handles, but this is not proof of the same mechanism here.Next discriminating test: in fresh processes compare default stream vs explicit nondefault PyTorch stream, PyTorch caching allocator enabled vs disabled, and place log prints between
torch.empty,fill_, andtorch.cuda.synchronizeto locate the precise failing operation. Logtorch.cuda.current_stream().cuda_stream, cuda runtime maps, and PyTorch allocator settings. If confirmed runtime-related, test a separate build-linkage PR (CUDA::cudartdynamic instead of static) with Windows/Linux CI and native Blackwell evaluation; do not roll it into numerical PR #242 without proving it.@xmarre commented on GitHub (Oct 12, 2026):
Four-case stream/allocator isolation: all fail specifically on a subsequent PyTorch kernel (2026-10-12)
Owner's
kitchen-runtime-isolation.logrepeats a non-Sol Kitchen operation withCUDA_LAUNCH_BLOCKING=1. Independent processes:PYTORCH_NO_CUDA_MEMORY_CACHINGcuda.quantize_int8_rowwise+torch.cuda.synchronize()torch.empty(64,device='cuda')probe.fill_(1.)The second native call is never reached. Caching, nondefault streams, transient Sol-Attn workspace, import order and Sol overflow logic are now excluded as necessary conditions. In particular, this is not a failure of memory allocation; failure occurs when PyTorch tries to launch
fill_after the successful native kernel and synchronization.Kitchen links
CUDA::cudart_static(incomfy_kitchen/backends/cuda/CMakeLists.txt), while loaded process containslibcudart.so.13andlibcudart.so.12. NVIDIA's best practices state multiple static runtimes may coexist, so linkage incompatibility remains a hypothesis, not proof. A distinct experiment comparing shared CUDART linking can help, but packaging/ABI implications must be checked before upstream adoption. Do not roll this into numerical #242.Next qualification: gather
readelf -d/loader mapping and driver context / stream state at the failing boundary; experimentally build the same extension with CUDART shared linkage in separate draft PR, then run the exact quantization->PyTorch fill reproduction against both builds. Keep #242 and #244 unchanged.@xmarre commented on GitHub (Oct 12, 2026):
Linkage-only A/B now available: draft #246
Based on the four-case allocator/stream isolation above, I published a separate, single-commit diagnostic PR that switches Linux only from
CUDA::cudart_statictoCUDA::cudartand sets both target runtime properties toShared, leaving Windows static and the entire numerical CUDA source untouched. The native reproducertests/manual_cuda_runtime_interop.pychecks repeated non-Sol quantization and plain Sol calls followed by PyTorchfill_, and printsreadelf's extensionlibcudartdependency.DT_NEEDED: libcudart.so.13and 3 iterations of--operation quantizefollowed by--operation solusing the existing script.This leaves numerical draft #242 and build-system draft #244 unchanged.
@xmarre commented on GitHub (Oct 12, 2026):
Root A/B invalidated by ELF link evidence — CUDA 11 selected despite CUDA 13 NVCC (2026-10-12)
Owner installed experimental draft PR #246 alongside numerical #242 and build #244, then ran its manual quantize/Sol probes. Both reported:
This is a concrete compiler/runtime selection mismatch, not a successful matched-CUDA13 shared-runtime experiment. The failure does not falsify matched shared linkage, and a shared-runtime fix must never be qualified with the CUDA 11 dependency present. CMake's
CUDA::cudarttarget resolved to the wrong library, potentially via its cached library search; exact selection mechanism still needs proof. Linkage code never altered the numerical CUDA kernels.Draft #246 is updated to one-commit
cd624cfafe28f6ae526f670967dc3117154a85b0. On Linux it explicitly linkslibcudart.so.<CUDAToolkit_VERSION_MAJOR>only from the selectedCUDAToolkit_ROOTlibrary paths, otherwise configuration fails. It logsCUDA::cudartimported location and selected pinned path, and tests now reject aDT_NEEDEDCUDART major mismatch before running the GPU repro. Windows static linkage and all numerical sources remain unchanged. CI run 38207788536 is building the revised code.Owner next step after CI: refresh only temporary #246 overlay in Patcher, rebuild, and first inspect the new
DT_NEEDED. Only iflibcudart.so.13and no old cudart are needed by the extension should the quantize/sol three-iteration A/B be interpreted. No H3 full run/merge/release while the common CUDA interop problem persists.@xmarre commented on GitHub (Oct 12, 2026):
Matched CUDA 13 runtime: repeat-call repro now passes (Blackwell, 2026-10-12)
The owner refreshed diagnostic PR #246 to head
cd624cfafe28f6ae526f670967dc3117154a85b0and rebuilt the same Kitchen overlay stack (#242 numerical, #244 build, #246 shared-runtime A/B). Confirmed installed_C.abi3.soELFDT_NEEDED: libcudart.so.13on PyTorch2.10.0+cu130, RTX PRO 6000 Blackwell WSL. Loaded shared CUDA runtimes include versions 13 and 12, but not the host's CUDA 11.5.With
CUDA_LAUNCH_BLOCKING=1and an explicit native-sync → PyTorch allocation →fill_→ sync sequence, both non-Sol Kitchenquantize_int8_rowwise3/3 PASS and plain Sol-Attntoken_aug=03/3 PASS. Under the old static-runtime build, both failed after first call at the PyTorchfill_probe. The first shared-runtime test (prior head #246) had actually linkedlibcudart.so.11.0and failed: it was an invalid matched-CUDA13 A/B.Inference: strong causal support for native/PyTorch CUDA runtime-linkage compatibility as the class of problem; does not prove static linkage is intrinsically wrong, because the static binary's internal CUDART version has not been established. In particular, coexistence of libcudart.so.12 with 13 is still observed and harmless in this six-call test.
Disposition: low-level interop blocker cleared for this three-iteration WSL test environment only. Keep #246 DRAFT pending packaging audit: absolute
INSTALL_RPATHto local Conda CUDA install is unsuitable for general-purpose redistribution; cross-machine wheel audit, Windows behavior, selected CUDA toolkit detection and loader interoperability must be qualified separately before proposing upstream merge. Now proceed with original #242 CUDA overflow numerical suite. Do not merge/release any PR yet.@xmarre commented on GitHub (Oct 12, 2026):
Status: the corrected matched-CUDA13 experimental linkage (#246 head cd624cfa) passed 3/3 repeated non-Sol and 3/3 repeated plain Sol interop smoke checks on the owner's Blackwell, and now 7/7 actual GPU numerical tests in the stack (#242+#244+#246). This confirms the previously reproducible PyTorch invalid resource-handle blocker does not appear in these tests with matched shared CUDART 13. Keep #245 open for runtime selection/linkage provenance and portable wheel fix, #246 draft; do not infer dynamic CUDART is universally necessary or that static CUDART is intrinsically unsafe.
@xmarre commented on GitHub (Oct 12, 2026):
Review-ready PR cluster / issue #245 status (2026-10-12)
The owner had
cudaErrorInvalidResourceHandleafter both Sol and unrelated quantization kernels under mixed runtime linkage, but achieved 3/3 repeated non-Sol + 3/3 repeated plain Sol interop PASS, 7/7 numerical CUDA tests, and a full deterministic H3 01907 continuation with matched shared CUDA13. The Linux shared-runtime source fix is now review-ready in PR #246 at6803e41b; it explicitly selects the matching toolkit CUDART and replaces the previous absolute CUDA toolkit RPATH with$ORIGIN, and CI now checks actual ELF dependencies in both Linux wheel architectures. Separate #244 (0e2d78cd) now invalidates staleCUDA_cudart_LIBRARY/toolkit root cache entries; Python-focused 9/9 PASS. Both PRs remain unmerged. The new relocatable #246 revision needs CI/wheel-ELF verification and post-rebuild owner GPU interop check before release. Do not close this issue based only on PR review readiness.