solvers.ParallelismOptimizer
solvers.ParallelismOptimizer()Searches for the optimal 3D/4D parallelism split (DP, TP, PP, EP).
Given a model architecture and a cluster size, this optimizer sweeps the integer design space of parallelism degrees to find the configuration that maximizes Model FLOPs Utilization (MFU).
Literature Source: 1. Narayanan et al. (2021), “Efficient Large-Scale Language Model Training on GPU Clusters Using Megatron-LM.”
Methods
| Name | Description |
|---|---|
| solve | Search for the parallelism split (TP x PP x DP) that maximizes MFU. |
solve
solvers.ParallelismOptimizer.solve(
model,
fleet,
batch_size,
precision='fp16',
efficiency=0.5,
max_tp=None,
max_pp=None,
overlap_comm=True,
seq_len=2048,
activation_recomputation=False,
)Search for the parallelism split (TP x PP x DP) that maximizes MFU.
Exhaustive sweep over power-of-two TP and PP degrees with TP * PP * DP = total_accelerators. TP is capped at the node size by default (tensor parallelism needs NVLink-class bandwidth). Candidates are pre-screened for memory feasibility — per-GPU weights plus same-size gradients must fit in 90% of HBM capacity, with weights sharded by TP*PP — then each survivor is priced with DistributedModel, dropped if its replica’s training state (activations included) does not fit, and ranked by MFU = scaling_efficiency * efficiency. Pipelined candidates use one-sample microbatches (microbatch_count = per-replica batch), the schedule that minimizes both the bubble and in-flight activations.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| model | Workload | The model to train. | required |
| fleet | Fleet | The cluster (total accelerators, node size, fabric). | required |
| batch_size | int | Global batch size in samples. | required |
| precision | str | Numerical precision. | 'fp16' |
| efficiency | float | Single-node software efficiency in (0, 1]; multiplied by the distributed scaling efficiency to form the MFU objective. | 0.5 |
| max_tp | int | Cap on tensor-parallel degree (default: accelerators per node). | None |
| max_pp | int | Cap on pipeline-parallel degree (default: cluster size). | None |
| overlap_comm | bool | Whether DP communication overlaps the backward pass. | True |
| seq_len | int | Tokens per sample, for step FLOPs and activation memory. | 2048 |
| activation_recomputation | bool | Whether replicas recompute activations (full recomputation). | False |
Returns
| Name | Type | Description |
|---|---|---|
| ParallelismOptimizerResult | Best {tp, pp, dp} config with its MFU, throughput, step time, and the top-5 candidate list. |
Raises
| Name | Type | Description |
|---|---|---|
| ValueError | If no factorization is memory-feasible for this cluster. |
See Also
DistributedModel.solve : Performance model used to rank each candidate.
Notes
Equation: maximize efficiency * scaling_efficiency over power-of-two TP/PP layouts with integer DP = N/(TP*PP) and EP fixed to one. Assumptions: homogeneous fleet, one-sample pipeline microbatches, and the underlying distributed solver’s communication and memory approximations. Excludes: non-power-of-two layouts, EP search, measured scheduling, and allocator workspace. A feasible winner is feasible only under this model; the weight/gradient pre-screen is followed by full modeled-state checking.
References
Derivation: enumerate the bounded discrete layout set, discard candidates that violate modeled memory capacity, and rank remaining objective values.
Examples
>>> from mlsysim import Models, Systems
>>> result = ParallelismOptimizer().solve(Models.Vision.ResNet50,
... Systems.Clusters.Research_256, batch_size=256, max_tp=1, max_pp=1)
>>> result.best_config["tp"] == 1
True