Skip to content

20.10 Runtime controls and inference flags

A flag selects a mechanism in a particular runtime. Learn the mechanism, its resource tradeoff, and its correctness test first; then map it to the option names in the installed engine. Defaults and support vary by release, hardware, and model, so there is no universal command that optimizes every workload.

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.

Learning objectives

  • Distinguish request-level sampling controls from engine-level resource controls.
  • Map a performance symptom to a bounded experiment.
  • Record resolved configuration and evaluate interacting flags.

Request controls change the work or the output distribution

Section titled “Request controls change the work or the output distribution”
Generic controlWhat it doesWhat to measure
Maximum generated tokens, stop conditionsBound output work and define completion terminationTruncation, task success, generated-length distribution
Temperature, top-k, top-p, min-pTransform next-token probabilitiesQuality/diversity and rollout behavior probabilities
Repetition/frequency penaltiesModify logits based on historyRepetition and unintended suppression
Number of candidates, best-of-NSpend more generation and scoring compute per answerSuccess per request and total compute, not only selected-answer quality
Grammar or schema constraintsMask invalid token continuationsSchema validity, semantic correctness, constraint overhead
Seed and random-stream policyControl assignment of random drawsReplay behavior under changing batch order
Log probabilities and returned alternativesExpose extra scoring/output dataMemory, transfer, serialization, and scoring semantics

Reducing output length is often an effective system optimization, but comparing 32 generated tokens with 512 does not establish a faster engine. Freeze the workload when benchmarking execution. A sampler change also changes the behavior policy for RL.

Generic engine controlMechanismBenefit and limiting tradeoffRequired check
Active-sequence limitBound sequences scheduled concurrentlyMore weight reuse; longer per-user step time and more KVGoodput, ITL, preemptions, queue time
Per-step token budgetBound scheduled prefill and decode workLarger prefill throughput; longer interference with decodeTTFT and ITL together on mixed traffic
Chunked prefill and chunk sizeInterleave portions of long prompts with decodesShorter decode stalls; repeated scheduling and possible prefill slowdownLong/short prompt fairness and numerical equivalence
Context limitBound accepted prompt plus outputLower worst-case memory; less supported contextExplicit input rejection or truncation semantics
Cache memory budgetReserve KV capacity after weights/workspacesHigher concurrency; less safety marginPeak memory during warmup, graph capture, and long-context traffic
Cache block sizeTrade allocation granularity against bookkeepingSmaller tail waste; more metadata and kernel constraintsResident blocks, cache hit rate, useful capacity
Prefix-cache reuse and evictionReuse exact compatible prefix stateLess repeated prefill; cached prefixes occupy spaceNamespace correctness, hit/miss behavior, cold versus warm runs
Preemption/recompute/swapReclaim state when capacity is exhaustedAvoid immediate failure; recompute or transfer costPreemption rate, tail latency, forward progress
Admission limits and priorityBound queued/running work and choose orderingProtect SLOs; reject or defer excess workRejection rate, starvation, cancellation cleanup

An engine’s “batch size” may mean sequences, tokens in an iteration, or static tensor slots. These are not interchangeable. At 32 active sequences, a step may contain 32 decode tokens, thousands of prefill tokens, or a mixture. Ask which resource the control actually bounds.

Generic controlMechanismTradeoff to validate
Weight/activation dtypeBF16/FP16/FP8 or integer arithmetic/storageDevice support, scaling, numerical error, quality
Weight quantization methodCompress weights with a matching kernel/layoutSmaller memory versus dequantization cost and quality
KV dtype and scalesCompress retained attention stateContext-dependent error and supported attention backend
Attention backendChoose tiled/fused kernels and layoutShapes, head sizes, masks, hardware, invariance
Compilation and fused kernelsReduce launches and fuse operationsCompilation time, shape specialization, temporary memory
Device graph captureReplay a prepared launch sequenceCapture/warmup cost, fixed-shape buffers, reserved memory
Tensor/pipeline/expert parallel degreesSplit matrices/layers/expertsFit and throughput versus collective traffic and bubbles
Replica countServe independent request batchesAggregate capacity and redundancy versus duplicated weights
CPU/NVMe offloadMove weights or state out of device memoryFit versus per-step transfer latency and host bandwidth
Speculative draft and draft lengthVerify several proposed tokens per target callAcceptance, draft cost, verification cost, KV rollback
Deterministic/batch-invariant executionRestrict algorithms to a replay contractSupported shapes and topologies, memory, and throughput cost

