Skip to content

Backport PR #205 on branch versions/v0.3.x (🐛 fix(compat): don't reintroduce scan_p's removed linear param) - #207

Merged
nstarman merged 2 commits into
versions/v0.3.xfrom
auto-backport-of-pr-205-on-versions/v0.3.x
Aug 4, 2026
Merged

Backport PR #205 on branch versions/v0.3.x (🐛 fix(compat): don't reintroduce scan_p's removed linear param)#207
nstarman merged 2 commits into
versions/v0.3.xfrom
auto-backport-of-pr-205-on-versions/v0.3.x

Conversation

@nstarman

@nstarman nstarman commented Aug 4, 2026

Copy link
Copy Markdown
Owner

Manual backport of #205 (MrMeeseeks reported a conflict).

Conflict resolution

versions/v0.3.x never had the linear handling at all — the rebuild was introduced on main by #189 ("support multi-leaf Values and empty scans"), which was not backported. So the conflict is main's two-commit history vs. this branch's plain pass-through.

Resolved by taking the net effect of #205 on scan_bind_params only:

The cherry-pick would also have dragged in unrelated main-only changes to _compat.py (import reordering, dropping the JAX_GE_0_7_0 / pjit_p fallback, comment rewraps). Those are excluded — this branch still supports jax>=0.5.3 and Python 3.10, where the pjit_p fallback is required.

Note on scope

This branch was not hit by the weekly-CI failure that motivated #205: its pass-through never added linear, so TypeError: _scan_abstract_eval() got an unexpected keyword argument 'linear' does not occur here (verified — scan tests pass on versions/v0.3.x @ b365e08 with jax==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 the linear-present path), scan tests: 9 passed.

🤖 Generated with Claude Code

nstarman and others added 2 commits August 4, 2026 17:09
)

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>
@nstarman

nstarman commented Aug 4, 2026

Copy link
Copy Markdown
Owner Author

Fixed the CI failure in 3d011d0.

It was the pre-existing tests/usage/test_unitful.py::test_integer_pow_units_and_values_agree failure noted above, failing on every job (all Python versions, oldest and newest deps) — not the scan change:

ValueError: Comparator raised exception while sorting pytree dictionary keys.
  └── TypeError: '<' not supported between instances of 'Dimension' and 'Dimension'

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 ({meters: 1, seconds: -1}) can't be constructed. Single-dimension values are fine — a 1-element sort makes no comparisons — which is why only this one test trips it. main doesn't hit it because its _FastModuleMeta.__call__ bypasses that equinox flatten.

Fix: Dimension.__lt__ comparing names, so the sort has a total order.

Verified on Python 3.11 / jax==0.10.2: full suite 968 passed, 137 skipped, 58 xfailed, 6 xpassed (was 1 failed / 967 passed). Also passes on --resolution lowest-direct / Python 3.10.

@nstarman
nstarman merged commit 37e61da into versions/v0.3.x Aug 4, 2026
12 checks passed
@nstarman
nstarman deleted the auto-backport-of-pr-205-on-versions/v0.3.x branch August 4, 2026 21:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant