A high-throughput and memory-efficient inference and serving engine for LLMs
Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git
Synced Nov 12, 09:45 UTC
[CI/Build]: make it possible to build with a free-threaded interpreter (#29241)
Signed-off-by: Ralf Gommers <ralf.gommers@gmail.com> Co-authored-by: Cyrus Leung <tlleungac@connect.ust.hk>
Ralf Gommers committed
Nov 29, 2025 at 00:21 UTC
7c1ed45848890a06693d36d372d8e8e50cdc9593
2 files changed
+13
-2
cmake/utils.cmake
+7
-1
@@ -495,7 +495,13 @@ function (define_extension_target MOD_NAME)
495
set(SOABI_KEYWORD "")
496
endif()
497
498
- if (ARG_USE_SABI)
498
+ run_python(IS_FREETHREADED_PYTHON
499
+ "import sysconfig; print(1 if sysconfig.get_config_var(\"Py_GIL_DISABLED\") else 0)"
500
+ "Failed to determine whether interpreter is free-threaded")
501
+
502
+ # Free-threaded Python doesn't yet support the stable ABI (see PEP 803/809),
503
+ # so avoid using the stable ABI under free-threading only.
504
+ if (ARG_USE_SABI AND NOT IS_FREETHREADED_PYTHON)
505
Python_add_library(${MOD_NAME} MODULE USE_SABI ${ARG_USE_SABI} ${SOABI_KEYWORD} "${ARG_SOURCES}")
506
else()
507
Python_add_library(${MOD_NAME} MODULE ${SOABI_KEYWORD} "${ARG_SOURCES}")
setup.py
+6
-1
@@ -10,6 +10,7 @@ import re
10
import shutil
11
import subprocess
12
import sys
13
+import sysconfig
14
from pathlib import Path
15
from shutil import which
16
@@ -74,9 +75,13 @@ def is_ninja_available() -> bool:
75
return which("ninja") is not None
76
77
78
+def is_freethreaded():
79
+ return bool(sysconfig.get_config_var("Py_GIL_DISABLED"))
80
+
81
+
82
class CMakeExtension(Extension):
83
def __init__(self, name: str, cmake_lists_dir: str = ".", **kwa) -> None:
79
- super().__init__(name, sources=[], py_limited_api=True, **kwa)
84
+ super().__init__(name, sources=[], py_limited_api=not is_freethreaded(), **kwa)
85
self.cmake_lists_dir = os.path.abspath(cmake_lists_dir)
86
87