Skip to content

B.9 Pass 7: The Serving Platform

This pass replaces the tracer’s engine and gateway with production ones and runs them the way a production platform would. The Rust engine, written with async Rust, tokio, and hyper, gains continuous batching, chunked prefill, a prefix-caching block manager, disaggregated prefill and decode connected by gRPC, serving metrics and tracing, speculative decoding, and tool calls. A load generator measures it. The Go gateway in front gains authentication and authorization, rate limits, a streaming proxy, consistent-hash routing with cascades and failover, a response cache, and a usage ledger in SQLite that reconciles with what the engine reports.

Concepts from other sections (29)

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.

The last part of the pass deploys the platform on kind with per-role Helm charts and a Tilt dev loop, adds Prometheus, Tempo, and Grafana with SLOs and burn-rate alerts, and rehearses a decode worker dying mid-stream. It closes with a code review and a design review of everything built so far.

Learning objectives

  • Explain how continuous batching, chunked prefill, and the block manager let many streams share one model.
  • Explain why prefill and decode are disaggregated and how the KV transfer between them stays leak-free.
  • Explain how the gateway authenticates, limits, routes, caches, and meters requests without the engine knowing about tenants.
  • Explain how the SLOs, burn-rate alerts, traces, and dashboards explain a violation.
  • Diagnose a decode worker dying mid-stream and keep the system within its error budget.

This pass needs Pass 6, whose Python inference stack defines the correct output the engine must reproduce.

The pass builds the engine first, then the gateway, then the deployment and its observability:

  1. Candle model runner (Llama + bigram, int4), Rust KV cache, sampler and PCG32. Afterwards you can explain how the candle model runner runs Llama and the bigram (int4 included), and how the Rust KV cache and PCG32 sampler match Python.
  2. Continuous batching scheduler with priority and preemption. Afterwards you can explain how continuous batching admits, prioritizes, and preempts sequences each step.
  3. Chunked prefill (mixed prefill + decode batches). Afterwards you can explain how chunked prefill mixes prefill chunks with decode steps under a token budget.
  4. Block manager with prefix cache (none, hash, radix). Afterwards you can explain how the block manager allocates KV blocks and how the none, hash, and radix prefix caches reuse them.
  5. Async Rust and tokio: futures, tasks, channels, cancellation, hyper. Afterwards you can explain how futures, tasks, channels, and cancellation work in tokio and how hyper serves a request.
  6. Speculative decoding in the engine. Afterwards you can explain how the engine runs speculative decoding and verifies drafts in one batched step.
  7. tl-serve: OpenAI-compatible HTTP + SSE on tokio/hyper. Afterwards you can trace how tl-serve parses an OpenAI-compatible request and streams SSE on tokio and hyper.
  8. Protocol Buffers and gRPC: schema evolution, unary and streaming RPCs, stubs. Afterwards you can explain how Protobuf schemas evolve compatibly and how unary and streaming gRPC calls are made.
  9. Disaggregated prefill and decode. Afterwards you can explain how disaggregated prefill and decode transfer the KV cache and how the heartbeat client reports health.
  10. Serving metrics and tracing. Afterwards you can explain how the serving metrics, SLO histograms, and OTel spans are recorded and propagated.
  11. Tool calls and constrained decoding. Afterwards you can explain how tool calls are parsed and how constrained JSON decoding guarantees valid arguments in the engine.
  12. An open-loop load generator. Afterwards you can explain why the load generator is open-loop, how its log-linear histogram records latency, and how the Go PCG32 port matches.
  13. Run comparison and the regression gate. Afterwards you can explain how two runs are compared and when the regression gate fails.
  14. The server skeleton. Afterwards you can explain how the gateway’s composition root wires its parts from go/config and how graceful shutdown drains requests.
  15. API Keys, Scopes, Model Allowlists, and Tenants. Afterwards you can explain how API keys authenticate a request and how scopes, the model allowlist, and tenants authorize it.
  16. Rate Limiting: RPM Token Buckets and TPM Reserve/Settle. Afterwards you can explain how the RPM token bucket and the TPM reserve-and-settle limit traffic.
  17. SSE streaming proxy. Afterwards you can explain how the SSE streaming proxy forwards events, handles disconnects, and how it upgrades the tracer gateway.
  18. A consistent hash ring with bounded loads. Afterwards you can explain how a consistent hash ring with bounded loads places keys and caps each node’s share.
  19. Routing, cascades, and failover. Afterwards you can explain how the worker registry routes requests, how cascades and failover work, and how disaggregated requests are orchestrated.
  20. Response cache: LRU, TTL, singleflight, and tenant-scoped keys. Afterwards you can explain how the response cache combines LRU and TTL, why singleflight collapses duplicate misses, and why keys are tenant-scoped.
  21. SQL and SQLite: schema, transactions, WAL mode, indexes, aggregates. Afterwards you can explain how SQLite transactions, WAL mode, and indexes behave and how an aggregate query is written.
  22. The usage ledger and admin API. Afterwards you can explain how the usage ledger meters requests and how the admin API reads it.
  23. Contract tests: consumer-driven tests for gateway to engine. Afterwards you can explain how a consumer-driven contract test pins the gateway-to-engine interface.
  24. Dockerfiles for the gateway and the engine. Afterwards you can explain how the multi-stage Dockerfiles build small gateway and engine images.
  25. kind cluster, local registry, and port mappings. Afterwards you can explain how the kind cluster, local registry, and port mappings fit together.
  26. Helm charts and the observability stack. Afterwards you can explain how the Helm charts deploy the gateway, the engine, and the observability stack.
  27. The Tilt dev loop. Afterwards you can explain how the Tilt dev loop rebuilds and redeploys on change.
  28. CI for the learner repo. Afterwards you can explain what the repository’s CI runs and in what order.
  29. Tracing for the serving path. Afterwards you can trace the spans along the serving path and how their context propagates.
  30. Metrics and log correlation. Afterwards you can explain how metrics and logs are correlated with traces.
  31. SLOs and multi-window burn-rate alerts. Afterwards you can explain how SLOs set error budgets and why multi-window burn-rate alerts fire when they do.
  32. Dashboards as code for the serving path. Afterwards you can explain how the dashboards are defined as code for the serving path.
  33. A decode worker dies mid-stream. Afterwards you can diagnose a decode worker dying mid-stream from its symptoms, explain the fix, and explain how recurrence is prevented.
  34. Code review: review a seeded PR against your system. Afterwards you can identify the defects in the seeded PR and explain why each matters.
  35. Design review: the tracer and the serving platform. Afterwards you can explain the design decisions of the tracer and serving platform and the tradeoffs a design review raises.
  36. What the System Does After Pass 7. Afterwards you can explain how the engine, the gateway, and observability work together on kind to hold the SLOs.

