Skip to content

Reduce MimoOptimizer update-success across the world for cross-grid consensus - #5331

Merged
yashaswikarnati merged 1 commit into
NVIDIA:mainfrom
yashaswikarnati:ykarnati/upstream-mimo-optimizer-step-consensus
Jul 23, 2026
Merged

Reduce MimoOptimizer update-success across the world for cross-grid consensus#5331
yashaswikarnati merged 1 commit into
NVIDIA:mainfrom
yashaswikarnati:ykarnati/upstream-mimo-optimizer-step-consensus

Conversation

@yashaswikarnati

Copy link
Copy Markdown
Contributor

MimoOptimizer.step() already reduces found_inf across the world (MAX), but the final update-success flag from step_with_ready_grads() was only ANDed across this rank's per-module optimizers. For encoder/LLM on disjoint grids that lets ranks disagree on whether the step succeeded, desynchronizing LR scheduling.

This adds a world ReduceOp.MIN on the success flag, mirroring the found_inf reduction, so every rank agrees. Uses the torch.distributed world group (no parallel_state reads).

Part of the NMFW-516 MIMO-on-stock-trainloop series.

cog: per-rank verified green on cw-dfw 8-GPU.

@copy-pr-bot

copy-pr-bot Bot commented Jun 13, 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.

Comment thread megatron/core/models/mimo/optimizer.py Outdated
num_zeros = self.count_zeros() if self.config.log_num_zeros_in_grad else None
success = self.step_with_ready_grads()

# Cross-grid consensus: encoder and LLM may live on disjoint grids, so the

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

comment here is very verbose

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Trimmed to one line: # Reduce update success across the world (MIN) so disjoint-grid ranks agree. (d254c96)

@pytest.mark.skipif(
torch.cuda.device_count() < 2, reason="Cross-grid step consensus requires at least 2 ranks."
)
def test_step_success_is_world_min_consensus():

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

overall tests surface is overkill for what we added.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Slimmed to the single MIN-consensus case (dropped the trivial all-ranks-agree test). (d254c96)

@yashaswikarnati
yashaswikarnati force-pushed the ykarnati/upstream-mimo-optimizer-step-consensus branch from 0cf56a0 to d254c96 Compare June 14, 2026 00:38
@yashaswikarnati
yashaswikarnati marked this pull request as ready for review June 17, 2026 00:26
@yashaswikarnati
yashaswikarnati requested review from a team as code owners June 17, 2026 00:26
@svcnvidia-nemo-ci svcnvidia-nemo-ci added Final Review PR is in the "final review" stage complexity: low labels Jun 17, 2026
@yashaswikarnati

Copy link
Copy Markdown
Contributor Author

/ok to test d254c96

@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 Jun 25, 2026
MimoOptimizer drives encoder and LLM optimizers that may live on disjoint
process-group grids. found_inf is already reduced across the world with MAX
before the early return, but the final update-success flag from
step_with_ready_grads() was only an AND across this rank's per-module
optimizers and not world-consistent. Encoder-grid and LLM-grid ranks could
therefore disagree on whether the step succeeded, desynchronizing LR
scheduling. Reduce success over the world with ReduceOp.MIN, mirroring the
existing found_inf reduction, so every rank agrees.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: ykarnati <ykarnati@nvidia.com>
@yashaswikarnati
yashaswikarnati force-pushed the ykarnati/upstream-mimo-optimizer-step-consensus branch from 7dc3565 to 7efb912 Compare July 21, 2026 23:16
@yashaswikarnati

Copy link
Copy Markdown
Contributor Author

/ok to test 7efb912

@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/29951552469

@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/29960717151

@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/29968252811

Merged via the queue into NVIDIA:main with commit cc5b092 Jul 23, 2026
89 checks passed
@yashaswikarnati
yashaswikarnati deleted the ykarnati/upstream-mimo-optimizer-step-consensus branch July 23, 2026 02:20
shjwudp pushed a commit to shjwudp/Megatron-LM that referenced this pull request Jul 30, 2026
…onsensus (NVIDIA#5331)

Signed-off-by: ykarnati <ykarnati@nvidia.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
terminator123 pushed a commit to 021ai/Megatron-LM that referenced this pull request Aug 3, 2026
…onsensus (NVIDIA#5331)

Signed-off-by: ykarnati <ykarnati@nvidia.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
svcnvidia-nemo-ci pushed a commit to dimapihtar/Megatron-LM that referenced this pull request Aug 4, 2026
…onsensus (NVIDIA#5331)

Signed-off-by: ykarnati <ykarnati@nvidia.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
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: low

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants