jax
044efe82 - Use one MLIR context per Python thread, rather than one per computation.

Commit
124 days ago
Use one MLIR context per Python thread, rather than one per computation. MLIR contexts are not that cheap to create, and currently we create one MLIR context per `jit` we compile. This saves around 5s in the benchmark of `JAX_TEST_NUM_THREADS=64 python tests/api_test.py` on a Cloud TPU under Python 3.14t (no-gil) (27s -> 22s). The main catch here is that certain objects are interned in the context (notably, attributes) and they will grow without bound if we do not free the contexts. As a mitigation for this, we simply bound the number of times a context can be reused at 10. PiperOrigin-RevId: 955934147
Author
Parents
Loading