Lab — Build a Reproducible GPU Inference Server
Everything the module on running your first LLM built is still one tmux session and a scrollback of commands, which means it lives nowhere. This lab, the module's finish line, turns it into an artifact: a small repository that anyone with your record and a GPU box can take from zero to a serving, verified endpoint. The gate grammar is from the setup lab; the standard it meets is still the run scope from levels of inference engineering, now for a whole service: pinned environment, repeated result.
The reproducibility test at the end is the point. A server that worked once, assembled by hand, is a memory; a server that comes back identical from a fresh start is engineering evidence, and it is the baseline every measurement in inference benchmarking and every optimization after it will stand on.
The deliverable
One directory, versioned in git, plus the record file that extends the setup.md you started in the setup lab (values representative):
The revision line matters most: it is the snapshot hash the model download lesson left in your cache, and it names the exact artifact the evidence below refers to. One honesty note: from_pretrained resolves the repository's main branch unless you pass revision=, so the hash in the record is your detector for a moved artifact, not a lock; pass it to both from_pretrained calls if you want the lock (the pinning habit from the model download lesson, enforced in code).
Stage 1: the repository
Assemble the directory on the box: the serve.py you wrote in HTTP serving, a run.sh of two lines (source .venv/bin/activate, the uvicorn line), the one-line .gitignore so the venv itself stays out of git, and the environment per Python and PyTorch setup. Then pip freeze > requirements.txt, and git init, git add, git commit.
Gate. git status is clean, and requirements.txt pins every library serve.py imports. Record the versions into server.md.
Stage 2: the deterministic endpoint
Start the server with run.sh inside tmux, open the tunnel, and put the canonical prompt through the front door:
Gate. The endpoint is greedy (do_sample=False in the HTTP serving server, one request at a time behind its lock), so the determinism token generation and streaming demonstrated does real work here: the same artifact, weights, and policy produce the same continuation every time on the same box. On the course's reference run that continuation is a city of many faces. It is, not Paris, for the base-model reason the lesson on token generation and streaming showed you. Record the exact continuation your own box produced in server.md; from here on, the gate is that it repeats verbatim.
Stage 3: restart survival
Kill the server (Ctrl-C in its tmux pane). Run run.sh again. Repeat stage 2's curl, and give /stream one curl -N while you are there; the streaming instruments of inference benchmarking and GPU capacity testing will point at this endpoint later.
Gate. Same response, no hand-assembly in between: the repository, not your memory of the afternoon, brought the service back. If anything needed a manual step outside run.sh, move that step into run.sh and repeat this stage.
Stage 4: the cold start
The full drill: the repeat from the setup lab, extended to the service. Detach everything. In a fresh shell on the box: fresh clone of the repository into a new directory, fresh venv from requirements.txt, run.sh, tunnel, stage 2's curl. One trap: if your torch came from the index-URL install from GPU compatibility, the frozen 2.13.0+cu126 tag will not resolve from PyPI, so put the --index-url line at the top of requirements.txt itself. The model itself comes from the Hub cache by revision, which is why the record pins the hash.
Gate. The greedy check passes from the clone. This is the levels of inference engineering claim in full: another engineer with server.md, the repository, and a GPU box reproduces your service and your output without asking you anything.
Gate (economics). Stop the instance when done, per the rent-small habit from remote GPU setup. An idle server on a rented GPU is the utility bill what inference is warned about, running for nobody.
Running your first LLM is complete. You now own the exact artifact the rest of the course improves: a served, verified endpoint another engineer can rebuild from the record alone. Understanding one token goes inside it, tracing what those weights actually do to one token, and the serving thread resumes in inference engines, where this very server meets traffic it cannot survive.