Skip to content

The System the Solutions Build

The reference solutions build one system, called forge, and grow it in passes. This page is the map you will come back to throughout the course: what the components are, which language each is written in, where its solution lives, and the contracts where the components meet. Every contract is a file in course/contracts/. The solution implements those files, and any component can be replaced by another implementation that meets the same contract.

After Pass 1, every layer of the final system exists in its thinnest form. The table lists each component with its solution directory and the section that explains it:

ComponentLanguageSolutionWhat it doesExplained in
optional C exercisesCc/src/standalone kernels and data structures, specified by C headers and shared fixturesOptional standalone C kernels, Vectors, matrices, and matmul, and the data structures from A growable array to Heap top-k in C
tinyllmPythonpython/tinyllm/the byte bigram fitted by counting, safetensors v0, tokenizer files, the tinyllm CLIByte bigram
tl-serveRustrust/crates/a Candle engine streaming SSE completions from safetensors checkpoints, with one OTLP span per requestYour first endpoint
gatewayGogo/gateway/proxy/, entry/go/cmd/gatewayAPI-key check, SSE pass-through without buffering, traceparent and X-Request-IdThe tracer gateway, One trace
deployDocker, Helm, kindentry/deploy/engine and gateway images, charts, a kind cluster with NodePorts 30080 and 30686, JaegerTracer deploy
docsMarkdowndocs/ADR-0001, the engine-crashloop runbook, postmortemsArchitecture decision records, First drill
CIGitHub Actionsentry/.github/workflows/ci.yml, entry/.githooks/commit lint and native tests for every languageThe repository and its CI gate

The diagram shows how a request and the model’s files move between those components:

flowchart LR
  U["curl / OpenAI SDK"] -- "HTTP + key (openai-subset v0)" --> GW["gateway (Go)"]
  GW -- "HTTP SSE + traceparent" --> EN["tl-serve (Rust)"]
  PY["tinyllm CLI (Python)"] -- "model.safetensors + config.json" --> EN
  PY -- "tokenizer.json + fixtures" --> EN
  GW -- "OTLP/HTTP JSON" --> J["Jaeger"]
  EN -- "OTLP/HTTP JSON" --> J

Notice that Python and Rust exchange data only through files: safetensors checkpoints, tokenizer.json, and shared fixtures. No language boundary in the system uses FFI. ADR-0001 records why: in-process bindings would couple memory ownership and failure behavior across runtimes, while files with versioned schemas and parity fixtures let each language own its memory and errors and let each service be built, tested, and restarted on its own.

Those boundaries are only useful if they are written down. The contracts the tracer depends on, and the sections that first read or write them, are:

ContractFileUsed from
C exercise contractsc/include/tinyllm.h, tinyllm/abi.h, tinyllm/matmul.h, rules in c/ABI.mdthe optional standalone C sections
C test kitc/include/ol_test.hthe C example tests
Python interfacespy/tinyllm/ (lm/bigram.pyi, io/safetensors.pyi)Byte bigram
HTTP API v0openapi/openai-subset.v0.yamlYour first endpoint (engine tier), The tracer gateway (gateway tier)
Checkpointformats/safetensors.md, formats/config.schema.jsonwritten by Byte bigram, read by Your first endpoint
Tokenizerformats/tokenizer.md (the bytes tokenizer)both of the above
Entry pointsspec/cli-roles.mdevery role the system starts
System manifestconfig/system.schema.jsonhow a system declares its build steps and the command for each role
Decision recordtemplates/ADR.mdArchitecture decision records

After every pass the system runs end to end: a request enters at the gateway, reaches a model the Python side trained, and leaves a trace. Later sections do one of two things. Most upgrade a component behind an unchanged contract; the bigram retrained by autograd in Pass 2, for example, still serves through the same checkpoint and the same engine. The rest change a contract, and they do it through an explicit migration. Because every pass keeps the earlier end-to-end paths working, a regression anywhere shows up as a broken path you already understood.

The table traces how each contract grows across the passes:

ContractHow it grows
the model behind the checkpointcount bigram (Pass 1), autograd bigram (Pass 2), the transformer family (Pass 5), the Llama family served by the engine (Pass 7 on)
standalone C kernelsoptional exercises, whose outputs are compared with the Python reference’s outputs for the same inputs
HTTP openai-subsetv0 completions with SSE (Pass 1), v1 with chat, usage, and tools (Pass 7), the v2 migration (Pass 11)
gatewayproxy (Pass 1); auth, limits, routing, cache, and ledger (Pass 7); usage policy (Pass 10)
deploytwo charts and Jaeger (Pass 1), per-role charts and the observability stack (Pass 7), durable workers (Pass 8)