Skip to content

feat: support reentrant checkpoint exclusions - #67

Merged
github-actions[bot] merged 1 commit into
mindspore-ai:masterfrom
DavidFFFan:sync/pr-1290
Nov 9, 2026
Merged

github-actions[bot] merged 1 commit into
mindspore-ai:masterfrom
DavidFFFan:sync/pr-1290

Conversation

@DavidFFFan

@DavidFFFan DavidFFFan commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

What changed

Build Torch eager reentrant checkpointing on top of #1348's exclude-swap change. The branch has two commits in merge order: the cherry-picked #1348 commit, followed by our reentrant integration. #1348 remains a separate PR and is expected to merge first.

  • The outer forward runs without a full-layer saved_tensors_hooks context. Only excluded regions record a small local autograd graph; their forward operators run once, and replay reuses cached outputs.
  • An excluded region's multi-output input boundary uses a zero-element gradient root. Its local graph no longer retains recomputable input storage through detached activation leaf AccumulateGrad nodes or per-tensor input gradient hooks. Saved input aliases/views are reconstructed from replay inputs; other required tensors can use feat: checkpoint_exclude_swap #1348's optional swap hooks. Excluded outputs are always cached and can be registered with the swap group.
  • Preserve RNG and autocast state, expose the existing function and module use_reentrant=True entry points, and share prefire/session cleanup APIs with non-reentrant checkpoints.
  • Support PP dx/dw split with per-microbatch replay state: dx does not run parameter gradient hooks; dw computes parameter gradients later, using the same replay graph. Ordinary PP and FSDP checkpoint backward also work.
  • Preserve feat: checkpoint_exclude_swap #1348's checkpoint_exclude_wrapper(module, swap=False, group_swap=False, cpu_pool=None) interface and add an eight-card-budget grouped NPU test launcher.

Scope and limitations

Excluded outputs are always cached; there is no save_output switch. The eager reentrant checkpoint itself does not support torch.compile, policy_fn, checkpoint-input swap, non-default early_stop, higher-order differentiation, or nested reentrant checkpoints. The exclude wrapper's swap, group_swap, and cpu_pool options are separate and supported. Ordinary unscoped autograd.grad cannot guarantee that captured parameter gradients are filtered by its requested targets; use non-reentrant checkpointing when that contract is needed. PP dx/dw split combined with FSDP/HSDP, and PP retain_backward_graph=True, remain unsupported; ordinary FSDP backward is supported. The same-rank stage-backed swap/split test does not establish cross-rank PP+swap ordering or transfer-failure recovery.

Validation

  • torch-npu activated on this checkout; relevant CPU UT: 830 passed, 1 skipped, 1 xfailed (activation memory, pipeline, auto-model checkpoint, and fully-shard).
  • Ascend 910B3: MM, grouped MM, and fusion attention loss/dx/dw parity against eager and non-reentrant, RNG/autocast, and memory lifecycle. The eight-card-budget grouped exclude suite passed, including feat: checkpoint_exclude_swap #1348 non-reentrant swap cases and reentrant swap with regular/grouped transfer and pinned-memory pool.
  • Ascend distributed: ordinary FSDP checkpoint/exclude on two cards; PP split/exclude on 2, 4, and 8 cards; same-rank stage-backed swap plus split dx/dw on two cards; existing eight-card PP+HSDP split regression passed.
  • Same-operator input-recipe comparison: forward-end allocated memory fell by approximately 16 MiB; full-step peak fell by approximately 2.9 MiB. These are workload-specific, not general model guarantees.
  • New-code pylint and complexity checks, git diff --check, and agent documentation catalog check passed.

Fixes #1172.

@CLAassistant

CLAassistant commented Sep 11, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@DavidFFFan

Copy link
Copy Markdown
Contributor Author

/retest

@mindspore-ai-bot

Copy link
Copy Markdown

Gate trigger failed: please fix the /check-pr findings and obtain the pr-check-pass label before retrying.

@DavidFFFan

Copy link
Copy Markdown
Contributor Author

/check-pr

@DavidFFFan

Copy link
Copy Markdown
Contributor Author

/check-pr

@DavidFFFan

Copy link
Copy Markdown
Contributor Author

/retest

@mindspore-ai-bot

Copy link
Copy Markdown

Gate trigger failed: please fix the /check-pr findings and obtain the pr-check-pass label before retrying.

@DavidFFFan

