Skip to content

Update core.py Fix for CUDA <12.8#202

Open
umerkay wants to merge 2 commits into
thu-ml:mainfrom
umerkay:main
Open

Update core.py Fix for CUDA <12.8#202
umerkay wants to merge 2 commits into
thu-ml:mainfrom
umerkay:main

Conversation

@umerkay

@umerkay umerkay commented Jul 2, 2025

Copy link
Copy Markdown

Fix for CUDA <12.8 to fallback with warning "cuda version < 12.8, change pv_accum_dtype to 'fp32+fp32'"

Pls recompile with these changes (uncommenting lines 687-690 in sageattention/core.py).

Without these changes:
On my CUDA 12.5 setup on 4090, Upgrading from Sage Attention 1.0.6 to Sage Attention 2.2.0 gave me the following error

`terminate called after throwing an instance of 'c10::Error'
what(): CUDA error: unspecified launch failure
Compile with TORCH_USE_CUDA_DSA to enable device-side assertions.

Exception raised from c10_cuda_check_implementation at /pytorch/c10/cuda/CUDAException.cpp:43 (most recent call first):
frame #0: c10::Error::Error(c10::SourceLocation, std::__cxx11::basic_string<char, std::char_traits, std::allocator >) + 0x98 (0x7fab780f45e8 in /home/umer/anaconda3/envs/comfyui/lib/python3.12/site-packages/torch/lib/libc10.so)
frame #1: c10::detail::torchCheckFail(char const*, char const*, unsigned int, std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&) + 0xe0 (0x7fab780894a2 in /home/umer/anaconda3/envs/comfyui/lib/python3.12/site-packages/torch/lib/libc10.so)
frame #2: c10::cuda::c10_cuda_check_implementation(int, char const*, char const*, int, bool) + 0x3c2 (0x7fab781d2292 in /home/umer/anaconda3/envs/comfyui/lib/python3.12/site-packages/torch/lib/libc10_cuda.so)
frame #3: + 0x5d213 (0x7fab781d9213 in /home/umer/anaconda3/envs/comfyui/lib/python3.12/site-packages/torch/lib/libc10_cuda.so)
frame #4: + 0x44c172 (0x7fab6ee4c172 in /home/umer/anaconda3/envs/comfyui/lib/python3.12/site-packages/torch/lib/libtorch_python.so)
frame #5: c10::TensorImpl::~TensorImpl() + 0x9 (0x7fab780cef39 in /home/umer/anaconda3/envs/comfyui/lib/python3.12/site-packages/torch/lib/libc10.so)
frame #6: + 0x7033e8 (0x7fab6f1033e8 in /home/umer/anaconda3/envs/comfyui/lib/python3.12/site-packages/torch/lib/libtorch_python.so)
frame #7: + 0x703810 (0x7fab6f103810 in /home/umer/anaconda3/envs/comfyui/lib/python3.12/site-packages/torch/lib/libtorch_python.so)

frame #10: + 0x72e2ad (0x7fab6f12e2ad in /home/umer/anaconda3/envs/comfyui/lib/python3.12/site-packages/torch/lib/libtorch_python.so)
frame #13: dynamo_eval_custom_code + 0x1fe (0x7fab6f12d17e in /home/umer/anaconda3/envs/comfyui/lib/python3.12/site-packages/torch/lib/libtorch_python.so)
frame #14: + 0x72e1ac (0x7fab6f12e1ac in /home/umer/anaconda3/envs/comfyui/lib/python3.12/site-packages/torch/lib/libtorch_python.so)
frame #17: dynamo_eval_custom_code + 0x1fe (0x7fab6f12d17e in /home/umer/anaconda3/envs/comfyui/lib/python3.12/site-packages/torch/lib/libtorch_python.so)
frame #18: + 0x72e1ac (0x7fab6f12e1ac in /home/umer/anaconda3/envs/comfyui/lib/python3.12/site-packages/torch/lib/libtorch_python.so)
frame #21: dynamo_eval_custom_code + 0x1fe (0x7fab6f12d17e in /home/umer/anaconda3/envs/comfyui/lib/python3.12/site-packages/torch/lib/libtorch_python.so)
frame #22: + 0x72e05b (0x7fab6f12e05b in /home/umer/anaconda3/envs/comfyui/lib/python3.12/site-packages/torch/lib/libtorch_python.so)
frame #25: dynamo_eval_custom_code + 0x1fe (0x7fab6f12d17e in /home/umer/anaconda3/envs/comfyui/lib/python3.12/site-packages/torch/lib/libtorch_python.so)
frame #26: + 0x72e05b (0x7fab6f12e05b in /home/umer/anaconda3/envs/comfyui/lib/python3.12/site-packages/torch/lib/libtorch_python.so)
frame #29: dynamo_eval_custom_code + 0x1fe (0x7fab6f12d17e in /home/umer/anaconda3/envs/comfyui/lib/python3.12/site-packages/torch/lib/libtorch_python.so)
frame #30: + 0x72e05b (0x7fab6f12e05b in /home/umer/anaconda3/envs/comfyui/lib/python3.12/site-packages/torch/lib/libtorch_python.so)
frame #35: + 0x72e2ad (0x7fab6f12e2ad in /home/umer/anaconda3/envs/comfyui/lib/python3.12/site-packages/torch/lib/libtorch_python.so)
frame #40: + 0x72e2ad (0x7fab6f12e2ad in /home/umer/anaconda3/envs/comfyui/lib/python3.12/site-packages/torch/lib/libtorch_python.so)

Aborted (core dumped)`

Fix for CUDA <12.8 to fallback with warning "cuda version < 12.8, change pv_accum_dtype to 'fp32+fp32'"
@pamparamm

pamparamm commented Jul 3, 2025

Copy link
Copy Markdown

These changes require get_cuda_version function to be rewritten, as it spawns nvcc subprocesses on each sageattn_qk_int8_pv_fp8_cuda call and that is very performance heavy

@umerkay

umerkay commented Jul 4, 2025

Copy link
Copy Markdown
Author

Fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants