Repository navigation
Fix the SM120 Sage and ConvRot GELU kernels on Windows - #1639
Open
hiroki-abe-58 wants to merge 1 commit into
Open
hiroki-abe-58 wants to merge 1 commit into
hiroki-abe-58 wants to merge 1 commit into
Conversation
- sage_attn2_sm120_cached: the Windows SageAttention wheels are stable-ABI builds that register the fused and SM89 kernels as torch ops, so sageattention._fused/_qattn_sm89 have no function attributes; use torch.ops.sageattention_fused / sageattention_qattn_sm89 when the modules have none. - convrot_gelu_quant.cu: a Windows DLL exports only functions marked for export, so ctypes could not find the two entry points; export them on _WIN32. - prepare_convrot_gelu_fusion: treat a missing entry point (AttributeError) like a failed build, so the unfused path is used as documented.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On Windows, the RTX 5090 EdenLive preset (
configs/edenlive/realtime/wan22_5b_ar_int8_convrot_5090.json) stops before the first chunk. There are two separate failures.Problem
sage_attn2_sm120_cachedcallssageattention._fusedand_qattn_sm89functions as module attributes. The Windows SageAttention wheels that the Windows guide links to (woct0rdho, stable-ABI builds) register these kernels as torch ops instead (torch.ops.sageattention_fused,torch.ops.sageattention_qattn_sm89), so the modules have no such attributes:AttributeError: module 'sageattention._fused' has no attribute 'quant_per_block_int8_fuse_sub_mean_cuda'cpp_extension.load(is_python_module=False)and opened withctypes. On Windows a DLL only exports functions that are marked for export, so the entry point is missing:AttributeError: function 'lightx2v_prepare_convrot_gelu' not foundprepare_convrot_gelu_fusiononly catchesOSErrorandRuntimeError, so the model load fails, instead of falling back to the unfused path as its docstring describes.Change
sage_sm120_cached.py: one helper returns the module functions when the module has them, and otherwise the torch-ops namespaces (stable-ABI builds). Builds with module functions behave as before.convrot_gelu_quant.cu: export the twoextern "C"entry points under_WIN32. The macro is empty on other platforms.fused_gelu_linear.py: a missing entry point (AttributeError) now counts as "fusion unavailable", like a failed build.Validation
Setup: Windows 11, RTX 5090 (driver 610.88), torch 2.14.1+cu130, SageAttention
2.2.0+cu130torch2.10.0andhigher.post6(abi3), comfy-kitchen 0.2.39, CUDA 13.1 with MSVC 2022 (Build Tools 17.14).Kernel checks (EdenLive 5B attention shapes: 24 heads, head dim 128, 2640 query and 15840 key/value tokens, BF16):
SageAttn2Sm120CachedWeight.applyvs SDPAAttributeErrorapply_prepared(prepare_sage_sm120_kv(...))vs SDPAAttributeErrorprepare_convrot_gelu_fusion()AttributeErrorTrue;dumpbin /exportslists both functionsfused_gelu_convrot_int8_quant(x)vs comfy-kitchen'squantize_int8_rowwise_convrot64(gelu(x), 256), x: [2640, 14336] BF16End to end. I ran
python -m lightx2v.infer --model_cls wan22_edenlive_ar --task i2vwith the 5090 preset's settings: INT8 ConvRot DiT and proxy encoder,sage_attn2_sm120_cached,use_compile,warmup,use_cuda_graph, and LightTAE streaming decode. Three kernels have no Windows build, so I substituted:torch_real_ropefor FlashInfer RoPE;Input: the first 120 frames of the
cryo-crossingsample at 1280×704.For comparison, on the same machine without
sage_attn2_sm120_cached, compile and CUDA graphs:Not changed here: building the extension needs the MSVC environment, and
vcvars64.batsetsPlatform=x64. Windows environment variable names are case-insensitive, solightx2v_platformreads it asPLATFORMand stops withUnsupported PLATFORM: x64unlessPLATFORM=cudais set. I can add a line about this to the Windows guide if that would help.🤖 Generated with Claude Code