Batching, Scheduling and Admission

A serving scheduler decides which users progress, which memory is reserved and what happens under overload. Throughput, latency, fairness and cancellation must be visible in the same policy evaluation.

Section 4 of 9 · 12 units · about 50 hours

0/12

By the end you can Preserve request, memory, progress and fairness invariants under adversarial load, demonstrate one policy win and one regression, and explain both from scheduler traces rather than aggregate throughput.

Units

Build it

Mini project · about 14 to 20 hours

Continuous-batching scheduler with collapse and recovery evidence

Build a deterministic continuous-batching simulator in sim/ with budgets, preemption, priorities, cancellation and overload handling, and test it against public scheduler cases and frozen adversarial corpora. Carry one bounded policy into a real engine behind a flag and defend the win and the loss from traces.

  1. 1Build the sim/ continuous-batching simulator with token and sequence budgets, decode-first fill and deterministic replay, and check it against the TensorTonic continuous-batching scheduler cases plus your hand trace as the first regression test.
  2. 2Add KV-reserve admission with recompute preemption to sim/, counting preemptions per request, and assert ownership, no-overcommit, progress and bounded-wait invariants after every transition over randomized histories with a seeded leak and a stuck waiter they must catch.
  3. 3Run the Module 05 chunk-budget sweep in sim/ with decode-first fill, and keep the throughput table with inter-token latency tails that shows where a smaller budget steadies the stream and where it starves the hardware.
  4. 4Add priority classes with an aging rule to sim/, prove a convoy workload delays short requests under arrival order, keep a starvation test that fails with aging off, and pass the TensorTonic cache-aware routing cases for the affinity policy.
  5. 5Implement abort at every scheduler phase with leak checks, early rejection with retry budgets, and goodput over offered load; then sweep open-loop load through saturation with repeats, keeping raw records, drain time and the queueing against execution split.
  6. 6Freeze long-prefill, decode-heavy, mixed, bursty, priority and cancellation corpora, compare two policies from per-request traces keeping one regression, then carry one bounded change into a real engine behind a flag with fallback and run the companion continuous-batching pair.
What you hand in
  • The sim/ scheduler with replayable traces, invariant checks and the hand-trace regression test.
  • Adversarial corpora with per-policy traces, saturation sweeps with drain evidence and the ablation with its losing regime.
  • The bounded engine change behind a flag with fallback, cancel and routing tests and the scheduling write-up.
How to check it
How it's graded

Deterministic replay

Pass: Fixed corpus, config and ordering replay to identical per-request traces, and the hand trace matches exactly.

Great: A second policy replays cleanly, and trace diffs attribute every delay to a named scheduler decision.

Admission and preemption

Pass: Admit, defer and preempt decisions match budget math on fixed mixes, and per-request preemption counts explain eviction churn.

Great: A repeated-eviction workload shows the reserve fix that stops the churn with traces before and after.

Overload honesty

Pass: Cancel-at-every-phase tests leak no blocks, rejection protects goodput, and sweeps show the knee with drain time.

Great: The queueing against execution split names the saturated bottleneck, and the ablation keeps a losing regime.

Fairness and transfer

Pass: The starvation test fails with aging off and passes with it on, and the bounded engine change toggles to fallback cleanly.

Great: Routing cases pass, and engine traces explain where the simulator prediction held and where it broke.

