Fix: Remove misleading py_limited_api=cp39 wheel tag for PyTorch extension#1
Merged
Conversation
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.
Description
This PR removes the
options={"bdist_wheel": {"py_limited_api": "cp39"}}argument fromhopper/setup.py.Why is this necessary?
Currently, the build system forces the generated wheels to be tagged as
cp39-abi3. While this implies the wheel is portable across Python 3.9+ environments, Flash Attention 3 is a PyTorch C++ extension.PyTorch C++ extensions are strictly linked to the PyTorch C++ ABI (e.g.,
libtorch_python.so), which changes between PyTorch versions.If a user compiles FA3 on Python 3.11 with PyTorch 2.11, the wheel is tagged
cp39-abi3. If they then attempt to install this wheel on a Python 3.9 environment (which requires an older PyTorch version since 2.11 dropped 3.9 support), the installation succeeds, but importing the module results in a fatal crash:ImportError: undefined symbol: aoti_torch_create_device_guardThe Fix
By removing the
py_limited_apioverride,setuptoolswill correctly tag the wheel with the exact CPython version it was built against (e.g.,cp311-cp311). This prevents users from sharing incompatible wheels across different Python/PyTorch environments and encountering silent ABI linker errors.