Fix provenance tracking for closed-over constants on JAX 0.11.1 - #2245
Conversation
Benchmark reportthis PR run time: unchanged across 32 benchmarks
compile time: unchanged across 32 benchmarksNo significant changesEvery benchmark stayed within ±5% run time and ±25% compile time. Red is slower, green is faster; a row is coloured by the worse of its two columns. A delta in parentheses cleared the threshold on a measurement below the resolution floor, so it is shown without being called a change. † marks a benchmark that could not be compared — see below. Full results
|
| baseline | this PR | |
|---|---|---|
| ref | master |
fix/jax-hoisted-provenance-constants |
| commit | 26cc211a |
d34087fd |
| numpyro | 0.21.0 | 0.21.0 |
| jax | 0.11.1 | 0.11.1 |
| backend | cpu | cpu |
| python | 3.14.7 | 3.14.7 |
Runner: Linux-6.17.0-1022-azure-x86_64-with-glibc2.39, 4 CPUs.
Produced by this benchmark run.
Yes. NumPyro currently declares jax>=0.7.0, so I tested the current PR at that supported lower bound as well as on JAX 0.11.1.
Both runs include the new closed-over-constant regression. The production change uses the public jax.make_jaxpr API, which is available at the 0.7.0 lower bound, so no version-specific production path is needed. |
Fixes #2244.
Changes made
trace_to_jaxpr_dynamiccall with the publicjax.make_jaxprtracing API.call_jaxprbinding protocol.Why
JAX 0.11.1 hoists constants returned by
trace_to_jaxpr_dynamicintojaxpr.invars. NumPyro then paired those invars with provenance values built only from explicit keyword arguments, causing a length mismatch whenever a traced function closed over an array.jax.make_jaxprpreserves the distinction between constants and explicit inputs through its public API. Constants therefore retain empty provenance while tracked keyword arguments remain aligned withjaxpr.invars. This also removes a direct dependency on JAX's private partial-evaluation API.Tests
pytest -q test/ops test/infer/test_inspect.py test/infer/test_svi.py— 415 passed, 4 skipped.pytest -q test/ops/test_provenance.py— 11 passed.ruff check .ruff format . --checkpython scripts/update_headers.py --checkty check numpyro/ops/provenance.py test/ops/test_provenance.pyDependencies
No new dependencies.