Skip to content

Support recomputing in HybridModel - #4496

Merged
xuantengh merged 15 commits into
NVIDIA:mainfrom
xuantengh:xuantengh/ckpt_hybrid
May 14, 2026
Merged

Support recomputing in HybridModel#4496
xuantengh merged 15 commits into
NVIDIA:mainfrom
xuantengh:xuantengh/ckpt_hybrid

Conversation

@xuantengh

@xuantengh xuantengh commented Apr 28, 2026

Copy link
Copy Markdown
Contributor

This PR refactors the recompute procedure in transformer_block.py to share the common logic to hybrid_block.py, enabling recompute in HybridModel, including both full and selective granularity.

For HybridModel, recompute enabled runnings can produce bitwise equal loss curve compared to non-recompute running: wandb.

@copy-pr-bot

copy-pr-bot Bot commented Apr 28, 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.

@Phlip79

Phlip79 commented Apr 28, 2026

Copy link
Copy Markdown
Member

/claude review

Comment thread megatron/core/models/hybrid/hybrid_block.py Outdated

@claude claude Bot 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.

Logic looks correct — the _checkpointed_forward method properly mirrors TransformerBlock._checkpointed_forward adapted for the hybrid layer dispatch, and the test coverage (including numerical equivalence) is solid.

One minor cleanup: the last line of hybrid_block.py has trailing null bytes and a missing EOF newline (editor artifact). See inline comment.

@Phlip79

Phlip79 commented Apr 29, 2026

Copy link
Copy Markdown
Member

/ok to test a4071bf

@xuantengh
xuantengh force-pushed the xuantengh/ckpt_hybrid branch from a4071bf to 554e044 Compare April 30, 2026 06:46
@xuantengh

Copy link
Copy Markdown
Contributor Author

/ok to test 74cf66e

@xuantengh

Copy link
Copy Markdown
Contributor Author

/ok to test d9b3287

@xuantengh xuantengh self-assigned this May 2, 2026
@xuantengh

Copy link
Copy Markdown
Contributor Author

/claude review

@xuantengh
xuantengh marked this pull request as ready for review May 4, 2026 03:27
@xuantengh
xuantengh requested review from a team as code owners May 4, 2026 03:27
@svcnvidia-nemo-ci
svcnvidia-nemo-ci requested a review from a team May 4, 2026 03:27
Comment thread megatron/core/transformer/transformer_block.py Outdated
@xuantengh

Copy link
Copy Markdown
Contributor Author

/ok to test ce3bbbc

@xuantengh xuantengh changed the title Draft: support recomputing in HybridModel Support recomputing in HybridModel May 4, 2026
Comment thread megatron/core/transformer/transformer_block.py Outdated
@xuantengh
xuantengh enabled auto-merge May 12, 2026 05:00
@xuantengh

Copy link
Copy Markdown
Contributor Author

/ok to test b789f96

@xuantengh

Copy link
Copy Markdown
Contributor Author

@jaredcasper kindly reminder for approval

@svcnvidia-nemo-ci svcnvidia-nemo-ci added Approved All necessary approvals have been made and removed Final Review PR is in the "final review" stage labels May 13, 2026
@xuantengh
xuantengh added this pull request to the merge queue May 13, 2026
@svcnvidia-nemo-ci

Copy link
Copy Markdown
Contributor

🔄 Merge queue validation started!

You can track the progress here: https://github.com/NVIDIA/Megatron-LM/actions/runs/25829191438

@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks May 13, 2026
@xuantengh
xuantengh added this pull request to the merge queue May 14, 2026
@svcnvidia-nemo-ci

Copy link
Copy Markdown
Contributor

🔄 Merge queue validation started!

You can track the progress here: https://github.com/NVIDIA/Megatron-LM/actions/runs/25836746510

Merged via the queue into NVIDIA:main with commit 118933a May 14, 2026
79 of 83 checks passed
@xuantengh
xuantengh deleted the xuantengh/ckpt_hybrid branch May 14, 2026 04:51
cspades pushed a commit to cspades/Megatron-LM that referenced this pull request May 14, 2026
janEbert pushed a commit to janEbert/Megatron-LM that referenced this pull request Jun 2, 2026
yhgalaxy pushed a commit to yhgalaxy/Megatron-LM that referenced this pull request Jun 17, 2026
Signed-off-by: yhgalaxy <yhgalaxy@outlook.com>
jon-barker pushed a commit to jon-barker/Megatron-LM that referenced this pull request Jul 10, 2026
Signed-off-by: Jon Barker <jbarker@aws-cmh-slurm-1-vscode-02.cm.cluster>
terminator123 pushed a commit to 021ai/Megatron-LM that referenced this pull request Aug 3, 2026
svcnvidia-nemo-ci pushed a commit to dimapihtar/Megatron-LM that referenced this pull request Aug 4, 2026
Signed-off-by: Dmytro Pykhtar <dpykhtar@nvidia.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Approved All necessary approvals have been made complexity: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants