cp: fix(examples): enable ac for phi_4_squad (2634) into r0.5.0#2661
Merged
Conversation
* 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>
Contributor
Author
|
/ok to test 51374f7 |
fix(examples): enable activation checkpointing for phi_4_squad (2634) into r0.5.0fix(examples): enable ac for phi_4_squad (2634) into r0.5.0
HuiyingLi
approved these changes
Jun 20, 2026
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.
Cherry-pick of #2634 (c75d9cf) onto
r0.5.0.Release-branch resolution
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.examples/llm_finetune/phi/phi_4_squad.yaml(activation_checkpointing: true— the OOM fix), theModelSupportsweakref change in_transformers/capabilities.py, and the_release_recipe_memoryhelper in the checkpoint-robustness functional test. All applied cleanly.Verified:
py_compileclean.