Skip to content

On-the-fly trace-time DCE using Python ref counting #30062

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

Merged
merged 24 commits into from
Jul 11, 2025

Conversation

dougalm
Copy link
Collaborator

@dougalm dougalm commented Jul 8, 2025

We're in the process of replacing jvp+partial-eval with direct linearization which means using DynamicJaxprTrace instead of JaxprTrace to stage the forward tangent computation to a Jaxpr. But JaxprTrace had an unintentional feature that some people have come to rely on: on-the-fly trace-time DCE. Partial eval would build up a DAG of operations instead of a list of eqns, and unreachable parts of the graph would get pruned implicitly. This PR adds the same sort of logic to DynamicJaxprTrace using weak refs so we don't cause a regression.

@dougalm dougalm requested a review from mattjj July 8, 2025 15:20
@dougalm dougalm force-pushed the auto-dce-dynamic-jaxpr-trace branch 5 times, most recently from 6560dd6 to 449d084 Compare July 8, 2025 19:27
@google-ml-butler google-ml-butler bot added kokoro:force-run pull ready Ready for copybara import and testing labels Jul 8, 2025
@dougalm dougalm force-pushed the auto-dce-dynamic-jaxpr-trace branch from 60d3378 to 921e6fe Compare July 9, 2025 18:39
@mattjj mattjj force-pushed the auto-dce-dynamic-jaxpr-trace branch 3 times, most recently from d0f1a10 to e5a70ff Compare July 10, 2025 23:40
@mattjj mattjj force-pushed the auto-dce-dynamic-jaxpr-trace branch from e5a70ff to 8980220 Compare July 10, 2025 23:53
@copybara-service copybara-service bot merged commit d7badca into main Jul 11, 2025
25 checks passed
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