B.9.1 What the System Does After Pass 7
After Pass 7 the tracer’s engine and gateway have been replaced by production ones, and the platform runs on kind the way it would in production. The Rust inference engine is conformant, concurrent, observable, speculative, and tool-calling. The gateway conforms to the API, and its usage ledger reconciles with the engine. On kind, the gateway, disaggregated engines, and the observability stack hold the SLOs. Everything from earlier passes keeps working. This page gives the commands and configuration the finished solution runs, what each produces, and why each piece is needed.
Concepts from other sections (13)
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.
- inference engine: software that loads weights, schedules requests, manages the KV cache, and generates tokens (vLLM, SGLang, TensorRT-LLM, llama.cpp). Read more: 20.5 LLM Serving Platforms: How They Work and When to Use Them
- usage ledger: the durable per-request record of tenant, key, model, status, tokens, and latency. Read more: 25.5 The usage ledger and admin API
- Service Level Objective (SLO): a target for a defined measure of service behavior over a specified window. Read more: Chapter 13: Engineering Acronyms in Software Engineering
- KV pool: the GPU memory left for KV cache after weights and activation headroom; it sets maximum concurrency. Read more: 20.4.6 Load tests and the deployment runbook
- continuous batching: re-forming the batch at every step so finished requests leave and waiting ones join immediately. Read more: 23.3 Continuous batching scheduler with priority and preemption
- memory-bound: limited by the rate at which data can be read, not by arithmetic throughput. Read more: 22.7 Fused int4 and int8 dequantize-matmul in C
- logits: unnormalized log-scores that softmax turns into probabilities; here the table stores . Read more: 6.1 Byte bigram: counts, logits, safetensors v0
- Contract test: a test of the agreement between two services that runs neither against the other. Read more: 3.6 Contract tests: consumer-driven tests for gateway to engine in Software Engineering
- Error budget: the per-output bound a quantized layer must stay within. Read more: 21.5 Quantization: int8, int4 groups, fp8, and the KV cache
- 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
- window profile: a set of alert windows, evaluation interval, and
fordurations; prod and a 12x-compressed drill profile. Read more: 11.4 SLOs and multi-window burn-rate alerts in Systems Engineering - TTFT (time to first token): time from a request’s arrival to its first generated token. Read more: 23.4 Chunked prefill (mixed prefill + decode batches)
- TPOT (time per output token): time between successive tokens of a running request, about one step. Read more: 23.4 Chunked prefill (mixed prefill + decode batches)
The engine is the Serving chapter, from the model runner and sampler through continuous batching, chunked prefill, the block manager, the tokio server, disaggregated prefill and decode, metrics and tracing, speculative decoding, and tool calls, measured by the load generator and written with the primers on async Rust and tokio and Protocol Buffers and gRPC. The gateway spans AI Engineering, from the server skeleton, API keys and scopes, rate limiting, and the SSE streaming proxy to routing, the response cache, and the usage ledger, with a consistent hash ring, SQL and SQLite, and contract tests. Production on kind draws on the deploy sections from Dockerfiles to CI for the platform repo, the observability sections from tracing for the serving path to dashboards as code, the drill A decode worker dies mid-stream, and the code review and design review that close the pass.
The inference engine: conformant, concurrent, observable, speculative, tool-calling
Section titled “The inference engine: conformant, concurrent, observable, speculative, tool-calling”The Rust engine serves the OpenAI subset v1, openai-subset.v1.yaml, conformantly: streaming, stop strings, seeds, 16 concurrent streams, abort on disconnect, and tool calls. It keeps its KV pool clean under a burst of 64 requests from its own load generator, reports its metrics under the contract’s names, keeps greedy output unchanged with prompt-lookup speculation on, and answers a forced tool call with a schema-valid call. A tiny random Llama shows all of this in seconds. It is the tiny-llama-2l of the Llama-family model, in a 1024-position copy, because a tool request’s schema prompt is about 470 byte tokens, past the original 256. SmolLM2-135M-Instruct served the same way chooses for itself when to call a tool.
Why this matters: this engine replaces the tracer’s in every later pass. Continuous batching is what lets 16 streams share one model. A clean KV pool after a burst is the evidence that aborted and finished requests free their blocks. The metric names are what the SLO rules below query. And greedy equality with speculation on is the same correctness rule as Pass 6.
The roles are wired as cli-roles.md describes:
engine tl-serve --config <runtime.toml>; the runtime.toml's [engine].model_dir names the model, and [engine].model_id the name clients ask for ("tracer"). Health: http://127.0.0.1:{health_port}/healthzengine-spec the same template with [engine].speculative = { draft = "prompt_lookup", k = 4 }engine-prefill, engine-decode-a, engine-decode-b the same model with [engine].role = "prefill" and "decode", each with a gRPC port and a KV transfer portloadgen {loadgen} --target <base url without /v1> --model <m> --prompt <text> --max-tokens <n> --mode burst --burst <n> --duration <d> --out <report.json>: writes the report (formats/loadgen-report.schema.json) to --out and prints it as the final stdout lineThe runtime templates (engine, engine-spec, engine-prefill, and engine-decode) are in config/, and the load generator is go/cmd/loadgen.
Two comparisons show that the engines agree with each other. The first is greedy equality: the plain and the speculative engine give the same greedy text. The second is disaggregation without the gateway. Tokenize on the prefill engine, call EngineControl.Prefill there with decode_target set to a decode engine’s KV port, then send the same request to that decode engine with X-TL-KV-Handle. Greedy output (plain and streamed, alternating the two decode engines) and seeded output equal the unified engine’s. An unknown or released handle answers 404 kv_handle_not_found, and a transfer reset mid-push fails Prefill without leaking a KV block on either side, after which that decode engine serves again.
Disaggregation exists because prefill is compute-bound and decode is memory-bound, so running them on separate pools lets each be sized for its own bottleneck. Finally, the Rust and Python samplers agree on the same logits, and the engine’s greedy stream equals the Python model’s on the tiny model.
The gateway conforms to the API, and its ledger reconciles with the engine
Section titled “The gateway conforms to the API, and its ledger reconciles with the engine”The gateway, in front of the engine, is checked as a client sees it. The gateway tier of openai-subset.v1 passes: auth, limits, cache, headers, and priority.internal. The usage-policy cases, such as policy.451, wait for Pass 10. The engine tier passes on its own, which is the provider side of the contract tests. And the usage ledger reconciles with the usage the engine reported for a fixed workload, both through the admin API, admin.v1.yaml, and through the CLI.
The roles are wired like this:
engine the --config form, serving the byte-level model "tracer" (decision D32): "Once" is 4 prompt tokensgateway the --config form; health /readyz, started after the engine; its config sets [gateway].usage_db to a fresh ledger, routes model "tracer" to the engine, and accepts the key in $TL_API_KEY with the scopes infer and adminctl the umbrella CLI, with the usage verb belowThe usage verb of the ctl role is in go/cmd/ctl/usage.go:
{ctl} usage --gateway <base URL> [--tenant T] [--key-id K] [--since T] [--until T] [--group-by none|model|tenant|key_id|api_version] [--json] GET <base>/admin/v1/usage with the key in $TL_API_KEY. With --json: one JSON line per row, then a final line of totals over the rows: {"requests": N, "errors": E, "prompt_tokens": P, "completion_tokens": C, "cached_tokens": K}. Exit 1 on an HTTP error, with the error's message on stderr.A fixed workload makes the reconciliation exact: 8 completions and 4 streams of max_tokens 4 on “Once”, each with 4 prompt and 4 completion tokens, so the ledger holds exactly 12 requests, 48 prompt tokens, and 48 completion tokens. Failover before the first byte is part of routing: a backend killed before its first byte is retried elsewhere.
Why this matters: the gateway is where tenants, keys, limits, and billing live, so the engine never has to know about them. The ledger is what usage is billed from, and it is only trustworthy if it agrees with what the engine actually produced.
Production on kind holds the SLOs
Section titled “Production on kind holds the SLOs”The serving platform runs on the kind cluster as it would in production: the gateway (1 replica) in front of the engines deployed as 1 prefill and 2 decode, the observability stack (collector, Prometheus with the SLO rules, Tempo, and Grafana) scraping and tracing it, the load generator holding the SLO rate within budget, and the drill in which a decode pod is killed mid-load resolved within the error budget.
The Helm charts are under deploy/helm and the observability chart under deploy/observability:
loadgen {loadgen} --target <base url> --rate <rps> --duration <d>; sends the API key from $TL_API_KEY and prints its report (formats/loadgen-report.schema.json) as the final JSON linedeploy kube_context "kind-<system>", namespace "<system>", gateway_url NodePort 30080 (http://127.0.0.1:30080), prometheus NodePort 30090 (http://127.0.0.1:30090), traces Tempo query API, NodePort 30320, deployments <system>-gateway, <system>-engine-prefill, <system>-engine-decodeThe names the SLO queries rely on are fixed by observability.md. The Deployments and Services are <system>-gateway, <system>-engine-prefill, and <system>-engine-decode in the namespace. Every Service is scraped on :9464 by a ServiceMonitor labelled release: observability, so its series carry namespace and service labels. OTEL_SERVICE_NAME is <system>-gateway or <system>-engine. And the PrometheusRules are rendered from slo.yaml with the prod window profile and the label release: observability.
The SLO bounds are a TTFT p95 of 0.5 s, a TPOT p95 of 60 ms at 4 requests per second, and a 5xx ratio under 0.5%. They are calibrated on a fast laptop, so a slower machine can miss them with a correct system.
Why this matters: the SLOs turn “fast enough” into numbers the alerting rules can burn against, the observability stack is how a violation is explained, and the drill shows that the system degrades within budget when a decode pod dies, which is what production will do to it. Pass 8 turns to the long-running jobs behind the platform.