Backport PR #205 on branch versions/v0.3.x (🐛 fix(compat): don't reintroduce scan_p's removed linear param) - #207
Conversation
) JAX 0.10.2 dropped `linear` from `scan_p`, but `scan_bind_params`' pre-0.11 branch treated a missing `linear` the same as a misaligned one and injected an all-`False` tuple, so every quaxified `lax.scan` raised `TypeError: _scan_abstract_eval() got an unexpected keyword argument 'linear'` (weekly CI, Python 3.11 / jax 0.10.2). Only rebuild `linear` when it is actually present, preserving behaviour on older JAX that still takes it. Co-authored-by: Claude Opus 5 <noreply@anthropic.com> (cherry picked from commit 9235c44)
Equinox flattens every `Module.__init__` argument, and JAX sorts pytree
dict keys while flattening. `Unitful.units` is a `dict[Dimension, int]`,
so any multi-dimension value (e.g. `{meters: 1, seconds: -1}`) failed to
construct with "Comparator raised exception while sorting pytree
dictionary keys".
Add `Dimension.__lt__` (by name) so the sort has a total order.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
Fixed the CI failure in 3d011d0. It was the pre-existing Equinox flattens every Fix: Verified on Python 3.11 / |
Manual backport of #205 (MrMeeseeks reported a conflict).
Conflict resolution
versions/v0.3.xnever had thelinearhandling at all — the rebuild was introduced onmainby #189 ("support multi-leaf Values and empty scans"), which was not backported. So the conflict ismain's two-commit history vs. this branch's plain pass-through.Resolved by taking the net effect of #205 on
scan_bind_paramsonly:linearwhen it is present and the operand count changed (the fix: scan support for multi-leaf Values and length-0 scans #189 fix this branch lacks — quaxifying can change the flat operand count, and a stale per-operand tuple makes JAX's scan rules raise);linearwhen JAX no longer takes it (the 🐛 fix(compat): don't reintroducescan_p's removedlinearparam #205 fix; JAX 0.10.2 dropped the parameter).The cherry-pick would also have dragged in unrelated
main-only changes to_compat.py(import reordering, dropping theJAX_GE_0_7_0/pjit_pfallback, comment rewraps). Those are excluded — this branch still supportsjax>=0.5.3and Python 3.10, where thepjit_pfallback is required.Note on scope
This branch was not hit by the weekly-CI failure that motivated #205: its pass-through never added
linear, soTypeError: _scan_abstract_eval() got an unexpected keyword argument 'linear'does not occur here (verified — scan tests pass onversions/v0.3.x@ b365e08 withjax==0.10.2). The backport keeps the two branches consistent and brings the operand-count-misalignment guard across.Verification
All on Python 3.11:
jax==0.10.2, scan tests: 9 passed.jax==0.10.2, full suite:1 failed, 967 passed, 137 skipped, 58 xfailed, 6 xpassed. The one failure,tests/usage/test_unitful.py::test_integer_pow_units_and_values_agree, is pre-existing on b365e08 with this JAX (confirmed on the unmodified base) and unrelated to scan.jax==0.6.2(exercises thelinear-present path), scan tests: 9 passed.🤖 Generated with Claude Code