B.3 Pass 1: The Tracer
The tracer is a thin system through every layer of the final one, built before any layer is deep. Its model is a byte-level bigram fitted by counting, which is about as simple as a language model can be. But that bigram is written to a real checkpoint, served by a real Rust engine that streams completions over HTTP, fronted by a Go gateway that checks an API key and streams without buffering, packaged as images and Helm charts on a local kind cluster, and observed as one trace across the gateway and the engine in Jaeger. The pass also runs a first incident drill with its runbook and writes a first architecture decision record.
Concepts from other sections (7)
This section uses these ideas. Each has a short definition and a link to the section that explains it in full. Tap a dotted term in the text to preview it.
- Byte-level: the base alphabet is the 256 bytes (through the byte map), so every text encodes and there is no unknown token. Read more: 7.2 Byte-level BPE
- API key: a credential
tl_<id>_<secret>whose public id locates a record and whose secret proves possession. Read more: 10.1 API Keys, Scopes, Model Allowlists, and Tenants in Software Engineering - Helm chart: a directory of templated Kubernetes YAML plus default values; installing it creates a release. Read more: 1.7 Containers and Kubernetes: images, layers, Pods, Deployments, Services, Helm, kind in Programming and Algorithms
- Architecture decision record (ADR): a short, numbered, append-only file recording one hard-to-reverse decision with its context, consequences, and rejected alternatives. Read more: 12.1 Architecture decision records in Software Engineering
- Server-Sent Events (SSE): a
text/event-streambody ofdata: ...events, each terminated by a blank line. Read more: 23.1 Your first endpoint: a std-only Rust HTTP/1.1 + SSE server - Negative log-likelihood (NLL): , the surprise of the true token under the model, in nats. Read more: 17.2 Perplexity, bits per byte, NLL accumulator in Mathematics
- safetensors: a checkpoint format of an 8-byte header length, a JSON header, and raw little-endian row-major tensor bytes. Read more: 6.1 Byte bigram: counts, logits, safetensors v0
Building every layer thinly first is what makes the rest of the course safe. Each later pass deepens one layer behind a contract this pass fixes, and because the whole system already runs end to end, a change that breaks a seam shows up immediately. The pass introduces Python, Rust, HTTP and SSE, Go, and containers as they are needed. C remains optional depth later in the course.
Learning objectives
- Explain how a count-based bigram reaches the maximum-likelihood NLL and how it is written to safetensors.
- Trace an HTTP request and an SSE stream through a hand-written Rust server and a Go streaming proxy.
- Explain how the system is deployed on kind behind Helm charts and NodePorts.
- Explain how trace context propagates so one request shows as one trace.
- Diagnose the engine crashloop drill and explain the decision recorded in ADR-0001.
Before you begin
Section titled “Before you begin”This pass needs Pass 0: a working toolchain and a repository whose CI gate is green. Stages 1 to 7 run as local processes; stages 8 to 11 run on a local kind cluster.
In this pass
Section titled “In this pass”The sections build the system from the model outward, then deploy and observe it:
- Matmul in Python. Afterwards you can explain how the triple-loop Python matmul indexes rows and columns and why it matches numpy on the golden cases.
- Byte bigram. Afterwards you can explain why the count-based bigram reaches the maximum-likelihood NLL and how it is written to a safetensors file.
- Rust. Afterwards you can explain how the Rust echo server serves two clients at once and who owns each connection.
- HTTP and SSE. Afterwards you can trace how an HTTP request is parsed and how an SSE stream is framed by hand.
- Your first endpoint. Afterwards you can trace how the Rust server loads the checkpoint, streams SSE completions, and exports its span.
- Go. Afterwards you can explain how the Go streaming proxy propagates a deadline through its context.
- Your gateway. Afterwards you can explain why the Go gateway rejects bad keys before proxying and how it streams without buffering.
- Containers and Kubernetes. Afterwards you can explain how the image runs on kind behind a Helm chart and a NodePort.
- Images, kind, and Helm. Afterwards you can trace how helm install brings up the gateway and the engine on kind and how a curl reaches the engine through the gateway.
- One trace. Afterwards you can explain how trace context propagates so one request shows as one trace across gateway and engine in Jaeger.
- First drill. Afterwards you can diagnose the engine crashloop from its symptoms, explain the fix, and explain what its runbook says.
- First ADR. Afterwards you can explain why ADR-0001 has the languages meet at process and file boundaries.
- What the System Does After Pass 1. Afterwards you can explain how every layer runs end to end, starting with the CLI training and sampling the bigram from a clean shell.
The engine serves exactly the checkpoint the tinyllm CLI wrote, so by the end of the pass every layer exists and runs end to end. The stages are also in this pass’s manifest, path.tsv. Pass 2 keeps the engine and replaces how its model is trained.
Stages
Section titled “Stages”Generated from path.tsv.
| Stage | Read | Done when |
|---|---|---|
| 1 | Matmul in Python 9.1 Vectors, matrices, row-major layout, and matmul | You can explain how the triple-loop Python matmul indexes rows and columns and why it matches numpy on the golden cases. |
| 2 | Byte bigram 6.1 Byte bigram: counts, logits, safetensors v0 | You can explain why the count-based bigram reaches the maximum-likelihood NLL and how it is written to a safetensors file. |
| 3 | Rust 1.4 Rust: ownership, traits, Result, cargo workspaces, std TCP | You can explain how the Rust echo server serves two clients at once and who owns each connection. |
| 4 | HTTP and SSE 1.5 HTTP/1.1, JSON, and Server-Sent Events from the wire up | You can trace how an HTTP request is parsed and how an SSE stream is framed by hand. |
| 5 | Your first endpoint 23.1 Your first endpoint: a std-only Rust HTTP/1.1 + SSE server | You can trace how the Rust server loads the checkpoint, streams SSE completions, and exports its span. |
| 6 | Go 1.6 Go: packages, interfaces, goroutines, channels, context, net/http, testing | You can explain how the Go streaming proxy propagates a deadline through its context. |
| 7 | Your gateway 25.1 The tracer gateway | You can explain why the Go gateway rejects bad keys before proxying and how it streams without buffering. |
| 8 | Containers and Kubernetes 1.7 Containers and Kubernetes: images, layers, Pods, Deployments, Services, Helm, kind | You can explain how the image runs on kind behind a Helm chart and a NodePort. |
| 9 | Images, kind, and Helm 10.1 Tracer deploy: images, a kind cluster, two Helm charts, and Jaeger | You can trace how helm install brings up the gateway and the engine on kind and how a curl reaches the engine through the gateway. |
| 10 | One trace 11.1 One trace from gateway to engine | You can explain how trace context propagates so one request shows as one trace across gateway and engine in Jaeger. |
| 11 | First drill 12.1 First drill: the engine crashloops | You can diagnose the engine crashloop from its symptoms, explain the fix, and explain what its runbook says. |
| 12 | First ADR 12.1 Architecture decision records | You can explain why ADR-0001 has the languages meet at process and file boundaries. |
| 13 | What the system does after Pass 1 B.3.1 What the System Does After Pass 1 | You can explain how every layer runs end to end, starting with the CLI training and sampling the bigram from a clean shell. |