Skip to content

Commit 630497c

Browse files
authored
fix(executorch): drop the unused cuRAND link from the CUDA shims (#4653)
1 parent f753a1c commit 630497c

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

py/torch-tensorrt-executorch-runtime/native/CMakeLists.txt

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ target_link_libraries(portable_lib PRIVATE
227227
# selects CMAKE_CXX_COMPILER and those standard libraries for these targets, so it has
228228
# to be set on every one of them.
229229
#
230+
230231
# The CUDA backend brings two shared libraries of its own. They get the same treatment,
231232
# because libaoti_cuda_shims.so is the first DT_NEEDED of _portable_lib.so and so leads
232233
# the whole dlopen group in symbol search order.
@@ -250,6 +251,33 @@ foreach(_torch_tensorrt_executorch_runtime_target
250251
PROPERTY LINKER_LANGUAGE CXX)
251252
endforeach()
252253

254+
# ExecuTorch links CUDA::curand into aoti_cuda_shims, but nothing in it calls a curand
255+
# host function: the only curand use in the pinned source is the device-side API from
256+
# curand_kernel.h inside rand.cu, which nvcc compiles into the fatbinary. Measured on the
257+
# shipped artifact: DT_NEEDED carries libcurand.so.10 while the dynamic symbol table
258+
# imports no curand symbol at all.
259+
#
260+
# The over-link is not harmless: the wheel declares a dependency it never calls, and
261+
# nothing guarantees an installer provides it, so importing the runtime can fail on a
262+
# missing shared object before any delegate runs. Which installers happen to supply
263+
# libcurand.so.10 is not stable and has already changed more than once, so the reason to
264+
# drop the link is that nothing uses it, not that a particular resolver omits it.
265+
#
266+
# Dropped here rather than patched into ExecuTorch. This becomes a no-op only once the
267+
# pin includes upstream's own removal, which landed on their main line AFTER the pinned
268+
# release. The 1.4 series still links cuRAND, so a patch bump within 1.4 does not make
269+
# this redundant: check that the pinned tree has no CUDA::curand in
270+
# backends/cuda/CMakeLists.txt before deleting this block.
271+
foreach(_torch_tensorrt_curand_property LINK_LIBRARIES INTERFACE_LINK_LIBRARIES)
272+
get_target_property(_torch_tensorrt_curand_value
273+
aoti_cuda_shims ${_torch_tensorrt_curand_property})
274+
if(_torch_tensorrt_curand_value AND CUDA::curand IN_LIST _torch_tensorrt_curand_value)
275+
list(REMOVE_ITEM _torch_tensorrt_curand_value CUDA::curand)
276+
set_property(TARGET aoti_cuda_shims
277+
PROPERTY ${_torch_tensorrt_curand_property} "${_torch_tensorrt_curand_value}")
278+
endif()
279+
endforeach()
280+
253281
# The runtime wheel intentionally does not bundle PyTorch, TensorRT, or CUDA.
254282
# PyTorch, TensorRT, and CUDA pip packages install their shared libraries in
255283
# directories under site-packages, relative to this extension package.

0 commit comments

Comments
 (0)