Skip to content

cp: fix(examples): enable ac for phi_4_squad (2634) into r0.5.0#2661

Merged
HuiyingLi merged 1 commit into
r0.5.0from
cherry-pick-2634-r0.5.0
Jun 20, 2026
Merged

cp: fix(examples): enable ac for phi_4_squad (2634) into r0.5.0#2661
HuiyingLi merged 1 commit into
r0.5.0from
cherry-pick-2634-r0.5.0

Conversation

@akoumpa

@akoumpa akoumpa commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Cherry-pick of #2634 (c75d9cf) onto r0.5.0.

Release-branch resolution

  • Dropped tests/unit_tests/_transformers/test_capabilities_magi.py: this PR only modifies that test, but the file does not exist on r0.5.0 (the magi test was added main-only after the branch cut), so there is nothing to patch.
  • Kept the actual fix: examples/llm_finetune/phi/phi_4_squad.yaml (activation_checkpointing: true — the OOM fix), the ModelSupports weakref change in _transformers/capabilities.py, and the _release_recipe_memory helper in the checkpoint-robustness functional test. All applied cleanly.

Verified: py_compile clean.

* test(checkpoint): reclaim model+optimizer between robustness phases

The checkpoint-robustness test builds a full FSDP2 model + optimizer in every
phase. A bare `del <trainer>` did not reclaim them between phases: the per-part
optimizers are reachable from the model (built over model.parts), so the Adam
state lingered, and ModelSupports pinned the model strongly via model._supports.

- Add `_release_recipe_memory()`: clear optimizer state in place (the Adam
  moments are the bulk) + drop the recipe's model/optimizer/scheduler refs +
  gc, so each phase's state is reclaimed before the next phase allocates its own.
- Hold the model weakly in `ModelSupports` so the capability descriptor can
  never be the reason a multi-GiB model stays resident after its owner is gone.

Memory hygiene only (verified: model + optimizer reclaim to ~0 between phases).
This is NOT the OOM fix — see the activation-checkpointing change.

Signed-off-by: Alexandros Koumparoulis <akoumparouli@nvidia.com>

* fix(examples): enable activation checkpointing for phi_4_squad

phi-4 (14B) stores ~60 GiB of activations per training step; without
recomputation a single forward/backward peaks at ~74 GiB on an 80 GiB H100 and
OOMs on long SQuAD batches. This surfaced in the sft_ckpt_robustness suite,
whose resume phase trains max_steps+3 steps and reliably hits the spike
(steady alloc is a flat ~10 GiB, so it is a per-step activation peak, not a
leak or cross-phase accumulation).

Enabling activation_checkpointing bounds the per-step peak; verified end-to-end
on 8xH100 (EOS): the phi_4_squad checkpoint-robustness test passes
(peak ~70 GiB, no OOM, all phases incl. resume).

Ref (failing CI before the fix):
https://gitlab-master.nvidia.com/dl/JoC/nemo-ci/-/jobs/343744188

Signed-off-by: Alexandros Koumparoulis <akoumparouli@nvidia.com>

---------

Signed-off-by: Alexandros Koumparoulis <akoumparouli@nvidia.com>
(cherry picked from commit c75d9cf)
Signed-off-by: Alexandros Koumparoulis <akoumparouli@nvidia.com>
@akoumpa akoumpa requested a review from a team as a code owner June 20, 2026 02:08
@akoumpa akoumpa added Run CICD Trigger Testing CICD cherry-pick labels Jun 20, 2026
@copy-pr-bot

copy-pr-bot Bot commented Jun 20, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@akoumpa

akoumpa commented Jun 20, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 51374f7

@HuiyingLi HuiyingLi changed the title cp: fix(examples): enable activation checkpointing for phi_4_squad (2634) into r0.5.0 cp: fix(examples): enable ac for phi_4_squad (2634) into r0.5.0 Jun 20, 2026
@HuiyingLi HuiyingLi enabled auto-merge (squash) June 20, 2026 04:07
@HuiyingLi HuiyingLi merged commit 631a49f into r0.5.0 Jun 20, 2026
80 of 82 checks passed
@HuiyingLi HuiyingLi deleted the cherry-pick-2634-r0.5.0 branch June 20, 2026 04:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cherry-pick Run CICD Trigger Testing CICD

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants