-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Seeing what happens if we get rid of positional effects #33425
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Summary of ChangesHello @dougalm, 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 fundamentally refactors how Highlights
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this 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 experiments with removing positional information from effects by removing input_index from JaxprInputEffect. This is a significant and wide-ranging change that simplifies code across many modules, removing the need for complex effect re-numbering logic in various transformations like vmap, jit, and control flow primitives. The changes look consistent with the goal of making effects non-positional.
However, I found a critical issue in jax/_src/state/discharge.py where the logic for propagating effects from a run_state call seems to have been completely removed, causing it to incorrectly report no effects. This could lead to incorrect effect analysis for functions that use run_state.
jax/_src/state/discharge.py
Outdated
| pass | ||
| inner_to_outer_aval_mapping[i] = outer_ref_index | ||
| outer_ref_index += 1 | ||
| nonlocal_effects = set() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic for propagating effects from the run_state jaxpr seems to have been completely removed. This results in nonlocal_effects always being an empty set, which is incorrect as run_state should propagate effects from its body, especially for non-discharged refs.
With the removal of positional effects, we can no longer map effects to specific input refs. A reasonable approach would be to over-approximate: if there are any non-discharged Ref inputs, all RefEffects from the inner jaxpr should be propagated. Non-RefEffects should always be propagated.
I suggest restoring a simplified version of the effect propagation logic. The is_ref variable on the next line will become unused and can be removed separately.
| nonlocal_effects = set() | |
| nonlocal_effects = jaxpr.effects if any(isinstance(aval, AbstractRef) for aval in avals) else {e for e in jaxpr.effects if not isinstance(e, RefEffect)} |
60215a7 to
1801635
Compare
1801635 to
161b183
Compare
No description provided.