bridge.models.megatron_mimo.megatron_mimo_builder#
Module Contents#
Functions#
Create HyperCommGrid objects per module from MegatronMIMO parallelism config. |
|
Create embedding-related process groups from globally enumerated PP ranks. |
|
Check if current rank is first stage in pipeline. |
|
Check if current rank is last stage in pipeline. |
Data#
API#
- bridge.models.megatron_mimo.megatron_mimo_builder.EXPERT_VIEW_NAME#
‘expert’
- bridge.models.megatron_mimo.megatron_mimo_builder.build_hypercomm_grids(
- megatron_mimo_parallelism_config: megatron.bridge.models.megatron_mimo.megatron_mimo_config.MegatronMIMOParallelismConfig,
Create HyperCommGrid objects per module from MegatronMIMO parallelism config.
Creates grids on ALL ranks (required for consistent collective calls), but only ranks in each grid’s range will participate in its operations.
Each grid is built with a dense
baseview plus a registeredexpertview over the same rank span. Dense process groups (tp/cp/dp/pp) come from the base view; expert-parallel groups (expt_tp/ep/expt_dp) come from the expert view, matching the contract mcore’sget_mimo_optimizerexpects.- Parameters:
megatron_mimo_parallelism_config – MegatronMIMOParallelismConfig specifying parallelism per module.
- Returns:
Dict mapping module names to their HyperCommGrids.
- bridge.models.megatron_mimo.megatron_mimo_builder.populate_embedding_and_position_groups(
- pp_rank_groups: list[list[int]] | None,
Create embedding-related process groups from globally enumerated PP ranks.
Following MCore semantics:
pos_embd_pg: Only rank 0 of PP (first stage) - for position embeddings
embd_pg: Ranks 0 and -1 of PP (first and last stages) - for tied word embeddings
IMPORTANT: This calls dist.new_group which is a collective operation. Must be called on all ranks that could participate.
- Parameters:
pp_rank_groups – Every pipeline-parallel rank group in global creation order.
- Returns:
Tuple of process groups for the current rank. Returns (None, None) when no pipeline-parallel rank groups are provided.
- bridge.models.megatron_mimo.megatron_mimo_builder.is_pp_first_stage(
- pp_group: Optional[torch.distributed.ProcessGroup],
Check if current rank is first stage in pipeline.
- bridge.models.megatron_mimo.megatron_mimo_builder.is_pp_last_stage(
- pp_group: Optional[torch.distributed.ProcessGroup],
Check if current rank is last stage in pipeline.