Skip to content
King Jin

9 November 2026 · ML System reading notes · 1/6

ML System 01: Interfaces, Graphs and the Frontend

I've started working through openmlsys (Machine Learning Systems: Design and Implementation), because I wanted to understand how a line of PyTorch actually turns into work on a GPU. This series is my reading notes, one chapter at a time in the book's order. Part one starts with the layer closest to us: the programming interface a framework gives you, the computational graph it uses to represent a model, and the frontend of the AI compiler.

Programming interface

A modern ML system has to be easy to use and fast at the same time, so almost all of them use Python for the frontend and C/C++ for the backend: you write Python, and the real computation happens underneath.

The framework has to cover the whole workflow, and most of it is exposed as a Python API:

  • Data: loading, importing and preprocessing datasets
  • Models: stacking built-in layers, or writing your own
  • Training: loss functions and optimizers
  • Testing and debugging
  • Low-level extensions: defining your own operators in C++

Computational graph

The computational graph is how a framework represents a model internally. It is a directed acyclic graph: nodes are operators, and tensors flow along the edges. The graph holds both the model's computation and its state. With it, the framework can analyze the model's structure and then optimize it.

There are two ways to build the graph:

Static graphDynamic graph
How it runsbuild the whole graph first, then executebuild as you execute; each line gives a result straight away
Good atefficient compute and memory; can be deployed directlyflexible, easy to debug
Bad athard to debugslower
Use it fordeploymenttuning models, trying new ideas

The graph also records which operators depend on which, and scheduling relies on that:

  • operators run in dependency order;
  • operators that don't depend on each other can run concurrently;
  • training can run synchronously or asynchronously, and asynchronous training keeps the hardware busier and finishes sooner.

The AI compiler frontend

Once the framework has the graph, it hands it to the AI compiler. A compiler has a frontend and a backend; this part only covers the frontend.

  • IR (intermediate representation) is one of the compiler's core data structures: a form of the program that sits between the source language and the target language.
  • Static analysis checks code without running it, using lexical and syntax analysis plus control-flow and data-flow analysis.
  • Compiler optimization cleans up the inefficiencies in the IR the compiler first produces.

The frontend also derives the backward graph from the forward graph automatically, which is automatic differentiation. One thing to keep in mind: every optimization in the frontend is hardware-independent, such as deleting nodes nobody uses. Optimizations for a specific chip are the backend's job, which is the next part.