-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Open
Description
Description
Triton 3.5.0 provides binary wheels for Python 3.14t (free-threaded build), but the C extension module triton._C.libtriton does not declare GIL compatibility, causing Python to re-enable the GIL with a warning.
Environment
- Python version: 3.14.0 free-threading build
- Triton version: 3.5.0
- Platform: Linux x86_64
- Installation:
pip install triton(cp314t wheel)
Current Behavior
When importing Triton in Python 3.14t:
import triton._C.libtritonOutput:
RuntimeWarning: The global interpreter lock (GIL) has been enabled to load module
'triton._C.libtriton', which has not declared that it can run safely without the GIL.
Expected Behavior
The C extension should declare its GIL compatibility status using the Py_mod_gil slot in the module definition, as described in PEP 703.
Reproduction Steps
python3.14t -c "import triton._C.libtriton"Suggested Fix
Add the appropriate Py_mod_gil declaration in the C extension module initialization:
static PyModuleDef_Slot module_slots[] = {
{Py_mod_gil, Py_MOD_GIL_NOT_USED}, // or Py_MOD_GIL_USED if needed
{0, NULL}
};Additional Context
- Since Triton already builds and distributes cp314t wheels, adding the GIL declaration would complete the free-threaded support
- This affects users trying to leverage true parallel execution in Python 3.14t
- The warning can be suppressed with
PYTHON_GIL=0, but proper declaration is the correct solution
References
- PEP 703: https://peps.python.org/pep-0703/
- Python 3.14 free-threading docs: https://docs.python.org/3.14/howto/free-threading-extensions.html
marekvasko, Qubitium, kitsuyaazuma, ThomasByr and arnav-garg1kitsuyaazuma, ThomasByr and arnav-garg1
Metadata
Metadata
Assignees
Labels
No labels