PR #5469 ยท follows #5267 (its explainer) ยท permalinks pinned to head 27cd87fc and base dfe2dcd7
rollout_recovery.prefix_writers writer actors (default 1) build, encode and store the rows, splitting each write by row size.| Benchmark (from the PR, one run each) | Before | K = 1 | K = 2 | K = 4 |
|---|---|---|---|---|
| Long prompts, median cut, H100 | 0.388 s | 0.505 s | 0.284 s | 0.181 s |
| Large MoE cuts, Dynamo, 2nd cut | 47.61 s | 15.85 s | โ | 8.16 s |
Gym cuts 3 running calls. Their size (prompt plus generated tokens) is c1 = 40, c2 = 25, c3 = 20. On the right, prefix_writers = 2.
| Question | Answer |
|---|---|
| Who starts the writers, and where? | Each engine's setup_token_capture starts K, pinned to its own node, each needing 1 free CPU. On native vLLM every HTTP frontend starts its own K, so N frontends use N ร K CPUs. |
| What crosses to the actor? | Each frozen call: its Gym call object, prompt and generated ids, logprobs, the new chunk, and route / top-k tensors as NumPy bytes (submit_generation_cut_rows). Back: each row's key and its call's digest. |
| What if a share fails? | The pool waits for every started share, then the engine's own client clears all the batch's keys and retries each row alone. A dead writer fails the whole cut loudly, as before. |
| Local data plane? | No actor: the worker's writer thread builds the rows itself, through the same functions. Setup rejects prefix_writers > 1 there. |
Before (main)
# cut thread, engine process, one per worker for call in inventory: row = next(cut_transaction(call)) # freeze; the call stays frozen # inside: record = gym.build_prefix_record(...) โ slow, on this thread batch.add(row) # hand batch to the writer thread # writer thread, engine process keys = sink.stage_batch(records) # encode here, then one PUT via the actor for tx, key in zip(batch, keys): tx.send(key) # seal + ack (back on the cut thread)
After (this PR)
# cut thread, engine process for call in inventory: row = next(cut_transaction(call)) # freeze only # inside: record = gym.build_prefix_record(...) # inside: row = GenerationCutRow(ids, logprobs, tensors) batch.add(row) # writer thread, engine process shares = split_by_size(batch, K) # biggest first, to the less-loaded writer refs = [w.submit(s) for w, s in shares] # all K start at once staged = [w.result(r) for ...] # wait for every share, even after a failure for tx, (key, digest) in zip(batch, staged): tx.send((key, digest)) # seal + ack, same as before # each writer actor, its own process, 1 CPU records = [gym.build_prefix_record(r) for r in share] # the slow part, now here keys = sink.stage_batch(records) # encode + PUT return [(key, prefix_digest) ...]
Real code: _cut_transaction, PrefixWritePipeline._write, PrefixWriterPool.stage_generation_cut_rows, stage_generation_cut_rows.
The design holds up: one build path for the local plane, the actor and the engine's digest, and a pool even at K = 1, so there is no separate one-writer path. The asks are about proving and explaining the new setting:
| Ask | Why |
|---|---|
| Test a writer that is already dead (fails at submit) (C1) | Every pool test fails later, at result(); the "wait for every started share" promise has no test on the submit path. |
Test that prefix_writers reaches the pool (C2) | No test passes a value other than 1; the two new prefix_writers=2 L1 runs also pass with one writer. |
| Test the local-data-plane half of the setup check, and print what tripped it (C3) | Only the "prefix cuts off" half is tested. |
| Name the setting and the real CPU count in the startup error (C4) | It still says "needs 1 free CPU" when K writers start. |
| Say "per HTTP frontend" and when to raise K in the docs (C5) | N frontends use N ร K CPUs; K = 1 makes small cuts slower. |
C1 โ test_prefix_writer_actor.py:671C2 โ test_prefix_writer_actor.py:445C3 โ setup.py:1580C4 โ prefix_writer_actor.py:390C5 โ single-controller-rollout-checkpointing.md:99
prefix_writers = 1 unless cuts are large or generation_prefix/pipeline_write_us dominates the cut, and budget one CPU per writer per HTTP frontend.