👋 Hi! Thank you for contributing to the vLLM project.
Just a reminder: PRs would not trigger full CI run by default. Instead, it would only run fastcheck
CI which consists a small and essential subset of CI tests to quickly catch errors. You can run other CI tests on top of default ones by unblocking the steps in your fast-check
build on Buildkite UI.
Once the PR is approved and ready to go, please make sure to run full CI as it is required to merge (or just use auto-merge).
To run full CI, you can do one of these:
/ready
on the PRready
label to the PR🚀
/ready
LGTM
Some of the vLLM abi for custom ops require functionality from the CUDA driver rather than the runtime. e.g: cuTensorMapEncodeTiled. The library seems to get loaded when built with default packages (possibly by one of the older versions of the dependencies), but upgrading them would result in custom ops not getting built correctly.
There are two driver API functions (not runtime API) in use, and that definitely requires linking directly to libcuda or else dlopen/dlsym of the same so that the symbols can be resolved. This dependency is coming in from CUTLASS, it looked like to me.
@youkaichao is this still relevant?
This pull request has merge conflicts that must be resolved before it can be
merged. @sdake please rebase it. https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork
Yes this is still relevant. It's needed because of https://github.com/vllm-project/vllm/blob/main/CMakeLists.txt#L399 .
we usually use the libcuda.so brought by pytorch. if you build pytorch from scratch, chances are pytorch statically link against libcuda.so , and you have to make it available in the linker's path.
I don't think this is needed for the general public.
This is still needed -- can we go ahead and get it merged please?
It's needed because of https://github.com/vllm-project/vllm/blob/main/CMakeLists.txt#L399 .
@cliffwoolley could you say a bit more about why it's needed for this?
It's needed because of https://github.com/vllm-project/vllm/blob/main/CMakeLists.txt#L399 .
@cliffwoolley could you say a bit more about why it's needed for this?
Hi Tyler, the reason this doesn't throw an error by default is that PyTorch loads libcuda.so, and it happens to be loaded before vLLM makes any calls to CUDA. However, if that order is altered for any reason, lack of it leads to issues.
Because
It's needed because of https://github.com/vllm-project/vllm/blob/main/CMakeLists.txt#L399 .
@cliffwoolley could you say a bit more about why it's needed for this?
Where we are using the CUDA driver API -- which the linked line instructs CUTLASS to do -- then we have to have some form of linkage to the CUDA driver library, or else we can get an undefined symbol error like in the OP at runtime. This can be addressed in one of two ways: one is to directly link to the CUDA driver, which is what this PR accomplishes. The other way is via dlopen/dlsym -- or the corresponding convenience wrapper from the CUDA Runtime API that is cudaGetDriverEntryPoint. The latter might be preferable for executables that still have to load without CUDA (perhaps CPU-only, or on some other device type), though it would require some care to ensure that the symbol loaded is given the same name and signature as the CUDA driver would provide while being local/private to to vLLM (so as not to conflict with the actual CUDA driver library, which may also be loaded).
We get away without this only when something else in the address space -- e.g. libtorch -- has already loaded libcuda.so into the process and the dynamic loader can resolve our symbol even though there wasn't actual linkage to it. But it's possible in some cases to call into parts of vLLM that don't happen fo first call through PyTorch to initialize the GPU, and then the problem appears.
@kushanam and @cliffwoolley that is pretty convincing, thanks for the thorough explanation. Any reason not to do the samefor the other CUDA .so files as well (_moe_C.abi3.so
and cumem_allocator.abi3.so
)?
It's best to limit this to places where it's strictly needed. You can find that out by looking at nm -D
on whichever library and looking for U
symbols whose names start like cuSomething
(rather than cudaSomething
, which are from the runtime API, aka libcudart).
Login to write a write a comment.
It is necessary to add
libcuda.so
so that vllm will run against rebuilds of pytorch. I built my own version of pytorch (v2.3.1) to workaround an issue with GPU compute versions to run Neural Magic's dynamic quantization model. The reason for my recompile, although not super relevant, was the related toBLAS
in PyTorch failing with and A40 (compute 8.6) and only expecting compute>8.9, which is unrelated to this issue.I then tried something less exotic
facebookresearch/opt125m
, and a problem was exposed showing thatcuTensorMapEncodeTiled
could not be loaded as part of import vllm._C. The problem resulted in failure of the llvm python process. ThecuTensorMapEncodedTiled
symbol is provided bycutlass
and used bypytorch
. the_C.abi3.so
file shows the symbol is undefined (nm -g /home/sdake/v-llm/lib/python3.11/site-packages/vllm/_C.abi3.so | grep cuTensorMapEncodeTiled
showsU
meaning the symbol isn't available via the system's dynamic loader and this is caused by the symbol not being linked into the dymamic library. I triedpatchelf
to add the dynamic library to_C.abi3.so
which works.I could use the patchelf workaround, however, a more pressing problem is that when cloning
pytorch v2.3.1
, the symbol is consumed. I am not clear why this doesn't show up in broader community testing.Running this build script with this Dockerfile will reproduce the problem nicely. After building, a pytorch wheel is output to
${CWD}/target/torch-2.3.1-cp311-cp311-linux_x86_64.whl