Skip to main content

Design Space Exploration (DSE)

Declaratively navigate trade-offs without writing nested for-loops.

analysis
advanced
Learn how to use the DSE Engine to search parameter grids and optimize ML system architectures based on cost and performance SLA constraints.

The Question

Optimizing an ML system often involves navigating complex trade-offs: choosing between Tensor Parallelism (TP) and Pipeline Parallelism (PP), or deciding whether a larger batch size improves throughput without violating a strict 50ms latency SLA.

Building a real system requires searching a vast grid of possibilities, evaluating the analytical constraints of each point, and ranking the configurations by a target objective. How do we explore this design space cleanly, without writing messy nested loops?

NoteLearning Objectives
  • Define a declarative SearchSpace of system parameters.
  • Formulate optimization objectives (e.g., minimize: EconomicsModel.tco_usd).
  • Execute an exhaustive search using the DSE engine.
  • Filter configurations based on HBM feasibility and step-latency SLA constraints.

1. Setup

Import the necessary classes. The DSE (Design Space Explorer) is the Tier 3 engine that wraps around any Tier 1 analytical model.

import mlsysim
from mlsysim.engine.dse import DSE
from mlsysim.solvers import DistributedModel, EconomicsModel
from mlsysim.engine.pipeline import Pipeline

2. Defining the Evaluation Function

The search first needs a function that evaluates a given configuration point. It uses the Pipeline from Composable Pipelines & Callbacks to chain distributed performance and economics, rejecting configurations whose per-GPU shard exceeds HBM capacity (node_profile.feasible == False).

# Fixed baseline constants: 1,024 H100 GPUs across 128 DGX H100 nodes on InfiniBand NDR
model = mlsysim.Models.Language.Llama3_70B
fleet = mlsysim.Systems.Clusters.Training_1K

# The evaluation function accepts a dictionary of parameters and returns a structured object
def evaluate_config(params):
    pipe = Pipeline([DistributedModel(), EconomicsModel()])
    res = pipe.run(
        model=model,
        fleet=fleet,
        batch_size=params["batch_size"],
        tp_size=params["tp"],
        pp_size=params["pp"],
        microbatch_count=16,
        precision="fp16",
        efficiency=0.45,
        duration_days=30
    )
    if not res["DistributedModel"].node_profile.feasible:
        raise ValueError("Model shard exceeds per-GPU HBM")
    return res

This baseline pairs Llama-3.1-70B (70.6B parameters) with Training Cluster (1024 GPUs) (1,024 accelerators across 128 nodes).

4. Applying SLA Constraints

Maximizing raw throughput selects Batch=4096, pushing per-step latency past 10 seconds. Passing declarative constraints to DSE enforces hard step-latency (<= 6000 ms) and scaling-efficiency (>= 0.65) bounds without changing the evaluator:

dse_sla = DSE(
    space=space,
    objective="maximize: DistributedModel.effective_throughput",
    constraints=[
        "DistributedModel.step_latency_total <= 6000.0",
        "DistributedModel.scaling_efficiency >= 0.65",
    ],
)
sla_result = dse_sla.search(evaluate_config)

print("Top SLA-Compliant Configurations (Step <= 6,000 ms, Efficiency >= 65%):")
print(f"{'TP':>4} | {'PP':>4} | {'Batch':>6} | {'Throughput':>12} | {'Step Time':>10} | {'Efficiency':>10}")
print("-" * 62)

for candidate in sla_result["top_candidates"][:3]:
    p = candidate["params"]
    dist_res = candidate["result"]["DistributedModel"]

    throughput = dist_res.effective_throughput.to("1/s").magnitude
    latency = dist_res.step_latency_total.to("ms").magnitude

    print(f"{p['tp']:>4} | {p['pp']:>4} | {p['batch_size']:>6} | {throughput:>12,.1f} | {latency:>8,.1f}ms | {dist_res.scaling_efficiency:>9.1%}")
Top SLA-Compliant Configurations (Step <= 6,000 ms, Efficiency >= 65%):
  TP |   PP |  Batch |   Throughput |  Step Time | Efficiency
--------------------------------------------------------------
   8 |    2 |   2048 |        371.9 |  5,507.3ms |     70.8%
   8 |    4 |   2048 |        363.1 |  5,640.7ms |     69.1%
   8 |    4 |   1024 |        342.3 |  2,991.8ms |     65.2%

Enforcing the 6-second step budget shifts the optimal choice to TP=8, PP=2, Batch=2048, retaining 371.9 samples/sec while cutting step latency nearly in half.


Where This Clicks in the Textbook

Vol I · Ch 2Design Space

Frames ML systems engineering as constrained multi-objective optimization across latency, cost, and quality.

Vol II · Ch 8Resource Allocation

Maps declarative SLA constraints and Pareto trade-offs onto heterogeneous cluster hardware.

Vol IV · Ch 13Onboard vs. Cloud

Extends design-space search to partitioning perception and planning across robot compute and cloud links.

Next Steps

Back to top