The stages are also in this pass’s manifest, path.tsv. Pass 8 turns to the long-running jobs behind the platform: corpus builds and training runs.

Generated from path.tsv.

StageReadDone when
1Candle model runner (Llama + bigram, int4), Rust KV cache, sampler and PCG32
23.2 Candle model runner (Llama + bigram, int4), Rust KV cache, sampler and PCG32
You can explain how the candle model runner runs Llama and the bigram (int4 included), and how the Rust KV cache and PCG32 sampler match Python (L10.1).
2Continuous batching scheduler with priority and preemption
23.3 Continuous batching scheduler with priority and preemption
You can explain how continuous batching admits, prioritizes, and preempts sequences each step (L10.2).
3Chunked prefill (mixed prefill + decode batches)
23.4 Chunked prefill (mixed prefill + decode batches)
You can explain how chunked prefill mixes prefill chunks with decode steps under a token budget (L10.3).
4Block manager with prefix cache (none, hash, radix)
23.5 Block manager with prefix cache (none, hash, radix)
You can explain how the block manager allocates KV blocks and how the none, hash, and radix prefix caches reuse them (L10.4).
5Async Rust and tokio: futures, tasks, channels, cancellation, hyper
1.9 Async Rust and tokio: futures, tasks, channels, cancellation, hyper
You can explain how futures, tasks, channels, and cancellation work in tokio and how hyper serves a request (lang.09).
6Speculative decoding in the engine
23.9 Speculative decoding in the engine
You can explain how the engine runs speculative decoding and verifies drafts in one batched step (L10.8).
7tl-serve: OpenAI-compatible HTTP + SSE on tokio/hyper
23.6 tl-serve: OpenAI-compatible HTTP + SSE on tokio/hyper
You can trace how tl-serve parses an OpenAI-compatible request and streams SSE on tokio and hyper (L10.5).
8Protocol Buffers and gRPC: schema evolution, unary and streaming RPCs, stubs
1.10 Protocol Buffers and gRPC: schema evolution, unary and streaming RPCs, stubs
You can explain how Protobuf schemas evolve compatibly and how unary and streaming gRPC calls are made (lang.10).
9Disaggregated prefill/decode, KV transfer, heartbeat client
23.7 Disaggregated prefill and decode
You can explain how disaggregated prefill and decode transfer the KV cache and how the heartbeat client reports health (L10.6).
10Serving metrics, SLO histograms, OTel spans and propagation
23.8 Serving metrics and tracing
You can explain how the serving metrics, SLO histograms, and OTel spans are recorded and propagated (L10.7).
11Tool calls and constrained JSON decoding in the engine
23.10 Tool calls and constrained decoding
You can explain how tool calls are parsed and how constrained JSON decoding guarantees valid arguments in the engine (L10.9).
12Open-loop load generator, log-linear histogram, Go PCG32 port
23.11 An open-loop load generator
You can explain why the load generator is open-loop, how its log-linear histogram records latency, and how the Go PCG32 port matches (load.01).
13Run comparison and regression gate
23.12 Run comparison and the regression gate
You can explain how two runs are compared and when the regression gate fails (load.02).
14Server skeleton, composition root, go/config, graceful shutdown
25.2 The server skeleton
You can explain how the gateway’s composition root wires its parts from go/config and how graceful shutdown drains requests (gw.01).
15AuthN (API keys) and AuthZ (scopes, model allowlist, tenants)
10.1 API Keys, Scopes, Model Allowlists, and Tenants
You can explain how API keys authenticate a request and how scopes, the model allowlist, and tenants authorize it (gw.02).
16Rate limiting: RPM token bucket + TPM reserve/settle
10.2 Rate Limiting: RPM Token Buckets and TPM Reserve/Settle
You can explain how the RPM token bucket and the TPM reserve-and-settle limit traffic (gw.03).
17SSE streaming proxy (upgrades gw.00)
25.3 The SSE streaming proxy
You can explain how the SSE streaming proxy forwards events, handles disconnects, and upgrades gw.00 (gw.04).
18Consistent hash ring with bounded loads
15.9 A consistent hash ring with bounded loads
You can explain how a consistent hash ring with bounded loads places keys and caps each node’s share (ds.09).
19Worker registry, routing, cascades, failover, disaggregated orchestration
25.4 Routing, cascades, and failover
You can explain how the worker registry routes requests, how cascades and failover work, and how disaggregated requests are orchestrated (gw.05).
20Response cache: LRU + TTL, singleflight, tenant-scoped keys
6.1 Response cache: LRU, TTL, singleflight, and tenant-scoped keys
You can explain how the response cache combines LRU and TTL, why singleflight collapses duplicate misses, and why keys are tenant-scoped (gw.06).
21SQL and SQLite: schema, transactions, WAL mode, indexes, aggregates
1.11 SQL and SQLite: schema, transactions, WAL mode, indexes, aggregates
You can explain how SQLite transactions, WAL mode, and indexes behave and how an aggregate query is written (lang.11).
22Usage ledger, metering, admin API
25.5 The usage ledger and admin API
You can explain how the usage ledger meters requests and how the admin API reads it (gw.07).
23Contract tests (R6): consumer-driven tests for gateway to engine
3.6 Contract tests: consumer-driven tests for gateway to engine
You can explain how a consumer-driven contract test pins the gateway-to-engine interface (craft.20).
24Dockerfiles for the gateway and the engine
10.2 Dockerfiles for the gateway and the engine
You can explain how the multi-stage Dockerfiles build small gateway and engine images (dep.01).
25kind cluster + local registry + port mappings
10.3 kind cluster, local registry, and port mappings
You can explain how the kind cluster, local registry, and port mappings fit together (dep.02).
26Helm charts for the gateway and the engine, plus the observability stack
10.4 Helm charts and the observability stack
You can explain how the Helm charts deploy the gateway, the engine, and the observability stack (dep.03).
27Tilt dev loop
10.5 The Tilt dev loop
You can explain how the Tilt dev loop rebuilds and redeploys on change (dep.04).
28CI for the learner repo
10.6 CI for the platform repo
You can explain what the repository’s CI runs and in what order (dep.05).
29Tracing for the serving path
11.2 Tracing for the serving path
You can trace the spans along the serving path and how their context propagates (obs.01).
30Metrics and log correlation
11.3 Metrics and log correlation
You can explain how metrics and logs are correlated with traces (obs.02).
31SLOs and multi-window burn-rate alerts
11.4 SLOs and multi-window burn-rate alerts
You can explain how SLOs set error budgets and why multi-window burn-rate alerts fire when they do (obs.03).
32Dashboards as code for the serving path
11.5 Dashboards as code for the serving path
You can explain how the dashboards are defined as code for the serving path (obs.04).
33A decode worker dies mid-stream
12.2 A decode worker dies mid-stream
You can diagnose a decode worker dying mid-stream from its symptoms, explain the fix, and explain how recurrence is prevented (ops.01).
34Code review: review a seeded PR against your system
6.2 Code review
You can identify the defects in the seeded PR and explain why each matters (craft.08).
35Design review: tracer and serving platform
1.1 Design review: the tracer and the serving platform
You can explain the design decisions of the tracer and serving platform and the tradeoffs a design review raises (review.01).
36What the system does after Pass 7
B.9.1 What the System Does After Pass 7
You can explain how the engine, the gateway, and observability work together on kind to hold the SLOs.