Inference prep
Study plan
Day 1 of 13 · Nov 28, 2026

Define a request and its deadline

Start with interactive chat. Write down what the user sees before the first token and what they see while later tokens arrive.

Before you start

Python 3.11+, a terminal, paper and a new project directory.

Read and predict 1 hour including video

Inference Engineering · §1.2.2 p. 29; §1.4 pp. 35–38; §2.2 pp. 46–49

Use the printed page numbers. In the supplied PDF, add two to reach the viewer page. Write a prediction for the question below before opening its answer.

Python · asyncio queues · Baseten · Inference Engineering

David Beazley · Build Your Own Async

Optional, 15 min. Follow the first scheduling example. Point to the line where another job can run while the first job waits.

Play lecture
Open original lecture

Build and test 3 hours

In 35 minutes implement three async workers consuming ten jobs from a bounded queue. Inject one failure and cancel one caller. Write the first version unaided.

  1. Draw the request path

    On paper, connect client, gateway, queue, worker and client. Circle the first place a request can wait.

  2. Run a one-job queue

    Download the Python starter below. In its folder run python3 pool.py. It should print “finished 0”. Set the job count to ten, then start three consumers.

    Download pool.py. Use Python 3.11 or later. Run the starter once, then close it and write your three-worker version in a new file.

  3. Break one job

    Make job 4 raise ValueError. Record the error, finish the other nine and cancel an idle consumer. Put task_done() in a finally block after a successful get().

Open gateway
Troubleshooting

If join() hangs, count successful puts and calls to task_done(). They must match.

Save your result 1 hour

Save request.md with a five-hop trace and two practice targets: first content within 1 s, later tokens averaging at most 80 ms apart. Save your pool implementation.

Explain from memory 1 hour

A request enters at 0 ms, starts prefill at 100 ms and emits at 220 ms. How much of TTFT can you attribute to prefill?

Check your reasoning

The client measures 220 ms. You need a prefill-end timestamp to isolate computation from sampling, transport and buffering.

Save a trace and three tests. Explain why a missing task_done can hang shutdown.