Skip to content

Commit ea50e53

Browse files
committed
Update
[ghstack-poisoned]
2 parents 2de8249 + 89193df commit ea50e53

7 files changed

Lines changed: 49 additions & 34 deletions

File tree

.ci/scripts/wheel/test_shared_libraries.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,13 @@
7474
"aoti_torch_empty_strided",
7575
"aoti_torch_delete_tensor_object",
7676
"executorch::backends::cuda::CUDAStreamGuard::create",
77+
# From the CUDA sources rather than the C++ ones. The build drops every .cu file when no working
78+
# compiler is found, and the library is still produced from its .cpp sources, so a check that
79+
# names only C++ symbols passes on a library missing every kernel it was gated for.
80+
"aoti_torch_cuda__weight_int4pack_mm",
81+
"aoti_torch_cuda_sort_stable",
82+
"aoti_torch_cuda_rand",
83+
"aoti_torch_cuda_randint_low_out",
7784
)
7885

7986
_QUANTIZED_KERNEL_SYMBOLS = (

backends/cuda/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,8 @@ endif()
160160
# retention.
161161
if(_cuda_is_msvc_toolchain)
162162
target_link_libraries(
163-
aoti_cuda_shims PRIVATE cuda_platform CUDA::cudart CUDA::curand
164-
extension_cuda ${CMAKE_DL_LIBS}
163+
aoti_cuda_shims PRIVATE cuda_platform CUDA::cudart extension_cuda
164+
${CMAKE_DL_LIBS}
165165
)
166166
# Link object library directly so symbols are pulled exactly once while
167167
# avoiding duplicate static/object inclusion and interface leakage.
@@ -177,7 +177,7 @@ else()
177177
aoti_cuda_shims
178178
PRIVATE cuda_platform -Wl,--whole-archive aoti_common_shims_slim
179179
-Wl,--no-whole-archive
180-
PUBLIC CUDA::cudart CUDA::curand extension_cuda ${CMAKE_DL_LIBS}
180+
PUBLIC CUDA::cudart extension_cuda ${CMAKE_DL_LIBS}
181181
)
182182
endif()
183183

devtools/etdump/CMakeLists.txt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,14 @@ if(EXECUTORCH_BUILD_SHARED)
6969
# name something a consumer cannot link. Scoped to the shared build so a build
7070
# that does not opt in keeps the parent's public dependency.
7171
target_link_libraries(etdump PRIVATE flatccrt executorch_shared)
72-
else()
73-
target_link_libraries(etdump PUBLIC flatccrt)
74-
target_link_libraries(etdump PRIVATE executorch)
75-
endif()
76-
if(EXECUTORCH_BUILD_SHARED)
7772
set_target_properties(etdump PROPERTIES OUTPUT_NAME executorch_etdump)
7873
executorch_target_soname_policy(etdump)
7974
# Ships beside libexecutorch.so in the wheel's lib/ directory, and needs it,
8075
# so it has to be able to find it from wherever the package is installed.
8176
executorch_target_shipped_runtime_path(etdump)
77+
else()
78+
target_link_libraries(etdump PUBLIC flatccrt)
79+
target_link_libraries(etdump PRIVATE executorch)
8280
endif()
8381

