Skip to content

Add activation-checkpoint state tracking - #720

Merged
AkshitaB merged 4 commits into
akshitab/moe-v2-corefrom
akshitab/moe-v2-checkpoint-state
Jun 11, 2026
Merged

AkshitaB merged 4 commits into
akshitab/moe-v2-corefrom
akshitab/moe-v2-checkpoint-state

Conversation

@AkshitaB

Copy link
Copy Markdown
Contributor

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_context context managers), and exposes get_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

TianhuaTao and others added 3 commits June 11, 2026 01:33
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]>
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

@AkshitaB AkshitaB changed the title Add MoE-v2 activation-checkpoint state tracking Add activation-checkpoint state tracking Jun 11, 2026
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]>
@AkshitaB
AkshitaB merged commit 7da97e9 into akshitab/moe-v2-core Jun 11, 2026
24 checks passed
@AkshitaB
AkshitaB deleted the akshitab/moe-v2-checkpoint-state branch June 11, 2026 23:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants