[Mlir-commits] [mlir] Added free-threading CPython mode support in MLIR Python bindings (PR #107103)

Stella Laurenzo llvmlistbot at llvm.org
Mon Sep 23 11:12:47 PDT 2024


stellaraccident wrote:

> Can you please detail this statement? I was thinking that we wanted to make python bindings thread-safe for free-threading cpython...

If you want to make them thread-safe, then we will need to add much more locking, likely choosing to use context-scoped locks. The issue is that the underlying MLIR library is thread-compatible but not thread-safe. The GIL is currently making usage from Python more thread safe than MLIR actually is. Concretely, think of two threads attempting to modify the operations in the same function as an example of what would happen without more binding-level locking.

Given the bleeding edge nature of free-threaded Python, I don't think we need to get to thread-safe in one step, but we should document and decide on where we are trying to take things. Then we could document a big warning saying that the library is not presently fully thread safe in [list ways].

I'm supportive of making incremental progress in the right direction, so long as we document where we are trying to get to and are clear with folks what the current safety level is.

https://github.com/llvm/llvm-project/pull/107103


More information about the Mlir-commits mailing list