Simplify JAX compat: use jax.make_jaxpr and aval helpers#137
Merged
chaoming0625 merged 8 commits intomainfrom Mar 7, 2026
Merged
Simplify JAX compat: use jax.make_jaxpr and aval helpers#137chaoming0625 merged 8 commits intomainfrom
chaoming0625 merged 8 commits intomainfrom
Conversation
… enhance error callback functionality
…rts and functions for clarity
Contributor
Reviewer's GuideThis PR simplifies JAX version handling and compatibility utilities by removing a custom internal make_jaxpr implementation, centralizing axis/aval helpers in _compatible_import, updating call sites to use those helpers, and tightening debug callback behavior ordering. Sequence diagram for updated StatefulFunction.make_jaxpr pathsequenceDiagram
actor User
participant StatefulFunction
participant jax_make_jaxpr as JaxMakeJaxpr
participant wrapped_fun_to_eval as WrappedFun
User->>StatefulFunction: make_jaxpr(*args, **kwargs)
StatefulFunction->>StatefulFunction: build cache_key, static_kwargs
StatefulFunction->>WrappedFun: functools.partial(_wrapped_fun_to_eval, cache_key, static_kwargs)
StatefulFunction->>JaxMakeJaxpr: jax.make_jaxpr(partial_fun, static_argnums, axis_env, return_shape=True)(*args, **dyn_kwargs)
JaxMakeJaxpr-->>StatefulFunction: jaxpr, (out_shapes, state_shapes)
StatefulFunction->>StatefulFunction: cache jaxpr, out_shapes, state_shapes
StatefulFunction-->>User: stateful jaxpr representation
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Member
Author
|
@sourcery-ai title |
Contributor
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- Now that
_make_jaxprand their_optimizationshandling are removed in favor ofjax.make_jaxpr, consider cleaning up any remaining references/configuration aroundself.ir_optimizationsto avoid dead or misleading options. - The change to
jax.debug.callback(err_fun, *args, **kwargs, ordered=True)assumes theorderedkeyword is available in all supported JAX versions; if older versions are still supported, you may want to guard this with a version check or fall back whenorderedis not accepted.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Now that `_make_jaxpr` and the `ir_optimizations` handling are removed in favor of `jax.make_jaxpr`, consider cleaning up any remaining references/configuration around `self.ir_optimizations` to avoid dead or misleading options.
- The change to `jax.debug.callback(err_fun, *args, **kwargs, ordered=True)` assumes the `ordered` keyword is available in all supported JAX versions; if older versions are still supported, you may want to guard this with a version check or fall back when `ordered` is not accepted.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
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.
Summary by Sourcery
Simplify JAX integration by removing a custom make_jaxpr implementation and aligning with newer JAX APIs, while centralizing version-dependent utilities in the compatibility layer.
Enhancements:
Tests: