You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Enabled freethreading support in MLIR python bindings
WIP freethreading
Added free-threading CPython mode support in Python bindings
- temporarily updated requirements
Added lock on PyGlobals::get and PyMlirContext liveContexts
WIP on adding multithreaded_tests
More tests and added a lock to _cext.register_operation
Updated tests + labelled passing and failing tests
Updated locks and added docs
Docs updates, tests and fixed cmake config issue
Fixed nanobind target in mlir/cmake/modules/AddMLIRPython.cmake
Reverted mlir/test/python/lib/PythonTestModulePybind11.cpp
Removed old data-races stacks and removed fixed tests
Revert some python deps versions
Recoded mlir/test/python/multithreaded_tests.py without pytest
Added a condition to skip running mlir/test/python/multithreaded_tests.py when has GIL
Addressed some of the PR review comments
Updated Python docs and mlir/test/python/multithreaded_tests.py
Updated mlir/test/python/multithreaded_tests.py due to removed lock in ExecutionEngine
Copy file name to clipboardExpand all lines: mlir/docs/Bindings/Python.md
+40
Original file line number
Diff line number
Diff line change
@@ -1187,3 +1187,43 @@ or nanobind and
1187
1187
utilities to connect to the rest of Python API. The bindings can be located in a
1188
1188
separate module or in the same module as attributes and types, and
1189
1189
loaded along with the dialect.
1190
+
1191
+
## Free-threading (No-GIL) support
1192
+
1193
+
Free-threading or no-GIL support refers to CPython interpreter (>=3.13) with Global Interpreter Lock made optional. For details on the topic, please check [PEP-703](https://peps.python.org/pep-0703/) and this [Python free-threading guide](https://py-free-threading.github.io/).
1194
+
1195
+
MLIR Python bindings are free-threading compatible with exceptions (discussed below) in the following sense: it is safe to work in multiple threads with **independent** contexts. Below we show an example code of safe usage:
1196
+
1197
+
```python
1198
+
# python3.13t example.py
1199
+
import concurrent.futures
1200
+
1201
+
import mlir.dialects.arith as arith
1202
+
from mlir.ir import Context, Location, Module, IntegerType, InsertionPoint
0 commit comments