Repository navigation
Commit cff6f4d
authored
Ship the CUDA Windows import library only in CUDA builds (pytorch#22054)
Depends on pytorch#22053, which is what makes a flag declared on a source tree file take effect. That one has landed and this branch is rebased on top of it.
### Summary
`backends/cuda/runtime/aoti_cuda_shims.lib` is a Windows import library: the small link stub a Windows program links against so its calls reach the CUDA delegate's shim DLL at run time. Lowering for Windows is a cross compile, so a Linux CUDA build needs it too, not only a Windows build.
Unlike the other files the wheel picks up, it is checked into the source tree rather than built, and its packaging entry declared no CMake options, so it went into every published wheel. On the most recent nightly cut that is all 50 rows: the 30 CUDA rows, which can use it, and the 20 CPU rows, which cannot. Five of those CPU rows are macOS, where the CUDA delegate cannot exist at all. Those wheels carry a link stub for a library they do not contain.
Declare `EXECUTORCH_BUILD_CUDA` on the entry, the same option that gates the delegate's own shared library, which is the very next entry in `ext_modules`. The import library now ships when the delegate does and not otherwise.
The code that reads it back needs a matching check, because this change is what makes that directory disappear. When lowering for a Windows target, `cuda_backend` defaults the shim library path to the installed package's `data/lib` directory. On a CPU wheel today the import library is the only file in there, so once it stops shipping, the directory stops existing. `executorch.data.lib` is not a declared package, so nothing else creates it, and a directory that is not there still reads back as an ordinary path instead of raising. Without a check, a CPU install would pass a missing directory straight into the AOTInductor link options and the failure would surface far from its cause. It now fails where the assumption breaks, and names both the fix and the `shim_library_path` compile spec that overrides the default.
### Test plan
Called `get_aoti_compile_options()` with a `windows` platform compile spec against a package directory with no `data/lib`, one with an empty `data/lib`, one holding the import library, and one with no `data/lib` but an explicit `shim_library_path` spec. The first two raise and the last two return the expected path. Ran the same four without the new check and all four returned a path, including the one that does not exist.
The new wheel test asks whether the wheel ships the `aoti_cuda_shims` shared library, not whether its version carries a `+cuXXX` label, because only a published wheel carries that label and a locally built CUDA wheel would otherwise be told to drop a file it needs. Both files are packaged behind `EXECUTORCH_BUILD_CUDA` alone, so they arrive together. Ran it in all four combinations of the shim library present or absent and the import library present or absent, and it passes only on the two that match. Ran it against today's published nightly wheels: the CPU wheel fails, which is the case this change removes, and the CUDA wheel passes. Removing the import library from the CPU wheel, which is what this change does, turns that failure into a pass and leaves the CUDA wheel passing.
That test runs from the wheel test entry point used by the Linux, Linux aarch64, macOS and CUDA Linux jobs, so it covers 45 of the 50 wheels published today. The Windows job does not use that entry point, so the 5 Windows wheels are not covered by it.
The same packaging change was built by the wheel jobs on pytorch#22049. Unzipping six of those wheels: the CPU, macOS and Windows wheels lose `executorch/data/lib/aoti_cuda_shims.lib` and nothing else, and the CUDA wheels are unchanged file for file.1 parent 16fef19 commit cff6f4d
3 files changed
Lines changed: 49 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2343 | 2343 | | |
2344 | 2344 | | |
2345 | 2345 | | |
| 2346 | + | |
| 2347 | + | |
| 2348 | + | |
| 2349 | + | |
| 2350 | + | |
| 2351 | + | |
| 2352 | + | |
| 2353 | + | |
| 2354 | + | |
| 2355 | + | |
| 2356 | + | |
| 2357 | + | |
| 2358 | + | |
| 2359 | + | |
| 2360 | + | |
| 2361 | + | |
| 2362 | + | |
| 2363 | + | |
| 2364 | + | |
| 2365 | + | |
| 2366 | + | |
| 2367 | + | |
| 2368 | + | |
| 2369 | + | |
| 2370 | + | |
| 2371 | + | |
| 2372 | + | |
| 2373 | + | |
| 2374 | + | |
| 2375 | + | |
| 2376 | + | |
| 2377 | + | |
| 2378 | + | |
| 2379 | + | |
| 2380 | + | |
2346 | 2381 | | |
2347 | 2382 | | |
2348 | 2383 | | |
| |||
2559 | 2594 | | |
2560 | 2595 | | |
2561 | 2596 | | |
| 2597 | + | |
2562 | 2598 | | |
2563 | 2599 | | |
2564 | 2600 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
801 | 801 | | |
802 | 802 | | |
803 | 803 | | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
804 | 814 | | |
805 | 815 | | |
806 | 816 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2390 | 2390 | | |
2391 | 2391 | | |
2392 | 2392 | | |
| 2393 | + | |
| 2394 | + | |
2393 | 2395 | | |
2394 | 2396 | | |
2395 | 2397 | | |
2396 | 2398 | | |
2397 | | - | |
| 2399 | + | |
2398 | 2400 | | |
2399 | 2401 | | |
2400 | 2402 | | |
| |||
0 commit comments