Skip to main content

Analytical models of ML systems

Performance, cost, and carbon, estimated from first principles before any hardware is provisioned.

Open source · v0.3.1 · Companion to the Machine Learning Systems textbook

MLSys·im is an analytical modeling framework for the stage before hardware is benchmarked or provisioned. It makes the first-order constraints explicit (memory, compute, network, data, reliability, cost, and carbon), which narrows the design space and shows which experiments are worth running.

Get Started →

pip install mlsysim

372 physics formulas

278 solvers and optimizers

103 sourced hardware specs

44 reference workloads

Start from the system question

Each of the four questions below maps to a solver. The analytical answer comes first; the sensitive parameters are then validated on the real stack once hardware is available.

Memory fit

Estimate weights, activations, optimizer state, KV cache, and communication buffers before a job fails at runtime.

The binding constraint

Separate compute, memory bandwidth, network communication, data input, reliability, cost, and carbon constraints.

Serving capacity

Size serving replicas for a QPS and p99 target, including batching and queueing assumptions.

Design-space sweeps

Sweep batch size, precision, parallelism, efficiency, geography, and hardware without needing cluster access.

A first analysis in five lines

from mlsysim import Engine, Models, Hardware

profile = Engine.solve(
    model=Models.Vision.ResNet50,
    hardware=Hardware.Cloud.A100,
    batch_size=1,
    precision="fp16",
    efficiency=1.0,
)

print(f"Bottleneck: {profile.bottleneck}")
print(f"Latency:    {profile.latency.to('ms'):~.2f}")
print(f"Throughput: {profile.throughput.to('1/s'):~.0f}")
Bottleneck: Memory
Latency:    0.54 ms
Throughput: 1843 / s

The engine applies the roofline model [1]: a step takes at least as long as its compute time or its memory-transfer time, whichever is larger.

\[T = \max\!\left(\frac{\text{FLOPs}}{\text{Peak} \times \eta},\ \frac{\text{Bytes}}{\text{BW}}\right) + T_{\text{overhead}}\]

At batch 1 on the theoretical ceiling (\(\eta = 1.0\)), ResNet-50’s arithmetic intensity is 146 FLOP/byte, just under the A100’s ridge point of 153 FLOP/byte. The memory term (0.028 ms) edges out the compute term (0.026 ms), though both are small next to the fixed dispatch overhead of 0.515 ms. The 0.54 ms total is mostly overhead, which is why batching helps so much here. Start from the Model Zoo and Silicon Zoo, or define a custom workload and hardware target.

What MLSys·im models

Every solver takes typed registry objects and returns an analytical estimate with units attached.

Validate the approximation

The outputs are analytical estimates, not measurements. Use them to narrow the design space, expose assumptions, and choose the next experiment.

  • Check feasibility first. If memory, network, or data movement is infeasible analytically, benchmarking will not rescue the design.
  • Calibrate efficiency. Compute-heavy solvers expose an efficiency parameter. The defaults are literature-informed starting points; replace them with measured MFU or sustained throughput once those measurements exist.
  • Compare regimes. The most reliable conclusions are binding constraints, crossover points, and sensitivity rankings.
  • Escalate fidelity deliberately. Pick the few configurations worth validating with profiling, traces, or production load tests.

See the accuracy and validation guide for how the solvers compare with published measurements.

Learn by doing

All tutorials →

Built for

Companion material

MLSys·im pairs with the Machine Learning Systems textbook. The lecture slides for Volume I and Volume II cover the concepts; the MLSys·im tutorial slides walk from a single-node roofline to fleet-scale carbon analysis. For course planning, see the teaching guide.

Cite MLSys·im

Coursework, research, or infrastructure analysis that uses MLSys·im should cite it as shown below. The textbook has its own citation for work that draws on the book or the course materials.

@software{mlsysim2026,
  author       = {Janapa Reddi, Vijay},
  title        = {{MLSys$\cdot$im}: First-Principles Infrastructure Modeling for Machine Learning Systems},
  year         = {2026},
  url          = {../mlsysim},
  version      = {0.3.1},
  institution  = {Harvard University}
}

Part of the MLSysBook Ecosystem

Back to top

References

[1]
S. Williams, A. Waterman, and D. Patterson, “Roofline: An insightful visual performance model for multicore architectures,” Communications of the ACM, vol. 52, no. 4, pp. 65–76, 2009, doi: 10.1145/1498765.1498785.