Skip to content

[Refactor] Unify SAC checkpointing and GLM DSA dataflow - #2039

Open
jayhenry wants to merge 4 commits into
InternLM:mainfrom
jayhenry:refactor/sac-checkpoint-dsa-dataflow
Open

[Refactor] Unify SAC checkpointing and GLM DSA dataflow#2039
jayhenry wants to merge 4 commits into
InternLM:mainfrom
jayhenry:refactor/sac-checkpoint-dsa-dataflow

Conversation

@jayhenry

Copy link
Copy Markdown
Collaborator

Summary

  • Unify activation checkpointing around one PyTree-aware reentrant boundary so structured micro-batch inputs and outputs stay on the real autograd and offload path.
  • Pass GLM DSA top-k IDs explicitly through decoder and MTP outputs, removing the mutable SequenceContext cache lifecycle.
  • Reuse frozen source-indexer results from checkpoint-local FIFO frames during replay.
  • Keep FSDP wrappers outside recompute and dense checkpoint boundaries outside compiled graphs.

Regression coverage

  • compile + top-k offload + shared-weight MTP with depth > 1; validates pinned-memory offload and restore, and that the source indexer is not recomputed
  • EP > 1 + intra-layer micro-batch 2
  • FSDP checkpointing, torch.compile, FP8, activation offload, and nested PyTree inputs and outputs

Validation

  • Post-rebase on latest upstream/main: 16 passed
    • tests/model/test_recompute.py
    • tests/model/test_glm52_mtp_checkpoint_repro.py
    • tests/model/test_fsdp_checkpoint.py
  • Qwen3.5 full 40-layer stack5 regression: step losses and grad norms matched upstream; steady sequence TGS +0.36%; peak allocated memory -0.14 GB.
  • GLM AdamW production-shaped and Muon EP2/micro2 training regressions completed.

Flatten structured inputs and outputs at one checkpoint boundary so nested MTP micro-batch tensors receive gradients. Keep FSDP outside replay and remove the non-reentrant MTP switch.
Move GLM-specific decoder and MTP adapters under the model package, thread DSA IDs through keyed outputs, and remove SequenceContext cache lifecycle state. Share one saved-tensor offload window for activation and DSA ID storage.
Keep reusable no-grad outputs in checkpoint-call-local FIFO frames, freeze DSA indexers through their model config, and preserve the original int32 storage across shared layers and offload. Add real regressions for source call counts and pinned-memory DSA offload.
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.

1 participant