Move cuda.core Windows AOTI stub-lib generation into build_ext in setup.py#2033
Move cuda.core Windows AOTI stub-lib generation into build_ext in setup.py#2033rwgk wants to merge 1 commit intoNVIDIA:mainfrom
Conversation
Reuse setuptools' initialized MSVC compiler when linking _tensor_bridge so Windows source builds do not need separate toolchain discovery in build_hooks.py. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
|
/ok to test |
|
|
Local testing with pytorch installed: |
mdboom
left a comment
There was a problem hiding this comment.
I know setup.py is still officially supported (just not calling it directly anymore), but I still like the idea of moving as much as we can to the "modern" tooling approach. I'm a little surprised that setuptools build_hooks support doesn't allow one to hook in "later" in the process, but I can't find anything.
Our needs are getting pretty complex here, and maybe we should explore one of the other build backends to see if they would provide better functionality. In the meantime, this is fine if it addresses a real need today.
Background
cuda_coreneeds a Windows stub import library for_tensor_bridgeso MSVC can link against PyTorch's AOTI symbols fromtorch_cpu.dllwithout making PyTorch itself a build-time dependency.That stub library was previously generated in
cuda_core/build_hooks.py. This worked in CI because the Windows workflows explicitly prepare the MSVC environment first, but it made local/source builds depend on a separate toolchain discovery path beforesetuptoolshad initialized its compiler machinery.What This Changes
aoti_shim.libgeneration out ofcuda_core/build_hooks.pyand intocuda_core/setup.py.build_ext, aftersetuptoolshas created and initialized the compiler object it will actually use for the extension build.lib.exeand append the generated import library only tocuda.core._tensor_bridge.lib.exesubprocess path from the PEP 517 build backend sobuild_hooks.pygoes back to focusing on extension preparation and cythonization.aoti_shim.handaoti_shim.defto document that the stub library is now produced fromsetup.py/build_ext.Why
setuptoolsalready uses for the actual extension build instead of maintaining a second discovery/bootstrap path in the build backend.Scope
cuda.core._tensor_bridge.Testing
build_hooks.py.