Skip to main content

The 6-Layer Architecture

Progressive Lowering: From Abstract Demand to Concrete Supply

MLSys·im organizes the full ML systems domain into six composable layers. Abstract workload demand (Layer A) is progressively mapped onto concrete hardware, infrastructure, distributed systems, and cyber-physical platforms (Layers B–D and F) through analytical solvers (Layer E). Each layer corresponds directly to chapters in the Machine Learning Systems textbook and its companion lecture slides.

Understanding this stack is the foundation for working with both this library and the textbook it accompanies.

The Stack at a Glance

%%{init: {'theme': 'neutral'}}%%
%%| fig-cap: "The MLSys·im 6-Layer Stack. Workloads (demand) are lowered onto Hardware, Infrastructure, Systems, and Embodied platforms (supply). Solvers bridge demand and supply to produce typed analytical profiles."
%%| fig-width: 100%
flowchart TB
    A["<b>Layer A · Workloads</b> — <i>Demand</i><br/>Transformer · SparseTransformer · CNN · SSM · Diffusion · Embodied<br/>Parameters · FLOPs · Arithmetic Intensity"]
    B["<b>Layer B · Hardware</b> — <i>Silicon</i><br/>HardwareNode · ComputeCore · MemoryHierarchy<br/>Peak FLOP/s · Bandwidth · Capacity · TDP"]
    C["<b>Layer C · Infrastructure</b> — <i>Environment</i><br/>GridProfile · Datacenter<br/>Carbon Intensity · PUE · WUE"]
    D["<b>Layer D · Systems</b> — <i>Topology</i><br/>Node · Fleet · NetworkFabric<br/>Topology · Accelerators/Node · Fabric BW"]
    F_emb["<b>Layer F · Embodied &amp; Physical AI</b> — <i>Cyber-Physical</i><br/>Embodied · Sensors · Actuators · Agents<br/>Stopping Envelopes · Control Loops · Safety Leases"]
    E["<b>Layer E · Solvers</b> — <i>Analysis</i><br/>SingleNode · Distributed · Serving<br/>Economics · Sustainability · Robotics · Agents"]
    R["<b>Results</b><br/>PerformanceProfile · AnalyticalResult (*Result)"]

    A --> E
    B --> D
    C --> D
    D --> E
    F_emb --> E
    E --> R

    style E fill:#e0f2fe,stroke:#0284c7,stroke-width:2px

The flow reads top-to-bottom: a Workload (the computation to perform) and a System (the available hardware, network, and environment) feed into a Solver (the analytical engine), which returns quantitative results that can guide a design decision.

NotePhysics formulas

Closed-form equations live in mlsysim.physics.* (performance, memory, communication, serving, economics, reliability, robotics, and fundamental physical constants in mlsysim.physics.constants). Pint units live in mlsysim.core.units; chip, model, scenario, and system specs live only in their registries (the legacy core/constants.py catch-all module was retired). See Math Foundations.

NoteTwo views of the same package

The six layers are the runtime view: how demand meets supply through solvers. The registries that populate Layers A–D and Layer F are organized as twelve zoos (Hardware, Models, Datasets, Platforms, Infrastructure, Systems, Ops, Scenarios, Embodied, Sensors, Actuators, Agents) plus support namespaces. That data view is documented in DATA_MODEL.md. Both descriptions are true at different altitudes.


Layer A: Workloads (Demand)

A Workload is a hardware-agnostic description of computational demand. It states how many FLOPs and memory bytes Llama-3 requires, not how fast Llama-3 runs.

MLSys·im provides six concrete workload types (plus the base Workload class):

  • TransformerWorkload: Dense LLMs and attention-based models (GPT, Llama, BERT). Defined by parameter count, layer count, hidden dimension, attention/KV heads, and sequence length. Supports KV-cache size estimation for autoregressive inference.
  • SparseTransformerWorkload: Mixture-of-Experts (MoE) Transformers (Mixtral, DeepSeek) with total vs. active parameter accounting and expert-routing metadata.
  • CNNWorkload: Vision and convolutional models (ResNet, MobileNet, YOLO). Defined by parameter count and total FLOPs per forward pass.
  • SSMWorkload: State-space sequence models (Mamba) with recurrent state sizing independent of context length.
  • DiffusionWorkload: Multi-step iterative denoising architectures (Stable Diffusion, DiT).
  • EmbodiedWorkload: Vision-Language-Action (VLA) and sensorimotor policies operating under closed-loop control deadlines.

