Reduce MimoOptimizer update-success across the world for cross-grid consensus - #5331
Conversation
| 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 |
There was a problem hiding this comment.
comment here is very verbose
There was a problem hiding this comment.
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(): |
There was a problem hiding this comment.
overall tests surface is overkill for what we added.
There was a problem hiding this comment.
Slimmed to the single MIN-consensus case (dropped the trivial all-ranks-agree test). (d254c96)
0cf56a0 to
d254c96
Compare
|
/ok to test d254c96 |
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>
7dc3565 to
7efb912
Compare
|
/ok to test 7efb912 |
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA/Megatron-LM/actions/runs/29951552469 |
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA/Megatron-LM/actions/runs/29960717151 |
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA/Megatron-LM/actions/runs/29968252811 |
…onsensus (NVIDIA#5331) Signed-off-by: ykarnati <ykarnati@nvidia.com> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
…onsensus (NVIDIA#5331) Signed-off-by: ykarnati <ykarnati@nvidia.com> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
…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>
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.