feat(detection): add handler for remat2 primitive#141
Merged
Conversation
Add support for jax.checkpoint/jax.remat by handling the remat2 primitive. The primitive uses the same "jaxpr" parameter key as jit/pjit, so it reuses the existing prop_closed_jaxpr implementation. Closes #118 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #141 +/- ##
=======================================
Coverage 93.14% 93.14%
=======================================
Files 53 53
Lines 3518 3518
=======================================
Hits 3277 3277
Misses 241 241 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Adds sparsity-detection support for jax.checkpoint / jax.remat by handling the remat2 JAX primitive as a nested-jaxpr call, consistent with how jit/pjit/named_call are already handled in the interpreter.
Changes:
- Dispatch
remat2equations through the existingprop_closed_jaxpr(..., param_key="jaxpr")path. - Add interpreter tests covering checkpoint/remat sparsity, closure-captured indices, and full Jacobian decompression through
jax.checkpoint.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/asdex/detection/_interpret/__init__.py |
Treats remat2 like other closed-jaxpr call primitives by reusing the jaxpr-param propagation handler. |
tests/_interpret/test_nested_jaxpr.py |
Adds regression tests to ensure checkpoint/remat traces correctly for sparsity and decompression, including precise gather tracking with closure-captured indices. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
jax.checkpoint/jax.rematby handling theremat2primitive"jaxpr"parameter key asjit/pjit, so it reuses the existingprop_closed_jaxprimplementationTest plan
test_remat2_checkpoint— sparsity detection through checkpointtest_remat2_closure_captured_index— closure-captured indices resolve preciselytest_remat2_decompression— full Jacobian computation worksCloses #118
🤖 Generated with Claude Code