The key step comes when a workload is “lowered” at a specific numerical precision (FP32, FP16, INT8, INT4). This precision lowering determines the Arithmetic Intensity (FLOPs/Byte), the single ratio that decides whether a model will be compute-bound or memory-bound on any given hardware target.

NoteTextbook, labs, and slides

Layer A concepts are covered in the following chapters:

Chapter · Study Sheet · Slides Topic Key Concepts
Vol I · Ch 5: Neural Computation (Study sheet · Slides) The math behind the model FLOPs, parameter counting, activation memory, forward/backward pass cost
Vol I · Ch 6: Network Architectures (Study sheet · Slides) Architecture as infrastructure Computational signatures of CNNs, SSMs, Transformers; quadratic attention scaling
Vol I · Ch 10: Model Compression (Study sheet · Slides) From benchmark winner to production model Pruning, distillation, group quantization (FP32 to INT4); precision as a workload knob
Vol I · Ch 8: Model Training (Study sheet · Slides) The physics of learning Training memory breakdown (weights, gradients, optimizer states, activations)

See the Model Zoo for vetted workloads spanning language, vision, state-space, generative vision, recommendation, embodied policy, and TinyML models.


Layer B: Hardware (Silicon)

A HardwareNode represents a single physical accelerator, such as an H100 GPU, an Apple M3 chip, a Jetson Orin, or even an ESP32 microcontroller. It provides the raw physical supply:

  • Compute: Peak throughput (TFLOP/s) across precisions (FP32, FP16, INT8), modeled via ComputeCore.
  • Memory: HBM or SRAM capacity and transfer bandwidth (TB/s), modeled via MemoryHierarchy.
  • Power: Thermal Design Power (TDP) in watts.

Every piece of silicon has a ridge point, the ratio of peak compute to memory bandwidth (\(I^* = \text{Peak\_FLOPs} / \text{BW}\)). When a workload’s arithmetic intensity falls below this ridge point, the workload is memory-bound: the compute units starve waiting for data. When above, the workload is compute-bound: memory delivers data faster than the cores can consume it.

This is the Roofline model, the diagnostic framework at the heart of Layer E’s SingleNodeModel.

NoteTextbook, labs, and slides

Layer B concepts are covered in the following chapters:

Chapter · Study Sheet · Slides Topic Key Concepts
Vol I · Ch 11: Hardware Acceleration (Study sheet · Slides) Moving data costs more than computing it Systolic arrays, tensor cores, Roofline model, accelerator spectrum (GPU to ASIC)
Vol II · Ch 2: Compute Infrastructure (Study sheet · Slides) The physics of the ML fleet HBM generations, bandwidth hierarchy (HBM to NVLink to InfiniBand), TCO analysis
Vol I · Ch 12: Benchmarking (Study sheet · Slides) Measuring what matters MLPerf, roofline profiling, statistical rigor, the lab-to-production gap

See the Silicon Zoo for 56 vetted hardware specs from cloud GPUs to microcontrollers.


Layer C: Infrastructure (Environment)

Hardware does not run in a vacuum. It runs in datacenters plugged into regional power grids, cooled by air or liquid systems, and constrained by physical energy budgets.

A GridProfile captures this physical context:

  • Carbon intensity (g CO₂/kWh) varies about 41× across regions. Quebec’s hydroelectric grid produces about 20 g CO₂/kWh; Poland’s coal-dominated grid produces about 820 g CO₂/kWh.
  • Power Usage Effectiveness (PUE) is the ratio of total facility power to IT equipment power. A PUE of 1.1 means 10% overhead for cooling and infrastructure; 1.6 means 60%.
  • Water Usage Effectiveness (WUE) is the liters of on-site cooling water consumed per kWh of IT equipment energy (\(E_{\text{IT}} \times \text{WUE}_{\text{site}}\)), determined by cooling technology (closed-loop air/liquid vs. evaporative towers).

A 1000-watt GPU running identical computations in Quebec versus Poland produces vastly different carbon footprints. This layer makes that difference quantifiable.

NoteTextbook, labs, and slides

Layer C concepts are covered in the following chapter:

Chapter · Study Sheet · Slides Topic Key Concepts
Vol II · Ch 15: Sustainable AI (Study sheet · Slides) Energy as a first-class engineering constraint Lifecycle carbon accounting, PUE & WUE modeling, carbon-aware scheduling

See the Infrastructure Zoo for regional grid profiles and datacenter configurations.


