diff --git a/setup.py b/setup.py index 3dedb83e66..522a90fe30 100644 --- a/setup.py +++ b/setup.py @@ -289,7 +289,8 @@ def remove_rpath(path: Path) -> None: class CMakeExtension(Extension): def __init__(self, name: str, cmake_lists_dir: str = ".", **kwa) -> None: - super().__init__(name, sources=[], py_limited_api=not is_freethreaded(), **kwa) + kwa.setdefault("py_limited_api", not is_freethreaded()) + super().__init__(name, sources=[], **kwa) self.cmake_lists_dir = os.path.abspath(cmake_lists_dir) @@ -1247,11 +1248,18 @@ def _read_requirements(filename: str) -> list[str]: if _is_cuda(): if _cuda_arch_contains(7, 0): ext_modules.append(CMakeExtension(name="vllm._sm70_sampler_C")) - ext_modules.append(CMakeExtension(name="vllm._sm70_exact_reduce_C")) - ext_modules.append(CMakeExtension(name="vllm._h3_w8a16_C")) - ext_modules.append(CMakeExtension(name="vllm._h3_flashinfer_C")) - ext_modules.append(CMakeExtension(name="vllm._h3_flashattn_C")) - ext_modules.append(CMakeExtension(name="vllm._sm70_sparse_attention_C")) + # These five are pybind11 modules, which cannot be built against the + # limited API, so CMake defines them WITH_SOABI but without USE_SABI + # and they carry the full SOABI suffix. Declared limited-API, an + # in-place (editable) build copies an .abi3.so that was never built. + for soabi_module in ( + "vllm._sm70_exact_reduce_C", + "vllm._h3_w8a16_C", + "vllm._h3_flashinfer_C", + "vllm._h3_flashattn_C", + "vllm._sm70_sparse_attention_C", + ): + ext_modules.append(CMakeExtension(name=soabi_module, py_limited_api=False)) build_sm70_fa2 = _cuda_arch_contains(7, 0) and not _cuda_arch_at_least(8, 0) if _cuda_arch_at_least(8, 0) or build_sm70_fa2: ext_modules.append(CMakeExtension(name="vllm.vllm_flash_attn._vllm_fa2_C"))