8482
target_include_directories(

install_utils.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import platform
1111
import re
1212
import shlex
13+
import shutil
1314
import subprocess
1415
import sys
1516
from typing import List, Optional
@@ -159,14 +160,18 @@ def _selected_nvcc() -> List[str]:
159160
explicit = os.environ.get("CUDACXX")
160161
if explicit:
161162
return [explicit, "--version"]
162-
# CUDA_PATH is honoured by CMake's own compiler search, and /usr/local/cuda is the route
163-
# FindCUDAToolkit resolves through when nothing else is set. Skipping both meant packaging could
164-
# report no toolkit while the build compiled with one, which disables the mismatch guard.
165-
for root in (
166-
os.environ.get("CUDAToolkit_ROOT"),
167-
os.environ.get("CUDA_PATH"),
168-
"/usr/local/cuda",
169-
):
163+
# Follow CMake's COMPILER search, since that is what decides which nvcc compiles the sources:
164+
# CUDACXX above, then PATH, then CUDA_PATH, then the conventional symlink. PATH has to come
165+
# before the others. Measured with only PATH pointing at 13.0 on a box whose /usr/local/cuda is
166+
# 12.8, CMake compiles with 13.0, so consulting the symlink first reported 12.8 and produced
167+
# metadata for a train the binaries were not built with.
168+
#
169+
# CUDAToolkit_ROOT is deliberately absent: it steers find_package(CUDAToolkit) but CMake's
170+
# compiler search ignores it, so reading it here names a compiler that will not be used.
171+
on_path = shutil.which("nvcc")
172+
if on_path:
173+
return [on_path, "--version"]
174+
for root in (os.environ.get("CUDA_PATH"), "/usr/local/cuda"):
170175
if not root:
171176
continue
172177
candidate = os.path.join(root, "bin", "nvcc")

setup.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -216,14 +216,8 @@ def _minimal_packages() -> List[str]:
216216
# the CUDA runtime and cuRAND and nothing else, and the generated model library embeds its kernels
217217
# rather than compiling them at run time, so there is no runtime compiler to satisfy either.
218218
_CUDA_RUNTIME_PACKAGES = {
219-
"12": (
220-
"nvidia-cuda-runtime-cu12",
221-
"nvidia-curand-cu12",
222-
),
223-
"13": (
224-
"nvidia-cuda-runtime",
225-
"nvidia-curand",
226-
),
219+
"12": ("nvidia-cuda-runtime-cu12",),
220+
"13": ("nvidia-cuda-runtime",),
227221
}
228222

229223
# Where each train installs its libraries under site-packages. CUDA 13 collects them in
@@ -234,10 +228,7 @@ def _minimal_packages() -> List[str]:
234228
# searches what is recorded here, so a missing directory leaves a shipped library unable to find
235229
# a package that is installed, and an extra one implies a dependency the wheel does not have.
236230
_CUDA_LIBRARY_DIRECTORIES = {
237-
"12": (
238-
"nvidia/cuda_runtime/lib",
239-
"nvidia/curand/lib",
240-
),
231+
"12": ("nvidia/cuda_runtime/lib",),
241232
"13": ("nvidia/cu13/lib",),
242233
}
243234

tools/cmake/executorch-wheel-config.cmake

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@
4141
# A consumer using these variables has to set it, because a compiler defaulting
4242
# to an older standard cannot parse them.
4343
#
44+
# EXECUTORCH_RUNTIME_LIBRARY_DIR -- Where the shipped libraries live. A consumer
45+
# that installs its own binary elsewhere adds this to its INSTALL_RPATH, because
46+
# CMake removes the entry it recorded while building.
47+
#
4448
# EXECUTORCH_LIBRARIES -- Libraries to link against: the prebuilt runtime and
4549
# the components the wheel shipped, except the ones documented below as opt in.
4650
# Not the Python extension, which carries unresolved interpreter symbols that
@@ -184,6 +188,16 @@ if(EXISTS "${_executorch_version_file}")
184188
endif()
185189
unset(_executorch_version_file)
186190

191+
# Where the shipped libraries live. Computed here rather than beside the Python
192+
# extension, because a consumer on the older variables route is told to put this
193+
# in its INSTALL_RPATH, and a package built without that extension would
194+
# otherwise hand it an empty string and produce a binary that cannot start.
195+
if(_executorch_runtime_library)
196+
get_filename_component(
197+
EXECUTORCH_RUNTIME_LIBRARY_DIR "${_executorch_runtime_library}" DIRECTORY
198+
)
199+
endif()
200+
187201
set(EXECUTORCH_INCLUDE_DIRS "${_executorch_package_root}/include"
188202
"${_executorch_c10_include}"
189203
)
@@ -746,12 +760,6 @@ if(_portable_lib_LIBRARY)
746760
# every consumer and survives install, which would bake this machine's
747761
# package location into a library the consumer ships onward. A consumer that
748762
# installs elsewhere adds these to its own INSTALL_RPATH.
749-
get_filename_component(
750-
EXECUTORCH_RUNTIME_LIBRARY_DIR "${_executorch_runtime_library}" DIRECTORY
751-
)
752-
get_filename_component(
753-
EXECUTORCH_PYTHON_EXTENSION_DIR "${_portable_lib_LIBRARY}" DIRECTORY
754-
)
755763
endif()
756764
endif()
757765

tools/cmake/preset/pybind.cmake

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ set_overridable_option(EXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL ON)
2121
set_overridable_option(EXECUTORCH_BUILD_KERNELS_LLM ON)
2222
set_overridable_option(EXECUTORCH_BUILD_KERNELS_LLM_AOT ON)
2323
set_overridable_option(EXECUTORCH_BUILD_KERNELS_OPTIMIZED ON)
24+
# The wheel ships the profiler library and documents it as usable, so the tracer
25+
# has to be compiled in. Left off, every recording hook is preprocessed away and
26+
# a caller gets an empty trace with no error. The devtools directory is already
27+
# built for a shared or pybind build, which is all this option requires.
28+
set_overridable_option(EXECUTORCH_ENABLE_EVENT_TRACER ON)
29+
set_overridable_option(EXECUTORCH_BUILD_DEVTOOLS ON)
2430
set_overridable_option(EXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR ON)
2531
set_overridable_option(EXECUTORCH_BUILD_EXTENSION_DATA_LOADER ON)
2632
set_overridable_option(EXECUTORCH_BUILD_EXTENSION_MODULE ON)

0 commit comments

Comments
 (0)