Layer D: Systems (Topology)

A single GPU cannot train a 100-billion-parameter model. Layer D composes individual HardwareNodes from Layer B into distributed clusters, connected by the network fabrics that determine communication overhead.

Core system types include:

  • Node: A single compute server grouping accelerators within a physical chassis (e.g., 8x H100 GPUs connected by 450 GB/s per-direction / 900 GB/s bidirectional NVLink). Includes one-way intra_node_bw and NIC count.
  • RackProfile: A physical rack composition that aggregates node count, accelerator count, accelerator power, and non-accelerator support power.
  • NetworkFabric: The inter-node interconnect: topology (fat-tree, rail-optimized), bandwidth (e.g., 400 Gbps InfiniBand NDR), latency, and oversubscription ratio.
  • Fleet: A collection of Nodes connected by a NetworkFabric, deployed in a specific Datacenter (Layer C). This is the complete system that solvers operate on.

The structure of this system (how many GPUs each node holds, what fabric connects them, and which parallelism strategy runs across them) determines its communication overhead and scaling efficiency.

NoteTextbook, labs, and slides

Layer D concepts span four chapters covering the distributed systems stack:

Chapter · Study Sheet · Slides Topic Key Concepts
Vol II · Ch 3: Network Fabrics (Study sheet · Slides) The synchronization backbone \(\alpha\)-\(\beta\) model, topology (fat-tree, dragonfly), RDMA, bisection bandwidth
Vol II · Ch 5: Collective Communication (Study sheet · Slides) The traffic patterns of distributed ML AllReduce algorithms (ring, tree, hierarchical), computation-communication overlap
Vol II · Ch 6: Distributed Training (Study sheet · Slides) The physics of scaling DP/TP/PP/EP, ZeRO/FSDP, Communication-Computation Ratio (CCR), 4D hybrid strategies
Vol II · Ch 8: Fleet Orchestration (Study sheet · Slides) Extracting useful work from shared infrastructure Slurm vs. Kubernetes, topology-aware scheduling, elastic training, multi-tenancy

See the Fleet Zoo for production cluster topologies from 256-GPU research clusters to 8192-GPU frontier fleets.


Layer E: Solvers (Analysis)

The previous four layers are static definitions, the nouns of the stack. Solvers are its verbs: the analytical engines that bridge demand and supply to answer specific questions.

Each solver implements closed-form equations from peer-reviewed systems literature. They require no simulation, no benchmarking, and no hardware.

Solver Bridges Core Equation Key Output
SingleNodeModel A \(\to\) B Roofline / Iron Law (Williams et al., 2009) Latency, throughput, bottleneck classification
DistributedModel A \(\to\) D Ring All-Reduce + Pipeline schedules Scaling efficiency, communication overhead, bubble fraction
ServingModel A \(\to\) B Pre-fill / Decode phase decomposition TTFT, inter-token latency, KV-cache memory
EconomicsModel D \(\to\) cost CapEx + OpEx over time horizon TCO in USD, cost per query
SustainabilityModel D \(\to\) C PUE \(\times\) grid carbon intensity Energy (kWh), carbon (kg CO₂e), water (L)
ReliabilityModel D \(\to\) uptime Young-Daly optimal checkpointing Fleet MTBF, failure probability, checkpoint interval

Solvers are composable. To find the most sustainable way to serve Llama-70B, chain ServingModel (feasibility and latency) into EconomicsModel (cost) into SustainabilityModel (carbon). Each solver’s typed output feeds naturally into the next.

NoteTextbook, labs, and slides

Layer E concepts draw from multiple chapters that teach the diagnostic and optimization frameworks:

Chapter · Study Sheet · Slides Topic Key Concepts
Vol I · Ch 11: Hardware Acceleration (Study sheet · Slides) The Roofline model Arithmetic intensity, ridge points, memory-bound vs. compute-bound diagnosis
Vol I · Ch 13: Model Serving (Study sheet · Slides) Inverting every training priority Latency budgets, queuing theory (Little’s Law), continuous batching
Vol II · Ch 9: Fleet Efficiency (Study sheet · Slides) Match the software to the silicon Operator fusion, FlashAttention SRAM IO, mixed precision, profiling workflow
Vol II · Ch 10: Serving at Scale (Study sheet · Slides) Where ML systems live or die economically Serving economics, PagedAttention KV-cache, disaggregation, autoscaling
Vol II · Ch 6: Distributed Training (Study sheet · Slides) Scaling efficiency analysis Communication-Computation Ratio, parallelism strategy selection, scaling laws

