mlsysim/README.md
Content may be incomplete or change without notice. The published curriculum lives at <a href="https://mlsysbook.ai"><b>mlsysbook.ai</b></a>.</p>
<p> <a href="https://github.com/harvard-edge/cs249r_book/tree/dev"></a> <a href="https://mlsysbook.ai"></a> </p> </td></tr> </table> </div> <!-- DEV-BANNER-END --> <div align="center"> <h1>๐ MLSysยทim: The Modeling Platform</h1> <blockquote> <b>The physics-grounded analytical simulator powering the Machine Learning Systems ecosystem.</b>Provides a unified "Single Source of Truth" (SSoT) for modeling systems from sub-watt microcontrollers to exaflop-scale global fleets.
mlsysim implements a "Progressive Lowering" architecture, separating high-level workloads from the physical infrastructure that executes them.
mlsysim is designed as an Infrastructure-as-Code (IaC) Compiler for ML systems. It features a stunning terminal UI for humans and a strict JSON API for CI/CD pipelines and AI agents.
Discover built-in hardware, models, and infrastructure without reading source code: <kbd>mlsysim zoo hardware</kbd>
<kbd>mlsysim zoo models</kbd>
Evaluate the physics of a workload on a specific hardware node instantly: <kbd>mlsysim eval Llama3_8B H100 --batch-size 32</kbd>
Define your entire cluster and SLA constraints in a declarative mlsys.yaml file:
# example_cluster.yaml
version: "1.0"
workload:
name: "Llama3_70B"
batch_size: 4096
hardware:
name: "H100"
nodes: 64
ops:
region: "Quebec"
duration_days: 14.0
constraints:
assert:
- metric: "performance.latency"
max: 50.0
Then compile and evaluate the 3-lens scorecard (Feasibility, Performance, Macro): <kbd>mlsysim eval example_cluster.yaml</kbd>
Every command supports strict, schema-validated JSON output. If an assert constraint is violated, the CLI returns a semantic Exit Code 3.
# Export the JSON Schema for your IDE or AI Agent
mlsysim schema > schema.json
# Run an evaluation in a CI pipeline
tco=$(mlsysim --output json eval example_cluster.yaml | jq .macro.metrics.tco_usd)
Use the Tier 3 Engineering Engine to automatically find the optimal configuration: <kbd>mlsysim optimize parallelism example_cluster.yaml</kbd>
<kbd>mlsysim optimize placement example_cluster.yaml --carbon-tax 150</kbd>
Because this core powers a printed textbook, we enforce strict Invariant Verification. Every physical constant is traceable to a primary source (datasheet or paper), and dimensional integrity is enforced via pint.
MLSysยทim is designed to be highly modular. Install only what you need:
# Core physics engine only (fastest, smallest footprint)
pip install mlsysim
# Install with the beautiful Terminal UI & YAML support
pip install "mlsysim[cli]"
# Install with dependencies for interactive labs (Marimo, Plotly)
pip install "mlsysim[labs]"
The framework is just as powerful inside a Python script or Jupyter Notebook. The SystemEvaluator provides a clean, unified entry point for full-stack analysis:
import mlsysim
# 1. Define the scenario
model = mlsysim.Models.Language.Llama3_8B
hardware = mlsysim.Hardware.Cloud.H100
# 2. Run the evaluation
evaluation = mlsysim.SystemEvaluator.evaluate(
scenario_name="Llama-3 8B on H100",
model_obj=model,
hardware_obj=hardware,
batch_size=32,
precision="fp16",
efficiency=0.45
)
# 3. View the beautifully formatted scorecard
print(evaluation.scorecard())