Skip to content

Python 3.14t: C extension missing Py_MOD_GIL declaration causes GIL re-enable warningΒ #8491

@kdt2014

Description

@kdt2014

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.libtriton

Output:

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions