Repository navigation
Add activation-checkpoint state tracking - #720
Merged
Merged
Conversation
Adds `nn/moe/v2/checkpointing.py`: thread-local depth tracking that reports whether execution is inside an activation-checkpoint forward or a recompute, so checkpointed MoE forwards can avoid repeating metric side effects on recompute. Pure-Python (threading + contextlib + torch), no MoE/model coupling. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
- Add a module docstring and docstrings on the non-trivial public functions. - Use the builtin `tuple` annotation instead of `typing.Tuple`. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Cover the forward/recompute context depth tracking (including nesting and reset), is_activation_checkpointing, and the get_rowwise_checkpoint_state save-on-forward / skip-on-recompute behavior. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
Drop the `_torch_compile_disable` AttributeError-fallback shim and decorate the state helpers with `@torch.compiler.disable` directly, matching the rest of the codebase (it's available on all supported torch versions). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
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.
Adds
nn/moe/v2/checkpointing.py: thread-local depth tracking for activation checkpointing.It reports whether execution is currently inside a checkpointed forward or a recompute (via re-entrant
checkpoint_forward_context/checkpoint_recompute_contextcontext managers), and exposesget_rowwise_checkpoint_state()returning(checkpointing_active, save_for_recompute)— so a checkpointed MoE forward can save outputs on the initial pass but avoid repeating metric side effects when it is recomputed in backward.Pure-Python (
threading+contextlib+torch), no MoE/model coupling. Includes CPU unit tests covering the depth tracking (nesting + reset) and the save-on-forward / skip-on-recompute behavior.🤖 Generated with Claude Code