Quantization, graphs, and kernel selection interact: a faster format may lack a compatible graph or attention path. A larger cache fraction can leave too little graph-capture memory. A speculative draft can compete with the target for memory and bandwidth. Test combinations after isolated measurements reveal which controls matter.

Suppose short interactive requests meet an ITL target when served alone, but long prompts cause stalls. Start with a mixed prompt distribution at a fixed offered rate. Record queue time, prefill duration, ITL, active tokens, and memory. Sweep the per-step token budget with chunked prefill enabled. A smaller budget may reduce decode stalls while increasing long-prompt TTFT. Choose a point meeting both SLOs, then repeat the batch-invariance checks.

If memory is the limiting factor instead, scheduling alone cannot shrink the model. Compute weights, KV, and temporary buffers separately. Compare fewer active sequences, shorter supported context, a supported KV/weight representation, or a different placement. Use quality tests for any representation change. The capacity parts provide the arithmetic.

This table maps a few portable concepts to vLLM 0.11.0, an archived teaching reference. It does not describe every provider or recommend that release for production. Option names are checked against its serve reference; its tuning guide explains the scheduling tradeoffs. Runtime-selected defaults should be read from the resolved configuration.

ConceptExample option in that release
Active sequence limit--max-num-seqs
Per-step token budget--max-num-batched-tokens
Chunked prefill--enable-chunked-prefill
Maximum model context--max-model-len
GPU memory fraction--gpu-memory-utilization
Prefix reuse--enable-prefix-caching
Tensor/pipeline placement--tensor-parallel-size, --pipeline-parallel-size
Weight/KV representation--dtype, --quantization, --kv-cache-dtype
Disable graph execution for comparison--enforce-eager
Draft/verification configuration--speculative-config

Inspect the installed runtime’s version, help, startup logs, and support matrix before translating any row into a command. Provider APIs may expose only context/output limits or a service tier; hidden provider optimizations cannot be inferred from a fast response.

SGLang uses different names and sometimes different budget semantics. These mappings were checked against its rolling server-argument reference on 2026-10-26; pin the installed release and inspect its help before using them.

Generic conceptSGLang exampleSemantic detail
Active sequences--max-running-requestsRunning requests rather than all queued arrivals
Prefill chunk budget--chunked-prefill-sizeA chunk limit, not necessarily the same total iteration budget as another runtime
Static memory allocation--mem-fraction-staticIncludes weights and KV pool; not an interchangeable percentage with every other engine
Disable prefix reuse--disable-radix-cacheA disable flag, opposite polarity to an enable-prefix flag
Tensor/pipeline layout--tp-size, --pp-sizeCooperating ranks rather than independent replicas
Graph backend by phase--cuda-graph-backend-decode, --cuda-graph-backend-prefillRolling docs list --disable-cuda-graph as deprecated
Batch-invariant operation mode--enable-deterministic-inferenceRead the supported backend/model restrictions and run the invariance matrix

The SGLang deterministic-inference guide scopes its controls. Equivalent concepts across vLLM and SGLang do not imply equal defaults, identical kernels, or bitwise-equal outputs.

Save model and adapter hashes, tokenizer/template revision, runtime/container version, driver and device topology, resolved engine settings, environment variables affecting execution, generation defaults, and workload seed. Configuration files, command-line flags, model generation defaults, and request overrides can have different precedence. Capture the final values used by the request rather than assuming the checked-in configuration won.

  • Token budget: the amount of prefill/decode work admitted into a scheduling iteration.
  • Graph capture: recording a device execution graph for later replay with supported shapes and buffers.
  • Resolved configuration: the values actually selected after defaults and overrides are applied.

Every control should connect a bottleneck to a mechanism, a tradeoff, and a correctness check. Provider flag names are mappings onto those concepts.

  1. Why can a larger token budget improve aggregate throughput while violating an interactive SLO?

    AnswerIt permits more work in one step and amortizes overhead, but can make each step or prefill interruption longer.
  2. Why should cache and graph settings be measured together after separate experiments?

    AnswerBoth reserve memory. Each can work alone but fail or trigger preemption when combined.