See the Solver Guide for a decision guide on choosing the right solver, and Math Foundations for the complete equations.


Layer F: Embodied & Physical AI

Physical and agentic AI systems couple neural inference to real-time control loops, sensors, actuators, and tool-use environments:

  • Embodied, Sensors, and Actuators: Quadrupeds, humanoids, manipulators, drones, AMRs, autonomous vehicles, cameras, LiDARs, IMUs, safety scanners/light curtains, harmonic drives, quasi-direct drives, and safety relays.
  • Agents: Multi-step tool-calling, deliberation, coding, research, and remediation harnesses with context-window and verification economics.
  • mlsysim.physics.robotics & mlsysim.solvers: Closed-form stopping-distance envelopes, kinematic limits, sensor-fusion timing budgets, thermal/battery endurance, and safety assurance bounds.

Progressive Lowering in Action

The architecture is best understood through a concrete example. Consider the question: “Can I serve INT4 Llama-3-70B replicas across a 4-H100 node within a target annual budget while minimizing carbon?”

This single question touches Layers A–E (with Layer F extending the same pattern when an inference loop drives an agent harness or robot controller):

1. Layer A — Llama-3-70B workload: 70.6B parameters, GQA with 8 KV heads,
             ~141 GB at FP16 (~35 GB raw INT4)

2. Layer B — H100 hardware: 989 TFLOP/s (FP16), 3.35 TB/s HBM3,
             80 GiB capacity, 700 W TDP

3. Layer C — Infrastructure: choose between Quebec (20 g CO₂/kWh)
             and US Average (429 g CO₂/kWh)

4. Layer D — System: 1 node × 4 H100s (or sharded TP across NVLink 900 GB/s via DistributedModel)

5. Layer E — Chain solvers:
             ServingModel / ServingCapacityModel → single-GPU TTFT, ITL, KV feasibility & replica count
             EconomicsModel → TCO over 1 year
             SustainabilityModel → carbon & water footprint by region

Each layer contributes a different piece of the answer. No single layer is sufficient alone. This is why MLSys·im separates concerns into six composable layers rather than offering a monolithic “predict performance” function.


Curriculum Quick Reference

For instructors and students using the companion textbook, study sheets, and lecture slides, the tables below map every MLSys·im layer to its primary chapters (browse the full Cross-Volume Textbook Map for all chapters).

Volume I: Foundations

Ch Chapter · Study Sheet · Slides MLSys·im Layer(s)
5 Neural Computation (Study sheet · Slides) A (Workloads)
6 Network Architectures (Study sheet · Slides) A (Workloads)
8 Model Training (Study sheet · Slides) A + B + E
10 Model Compression (Study sheet · Slides) A + E
11 Hardware Acceleration (Study sheet · Slides) B (Hardware) + E (Solvers)
12 Benchmarking (Study sheet · Slides) B (Hardware) + E (Solvers)
13 Model Serving (Study sheet · Slides) E (Solvers)

Volume II: Scaling

Ch Chapter · Study Sheet · Slides MLSys·im Layer(s)
2 Compute Infrastructure (Study sheet · Slides) B (Hardware) + E
3 Network Fabrics (Study sheet · Slides) D (Systems)
5 Collective Communication (Study sheet · Slides) D (Systems)
6 Distributed Training (Study sheet · Slides) D (Systems) + E (Solvers)
7 Fault Tolerance (Study sheet · Slides) D (Systems) + E (Solvers)
8 Fleet Orchestration (Study sheet · Slides) D (Systems)
9 Fleet Efficiency (Study sheet · Slides) E (Solvers)
10 Serving at Scale (Study sheet · Slides) E (Solvers)
15 Sustainable AI (Study sheet · Slides) C (Infrastructure) + E

Where to Go Next

  • Getting Started: Install MLSys·im and run a first analysis in 5 minutes.
  • Cross-Volume Textbook Map: Connect every chapter across Volumes I–IV to its companion solvers, tutorials, and labs.
  • Solver Guide: Decision guide for choosing the right analytical engine.
  • Math Foundations: The closed-form equations behind every solver.
  • Tutorials: Hands-on notebooks for roofline analysis, distributed training, LLM serving, and sustainability.
  • Zoo Overview: Browse the registries of vetted hardware, embodied systems, agents, models, fleets, and infrastructure.
Back to top