Copy link
Copy Markdown
Contributor Author

/retest

@mindspore-ai-bot

Copy link
Copy Markdown

🔵 The pipeline #1513 is running. Please wait a moment... (Link)

@mindspore-ai-bot

Copy link
Copy Markdown
Project Name Build_Stage Build Result Details
Hyper-parallel_Github_Gate - ❌ FAILURE 1513
Check_Lizard FAILURE 1513
Check_Pylint FAILURE 1513

@mindspore-ai-bot

Copy link
Copy Markdown

@DavidFFFan, your gate pipeline failed at the code check stage. You can configure some code check tools locally following the (pre-push quick guide), to enable automatic checking when you push your code every time. Tools included are: Check_CMakelint, Check_Codespell, Check_Cpplint, Check_Lizard, Check_Pylint, Check_ClangFormat, Check_ShellCheck.

@DavidFFFan

Copy link
Copy Markdown
Contributor Author

/check-pr

@DavidFFFan

Copy link
Copy Markdown
Contributor Author

/retest

@mindspore-ai-bot

Copy link
Copy Markdown

🔵 The pipeline #1514 is running. Please wait a moment... (Link)

@mindspore-ai-bot

Copy link
Copy Markdown
Project Name Build_Stage Build Result Details(Full/Incremental) Detail
Coverage Line Coverage ❌ FAILURE 75%/80% Link

@mindspore-ai-bot

Copy link
Copy Markdown
Platform Type Module Excution Time Time Limit
- shard 217.084s 300.0s
- optimizer 356.931s 300.0s
- pipeline_parallel 848.894s 600.0s
- auto_models 124.23s 150.0s
- accuracy 129.635s 120.0s
- dtensor 108.531s 120.0s
- swap_optimizer 356.921s 300.0s
- distributed_checkpoint 88.028s 120.0s
- activation_memory 464.962s 300.0s
- clip_grad 118.747s 120.0s
- fully_shard 429.527s 600.0s
- process_group 103.735s 90.0s
- tensor_parallel 277.846s 300.0s
- init_weights 81.135s 118.75s
- multicore 134.22025s 120.0s
- expert_parallel 185.867s 200.0s
- context_parallel 91.076s 120.0s
- llama3_examples 84.344s 120.0s

@mindspore-ai-bot

Copy link
Copy Markdown
Project Name Build_Stage Build Result Details
Hyper-parallel_Github_Gate - ❌ FAILURE 1514
coverage FAILURE 1514
UT_TEST FAILURE 1514
Smoke_Ascend910b_Torch FAILURE 1514

@DavidFFFan

Copy link
Copy Markdown
Contributor Author

/retest

@mindspore-ai-bot

Copy link
Copy Markdown

🔵 The pipeline #1518 is running. Please wait a moment... (Link)

@mindspore-ai-bot

Copy link
Copy Markdown
Project Name Build_Stage Build Result Details(Full/Incremental) Detail
Coverage Line Coverage ✅ SUCCESS 75%/93% Link

@mindspore-ai-bot

Copy link
Copy Markdown
Platform Type Module Excution Time Time Limit
- activation_memory 460.217s 375.0s
- shard 213.05s 300.0s
- accuracy 123.897s 120.0s
- pipeline_parallel 818.822s 675.0s
- auto_models 116.328s 150.0s
- optimizer 368.421s 300.0s
- fully_shard 381.665s 600.0s
- swap_optimizer 354.015s 300.0s
- expert_parallel 168.13887s 200.0s
- tensor_parallel 268.956s 300.0s
- multicore 131.93187s 120.0s
- clip_grad 104.777s 120.0s
- context_parallel 90.186s 120.0s
- dtensor 93.95s 120.0s
- init_weights 99.141s 118.75s
- llama3_examples 99.16s 120.0s
- process_group 88.872s 90.0s
- distributed_checkpoint 92.743s 120.0s

@mindspore-ai-bot

Copy link
Copy Markdown
Project Name Build_Stage Build Result Details
Hyper-parallel_Github_Gate - ✅ SUCCESS 1518

@liuchongming74 liuchongming74 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@DavidFFFan

Copy link
Copy Markdown
Contributor Author

/check-pr

@github-actions
github-actions Bot merged commit 4a2abbe into mindspore-ai:master Nov 9, 2026
6 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[RFC] Recompute host-performance optimization: support use_reentrant=True

6 participants