fix[next]: register jax.core.Tracer for embedded field dispatch on jax >= 0.11 - #2867
Merged
Merged
Conversation
…x >= 0.11 common._field / common._connectivity are functools.singledispatch and the embedded JAX backend registers them for jnp.ndarray (== jax.Array). Since jax 0.11, jax.Array is built by ArrayMeta and Tracer is no longer in its MRO; only isinstance() reports it as a jax.Array. singledispatch resolves on the MRO, so constructing a field from a traced array under jit/grad/scan fell through to the base implementation and raised NotImplementedError. Register jax.core.Tracer explicitly; it is a no-op on older jax where Tracer already subclasses jax.Array. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HVrnd8v75kACJXMcdNovAN
havogt
marked this pull request as ready for review
September 9, 2026 13:20
egparedes
reviewed
Sep 9, 2026
egparedes
left a comment
Contributor
There was a problem hiding this comment.
LGTM. Would it make sense to also bump the minimum required version of jax ?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
common._field/common._connectivityarefunctools.singledispatchfunctions; the embedded JAX backend registers them forjnp.ndarray(which isjax.Array). Since jax 0.11jax.Arrayis built by a metaclass (ArrayMeta) andjax.core.Traceris no longer in its MRO; onlyisinstance()still reports a tracer as ajax.Array, viaArrayMeta.__instancecheck__.singledispatchresolves on the class hierarchy, so constructing a field from a traced array (insidejax.jit,jax.grad,jax.lax.scan, ...) falls through to the base implementation and raises a bareNotImplementedError.Fix: additionally register
jax.core.Tracer. On older jax, whereTraceralready subclassesjax.Array, the extra registration resolves to the same implementation and is a no-op.