xla
xla copied to clipboard
Ported profiler's code from pybind11 to nanobind + threadsafety in FT
Description:
- Ported profiler's code from pybind11 to nanobind
- Added nanobind mutexes to protect PythonHooks and PythonHookContext under free-threading
- Race seen in JAX: https://github.com/jax-ml/jax/actions/runs/14651237353/job/41117294221?pr=28245#step:18:1561
#8 xla::profiler::PythonHookContext::ProfileFast(_frame*, int, _object*) /proc/self/cwd/external/xla/xla/python/profiler/internal/python_hooks.cc:292:25
and
#6 xla::profiler::PythonHookContext::ProfileFast(_frame*, int, _object*) /proc/self/cwd/external/xla/xla/python/profiler/internal/python_hooks.cc:292:25
cc @hawkinsp