Resources

  • Hands-On LLM Serving and Optimization - Chapter 6, batching and schedulingChi Wang and Peiheng Hu (O'Reilly)

    Read "Request Batching and Scheduling-Level Optimizations" in Chapter 6: dynamic, continuous and chunked-prefill batching. Rebuild each policy in a small event simulator and state the user-visible metric it can improve or harm.

  • Orca: A Distributed Serving System for Transformer-Based Generative ModelsUSENIX OSDI

    Study iteration-level scheduling and selective batching, including the workload assumptions. Reproduce one scheduling timeline by hand and use it as the correctness baseline for the simulator.

  • Sarathi-Serve: Tackling Throughput-Latency Tradeoffs in LLM InferenceMicrosoft Research

    Focus on chunked prefills, stall-free batching and the throughput-latency trade-off. Implement a fixed-token chunk policy and preserve a workload where chunking loses to the simpler scheduler.

  • AI Systems Performance Engineering - Chapters 16 and 18, scheduling and admissionChris Fregly (O'Reilly)

    Read "Dynamic Batching, Scheduling, and Routing" in Chapter 16 and "SLO-Aware Request Management and Fault Tolerance" in Chapter 18 (early rejection, quality of service).

  • Nano-vLLM - Scheduler, Block Manager and Engine LoopGeeeekExplorer

    Trace scheduler.py with llm_engine.py and block_manager.py. Add event logging in your own fork or project, explain every transition, and implement one bounded admission or chunking change with regression tests.

  • Mini-SGLang - Scheduler and Overlap SchedulingSGLang Project

    Read docs/structures.md, scheduler implementation and tests/core/test_scheduler.py, then compare overlap scheduling with the Nano-vLLM loop. Use the online benchmark only after fixing the same workload and hardware contract.

  • AI Systems Performance Engineering - Continuous Batching LabChris Fregly

    Run the Chapter 15 baseline and optimized continuous-batching pair under CPU-safe or available-GPU settings. Inspect the shared comparison contract and re-measure rather than quoting bundled deltas.

  • TensorTonic Language Modeling from Scratch - Simulate Continuous Decode BatchingTensorTonic

    Solve after the continuous-batching unit, then compare its admission rule with your own simulator.

  • LLM Inference: From scratch, one token at a time - Module 05Tushar Amrit

    Work the Batching module's arithmetic and checkpoint before the static and continuous batching units.

  • LLM Inference Systems Laboratory - SchedulerRoadmap-Final

    Add token and memory admission, chunking, priority, cancellation, overload and fairness to the simulator, then carry one policy through the real engine path with a reference fallback.

  • vLLM v0.31.0 benchmark CLIvLLM Project

    Use vllm bench serve with --request-rate for offered-load sweeps, and vllm bench throughput and vllm bench latency for offline endpoint and phase baselines. Fix the dataset, lengths, request rate, warmup and sampling, and keep raw per-request results; do not copy example rates as targets.

  • TensorTonic Language Modeling from Scratch - Route Cache-Aware Prefill RequestsTensorTonic

    Solve after the affinity unit: assign each request to a feasible worker by longest cached prefix, lowest projected uncached load, greatest remaining capacity, then lowest worker id, with -1 when infeasible.

  • vLLM v0.31.0 serve CLI and scheduler argumentsvLLM Project

    Look up scheduler flags and defaults: --max-num-seqs, --max-num-batched-tokens, --max-num-active-seqs, --enable-chunked-prefill, --long-prefill-token-threshold and --scheduling-policy. Runtime defaults vary by GPU class, so check them against the installed v0.31.0 behavior.

  • vLLM v0.31.0 metrics designvLLM Project

    Read the WAITING, RUNNING and PREEMPTED request states and the queue, inference, prefill and decode interval definitions. Swapped-preemption metrics are legacy in v1. The exported counters, including vllm:num_requests_waiting_by_reason and vllm:num_preemptions, are listed on the Production Metrics page, https://docs.vllm.ai/en/v0.31.0/usage/metrics/

  • vLLM v0.31.0 online servingvLLM Project

    Read the /abort_requests endpoint and the Responses cancel API for request cancellation. Verify client-disconnect aborts on your engine; the page does not cover them.

  • vLLM v0.31.0 LoRA adaptersvLLM Project

    Read per-request LoRARequest serving, server-wide --lora-modules with max_loras and max_lora_rank, and why adapter-slot pressure rewards grouping same-adapter requests.

  • vLLM v0.31.0 structured outputsvLLM Project

    Read the xgrammar and guidance backends, the choice, regex, json, grammar and structural_tag options in StructuredOutputsParams, and the --structured-outputs-config.backend flag.

  • vLLM v0.31.0 multimodal inputsvLLM Project

    Read limit_mm_per_prompt, content hashing with multi_modal_uuids in Cached Inputs, and the video pruning flags as examples of encoder-side scheduling cost.