Skip to content

Conversation

mattjj
Copy link
Collaborator

@mattjj mattjj commented Oct 13, 2025

I believe all remaining failures are expected.

Thanks to #32470 for exposing these!

I believe all remaining failures are expected.

Co-authored-by: Yash Katariya <[email protected]>
@mattjj mattjj requested a review from yashk2810 October 13, 2025 19:48
@mattjj mattjj self-assigned this Oct 13, 2025
@mattjj mattjj added the pull ready Ready for copybara import and testing label Oct 13, 2025
Copy link

Summary of Changes

Hello @mattjj, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request delivers a series of targeted fixes and improvements primarily focused on enhancing the stability and correctness of JAX's automatic differentiation (vjp3) and mutable array handling. It addresses several subtle bugs, particularly those related to float0 types and the interaction of mutable arrays with JAX's tracing and batching mechanisms, ensuring more reliable gradient computations and state management within the framework.

Highlights

  • Zero Class Enhancement: Added an instantiate method to the Zero class for creating zero-filled arrays based on their abstract values.
  • vjp3 Primal Canonicalization: Ensured primal values in _vjp3 are canonicalized, improving consistency.
  • Mutable Array Refinements: Adjusted assertions and error handling for mutable array references, particularly concerning float0 types.
  • AD Interpreter Context Fix: Corrected the application of context managers in the AD interpreter for ref_primitive operations.
  • Batching for Mutable Arrays: Introduced a new helper matchaxis2 and updated _addupdate_vmap to use it for more robust batching.
  • Specialized addupdate Partial Evaluation: Implemented a dedicated partial evaluation rule for addupdate_p to handle tangent operations and rematerialization more precisely.
  • Test Suite Updates: Enhanced existing tests and added specific checks to validate float0 behavior and pjit sharding in backward passes.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a series of fixes for bugs related to vjp3 and mutable arrays, which were exposed by a recent change. The changes span across automatic differentiation utilities, core interpreters, and state primitives, improving correctness and robustness, especially concerning float0 types and partial evaluation rules. The test modifications also enhance their reliability. My main feedback is on a broad exception handler that could be made more specific to avoid hiding potential future bugs.

Comment on lines +1398 to +1399
try: args[i]._refs._buf._replace_with(o) # type: ignore
except AttributeError: pass # TODO(mattjj): remove float0

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using a broad except AttributeError: pass can be risky as it might silence unexpected errors. While the TODO comment provides context about float0, it would be safer to make the check more specific if possible. For instance, you could check if the argument is of a type that is known not to have the _refs attribute, like float0 arrays. If a specific check is not feasible, consider adding a log warning within the except block to aid in debugging any future, unrelated AttributeErrors that might be suppressed here.

@copybara-service copybara-service bot merged commit 51701b0 into jax-ml:main Oct 13, 2025
23 of 25 checks passed
@mattjj mattjj deleted the vjp3-accum-bug-fixes branch October 13, 2025 22:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kokoro:force-run pull ready Ready for copybara import and testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants