Install MLSys·im and run a first analysis in under 5 minutes.
NotePrerequisites
MLSys·im assumes basic Python familiarity (variables, functions, pip install). No prior ML or hardware knowledge is required. Key concepts like roofline analysis, memory-bound vs. compute-bound, and FLOP/s are explained in context throughout the tutorials. For a full reference of terms, see the Glossary.
Installation
MLSys·im requires Python 3.10+ and installs with pip:
pip install mlsysim
For development or to follow along with tutorials locally:
Tutorials are pure Python and run in any Python 3.10+ environment. The local workflow is the supported path for the current release and matches the commands used throughout the documentation.
A First Analysis
For a map of Engine, specialized solvers, and scenarios, see Choosing a Python API. The example below uses the generic single-device Roofline model.
Once MLSys·im is installed, a complete roofline analysis takes five lines. The roofline model is the foundation of ML systems performance reasoning. It determines whether a workload is limited by compute (arithmetic units) or memory (data movement). For a visual walkthrough, see the Hardware Acceleration slide deck (Vol I, Ch 11).
import mlsysimfrom mlsysim import Engine# 1. Load a model and hardware from the vetted Zoomodel = mlsysim.Models.Vision.ResNet50hardware = mlsysim.Hardware.Cloud.A100# 2. Solve -- the Engine applies the roofline modelprofile = Engine.solve(model=model, hardware=hardware, batch_size=1, precision="fp16", efficiency=1.0)# 3. Read the resultsprint(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 output above is produced by running the code when this page is built, so it always matches the installed version of MLSys·im.
NoteWorking with units
MLSys·im uses the Pint library for physical units. All quantities carry attached units (ms, GB, TFLOP/s, etc.). Use .to('ms') to convert between units. Use .magnitude to extract the raw number for calculations or plotting.
Understanding the Output
Engine.solve() returns a PerformanceProfile, a structured result containing everything the roofline model can determine about the workload.
Core fields
Field
What it means
bottleneck
'Memory' or 'Compute': which resource limits performance
latency
Time to process one batch: the roofline bound plus fixed overhead
throughput
Samples per second = batch_size / latency
latency_compute
Time if only compute were the constraint
latency_memory
Time if only memory bandwidth were the constraint
latency_overhead
Fixed dispatch and kernel-launch time added on top of the roofline bound
arithmetic_intensity
Operations per byte, the x-axis of the roofline plot
Extended fields
Field
What it means
energy
Estimated energy consumption (Joules)
memory_footprint
Total memory required for the workload
mfu
Model FLOPs Utilization, the fraction of peak compute achieved
feasible
Whether the workload fits in device memory
TipThe key insight
If latency_memory > latency_compute, the workload is memory-bound, and faster arithmetic units will not help. The remedies are to increase batch size, use a more compute-dense operation (e.g., fused attention), or reduce data movement. When the workload is compute-bound, parallelism and quantization pay off.
MLSys·im ships with vetted registries of hardware, models, infrastructure, and systems, with source metadata where available. Use tab-completion to explore.
# Language modelsmlsysim.Models.Language.GPT2mlsysim.Models.Language.Llama3_8Bmlsysim.Models.Language.Llama3_70B# Vision modelsmlsysim.Models.Vision.ResNet50mlsysim.Models.Vision.MobileNetV2mlsysim.Models.Vision.AlexNet# Tiny / edge modelsmlsysim.Models.Tiny.DS_CNNmlsysim.Models.Tiny.WakeVision
Infrastructure
Regional grids and datacenter configurations for sustainability analysis:
# Regional power grids -- carbon intensity varies by energy sourcefor grid in ( mlsysim.Infrastructure.Grids.Quebec, mlsysim.Infrastructure.Grids.US_Avg, mlsysim.Infrastructure.Grids.Poland,):print(f"{grid.name:28s} ({grid.primary_source}): {grid.carbon_intensity_g_kwh:.0f} gCO2/kWh")
Quebec (Hydro) (hydro): 20 gCO2/kWh
US Average (mixed): 429 gCO2/kWh
Poland (Coal) (coal): 820 gCO2/kWh
Always use nested registry paths in Python code (Hardware.Cloud.H100, Models.Vision.ResNet50). The CLI still accepts short names like Llama3_8B and H100. See Provenance & registry paths.
The efficiency parameter (\(\eta\)) is the parameter that most affects MLSys·im results. It represents the fraction of theoretical peak hardware performance that is actually achieved in practice. Unoptimized single-request inference often runs near 5% of peak, whereas well-tuned training and batched serving workloads reach 30%–50%.
Bottleneck: Memory
Latency: 14.44 ms
Feasible: True
The Model Compression slides (Vol I, Ch 10) explain why parameter count and precision together determine both the memory footprint and the arithmetic intensity of a workload.
Companion Slide Decks
MLSys·im is the hands-on companion to the Machine Learning Systems textbook. The concepts modeled with MLSys·im are taught in the Beamer lecture decks for Volumes I and II, which carry speaker notes and in-class exercises.
Follow the structured learning path on the Tutorials page, starting with the Hello, Roofline Tutorial. Each tutorial pairs with a companion slide deck for visual explanations and active learning exercises.
For a complete reference of which solver to use for different questions, see the Solver Guide.