Open
Conversation
Signed-off-by: LosCrossos <165311345+loscrossos@users.noreply.github.com>
This was referenced Feb 27, 2026
|
not work |
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.
TLDR;
see below.
@jt-zhang the Error is not really on Sageattention but on Pytorch. No sure about best way to proceed. anyways i creted the PR so people wanting to compile on windows can apply it. Or accept it and make people happy. this fix does not affect Linux or other windows compilers apart from MSVC.
Sage2 and Sage3 compile. on windows the mem misalign bug is still there and not fixed by this PR. only compile.
Problem
When building the CUDA extensions on Windows we were seeing a build error from a
PyTorch header:
The failure wasn’t in any of our CUDA kernels at all, but in the host‑side translation unit generated by nvcc. compiled_autograd.h contains a #if that only keeps the large std::‑heavy else branch out of the build if the
USE_CUDA (or USE_ROCM) macro is defined.
https://github.com/pytorch/pytorch/blob/d33f96c5ccb43430ec2db286ea6490da9035895d/torch/csrc/dynamo/compiled_autograd.h#L1118
Without that macro the else branch is evaluated, the compiler trips over an MSVC namespace/typedef collision,
and the ninja build aborts.
Solution
Ensure that every compilation of our extension passes -DUSE_CUDA to the host compiler. This mirrors the definition PyTorch itself uses and forces the header to take its safe "CUDA-enabled on Windows" path.
The change simply adds -DUSE_CUDA to both CXX_FLAGS and NVCC_FLAGS in setup.py.
This change only affects Windows/MSVC (DISTUTILS_USE_SDK ) and not other windows compilers (MinGW etc).
No behaviour of the library is altered on Linux/other platforms.
Result
Builds now succeed on Windows with recent PyTorch/CUDA combinations; the
previous “ambiguous std” error is gone. The fix is entirely internal to the
build system and does not affect runtime functionality.