vllm.config.scheduler
¶
Classes:
-
SchedulerConfig–Scheduler configuration.
SchedulerConfig
¶
Scheduler configuration.
Methods:
-
compile_factors–WARNING: Whenever a new field is added to this config, add it to
-
default_factory–Create a
SchedulerConfigwith default values for itsInitVars.
Attributes:
-
async_scheduling(bool | None) –If set to False, disable async scheduling. Async scheduling helps to
-
async_scheduling_depth(int) –Steps in flight with async scheduling: the step on the GPU plus
-
cache_aware_admission_threshold(float) –KV cache usage below which
cache_aware_admission_windowis not applied. -
cache_aware_admission_window(int) –Look-ahead window for cache-aware admission. Within the first N waiting
-
disable_chunked_mm_input(bool) –If set to true and chunked prefill is enabled, we do not want to
-
disable_hybrid_kv_cache_manager(bool | None) –If set to True, KV cache manager will allocate the same size of KV cache
-
enable_chunked_prefill(bool) –If True, prefill requests can be chunked based
-
encoder_cache_size(int | None) –Multimodal encoder cache size in tokens, only used in V1, or None to
-
is_multimodal_model(bool) –True if the model is multimodal.
-
long_prefill_token_threshold(int) –For chunked prefill, a request is considered long if the prompt is
-
long_prefill_token_threshold_adaptive(bool) –Floor the effective long prefill token threshold at a fair share of
-
max_async_kv_loads_per_step(int | None) –Maximum number of async KV connector loads (e.g. a P/D NIXL pull) that
-
max_num_active_seqs(int | None) –Maximum number of requests the scheduler admits into RUNNING.
-
max_num_batched_tokens(int) –Maximum number of tokens that can be processed in a single iteration.
-
max_num_encoder_input_tokens(int) –Multimodal encoder compute budget, only used in V1.
-
max_num_inflight_kv_loads(int | None) –Maximum number of requests holding KV blocks for an async KV connector
-
max_num_queued_reqs(int | None) –Maximum number of requests that can be in-flight (waiting or running)
-
max_num_queued_tokens(int | None) –Maximum total prompt tokens of requests currently in the prefill
-
max_num_scheduled_tokens(int | None) –Maximum number of tokens that the scheduler may issue in a single iteration.
-
max_num_seqs(int) –Maximum number of sequences to be processed in a single iteration.
-
policy(SchedulerPolicy) –The scheduling policy to use:
-
pp_microbatch_min_tokens(int) –Pipeline parallelism only. Size prefill chunks at the uncached prefill
-
prefill_schedule_interval(int) –Only admit prefill once every N engine steps, leaving the steps in
-
runner_type(RunnerType) –The runner type to launch for the model.
-
scheduler_cls(str | type[object] | None) –The scheduler class to use. "vllm.v1.core.sched.scheduler.Scheduler" is
-
scheduler_reserve_full_isl(bool) –If True, the scheduler checks whether the full input sequence length
-
stream_interval(int) –The interval (or buffer size) for streaming in terms of token length.
-
watermark(float) –Fraction of total KV cache blocks to keep free (the watermark) when
async_scheduling = None
class-attribute
instance-attribute
¶
If set to False, disable async scheduling. Async scheduling helps to avoid gaps in GPU utilization, leading to better latency and throughput.
async_scheduling_depth = Field(default=2, ge=2)
class-attribute
instance-attribute
¶
Steps in flight with async scheduling: the step on the GPU plus
async_scheduling_depth - 1 steps scheduled ahead of it (per pipeline
stage beyond the first). The default 2 overlaps one step's host work
(output processing, scheduling, input preparation) with the next step's GPU
work. A deeper queue helps when the host round trip is longer than a GPU
step, as in low-batch decode across nodes with speculative decoding.
Ignored without async scheduling.
cache_aware_admission_threshold = Field(default=0.5, ge=0.0, le=1.0)
class-attribute
instance-attribute
¶
KV cache usage below which cache_aware_admission_window is not applied.
Defaults to 0.5, so the window engages only once the cache is at least half used. Below that there is room for both prompts and reordering would change admission order without an eviction to avoid, which is a fairness cost for no benefit. It also means the per-request cache probe is skipped entirely while the cache is roomy. Set to 0.0 to reorder on every step.
cache_aware_admission_window = Field(default=0, ge=0)
class-attribute
instance-attribute
¶
Look-ahead window for cache-aware admission. Within the first N waiting requests, those whose prefix is already in the KV cache are admitted ahead of requests that would have to compute theirs, so a cold request does not evict blocks a resident one still needs. 0 (the default) admits strictly in arrival order.
Reordering is confined to the window and to requests that are merely waiting, so a request that is blocked or already partially computed keeps its position and nothing is moved past it. Requires prefix caching and the "fcfs" policy; it is ignored otherwise. Costs one prefix-cache lookup per request in the window per step, so prefer the smallest window that spans the usual queue depth.
disable_chunked_mm_input = False
class-attribute
instance-attribute
¶
If set to true and chunked prefill is enabled, we do not want to partially schedule a multimodal item. Only used in V1 This ensures that if a request has a mixed prompt (like text tokens TTTT followed by image tokens IIIIIIIIII) where only some image tokens can be scheduled (like TTTTIIIII, leaving IIIII), it will be scheduled as TTTT in one step and IIIIIIIIII in the next.
disable_hybrid_kv_cache_manager = None
class-attribute
instance-attribute
¶
If set to True, KV cache manager will allocate the same size of KV cache for all attention layers even if there are multiple type of attention layers like full attention and sliding window attention. If set to None, the default value will be determined based on the environment and starting configuration.
enable_chunked_prefill = True
class-attribute
instance-attribute
¶
If True, prefill requests can be chunked based
on the remaining max_num_batched_tokens.
The default value here is mainly for convenience when testing.
In real usage, this should be set in EngineArgs.create_engine_config.
encoder_cache_size = Field(default=None, ge=1)
class-attribute
instance-attribute
¶
Multimodal encoder cache size in tokens, only used in V1, or None to
derive it from max_num_batched_tokens.
This is a capacity: how many tokens of encoder output may stay resident,
including across requests, so a later request reusing the same image can skip
the encoder. It is unrelated to how much encoder work one step may do
(max_num_encoder_input_tokens), and deriving it from a per-step batch budget
caps cross-request reuse at max_num_batched_tokens / tokens_per_item items.
Size it as in_flight_items * tokens_per_item when a workload sends several
requests against the same image.
Raised to the largest single item if that would not fit. Costs GPU memory at the model's multimodal embedding width, which is taken from the KV cache.
Resolved in __post_init__; never None afterwards.
is_multimodal_model = False
class-attribute
instance-attribute
¶
True if the model is multimodal.
long_prefill_token_threshold = Field(default=0, ge=0)
class-attribute
instance-attribute
¶
For chunked prefill, a request is considered long if the prompt is longer than this number of tokens. 0 disables the cap (default). Ignored when chunked prefill is disabled.
The cap is not applied when the request is the only one in the batch, since there is no other request for it to starve.
long_prefill_token_threshold_adaptive = Field(default=False)
class-attribute
instance-attribute
¶
Floor the effective long prefill token threshold at a fair share of the token budget: max_num_batched_tokens divided by the number of queued and running requests. Only applies when long_prefill_token_threshold is nonzero.
max_async_kv_loads_per_step = Field(default=None, ge=1)
class-attribute
instance-attribute
¶
Maximum number of async KV connector loads (e.g. a P/D NIXL pull) that
start in one scheduling step. Each start allocates KV blocks for the whole
prompt on the main thread, and with data parallelism every rank waits for the
slowest step. max_num_inflight_kv_loads bounds how many loads are held;
this bounds how fast they start. None (default) means no limit.
Requests identified by the connector as async loads wait separately, so
this limit does not block ordinary waiting requests. Starting loads while
the running batch is full still requires max_num_inflight_kv_loads.
Experimental: this option may be changed or removed in a future release.
max_num_active_seqs = Field(default=None, ge=1)
class-attribute
instance-attribute
¶
Maximum number of requests the scheduler admits into RUNNING.
max_num_seqs sizes the model runner (per-request buffers and CUDA
graph capture) and is also the default admission limit. Setting this
lowers only the number of requests that may occupy RUNNING, so decode
batches stay smaller without shrinking runner or graph capacity. Must
be <= max_num_seqs. None (default) keeps current behavior.
max_num_batched_tokens = Field(default=DEFAULT_MAX_NUM_BATCHED_TOKENS, ge=1)
class-attribute
instance-attribute
¶
Maximum number of tokens that can be processed in a single iteration.
The default value here is mainly for convenience when testing.
In real usage, this should be set in EngineArgs.create_engine_config.
max_num_encoder_input_tokens = Field(init=False)
class-attribute
instance-attribute
¶
Multimodal encoder compute budget, only used in V1.
NOTE: This is not currently configurable. It will be overridden by max_num_batched_tokens in case max multimodal embedding size is larger.
max_num_inflight_kv_loads = Field(default=None, ge=1)
class-attribute
instance-attribute
¶
Maximum number of requests holding KV blocks for an async KV connector load (e.g. a P/D NIXL pull) before they run: loads in progress, or finished and waiting for a running slot.
Setting it also lets requests the connector may load asynchronously
(KVConnectorBase_V1.may_load_async, by default P/D remote-prefill
requests) start their loads while the running batch is full, so they are
ready when a slot frees. None (default) keeps current behavior: no cap,
and loads start only when a running slot is free.
max_num_queued_reqs = Field(default=None, ge=0)
class-attribute
instance-attribute
¶
Maximum number of requests that can be in-flight (waiting or running) at the same time, or None for no limit. When the limit is reached, new requests are rejected with HTTP 503 so the client can retry on another instance. This bounds vLLM's otherwise unbounded request queue and is primarily a coarse capacity valve.
Unlike max_num_seqs, which applies per data-parallel rank, this
limit is enforced in the API server process and counts in-flight
requests across all DP ranks it routes to. Size it as roughly
data_parallel_size * max_num_seqs plus the desired queue depth if
it should not bind before per-rank admission does.
max_num_queued_tokens = Field(default=None, ge=0)
class-attribute
instance-attribute
¶
Maximum total prompt tokens of requests currently in the prefill phase, or None for no limit. When the limit is reached, new requests are rejected with HTTP 503.
This is a TTFT QoS mechanism: by setting it to
target_TTFT * prefill_throughput you reject requests when the
prefill backlog would exceed the latency target. In a disaggregated
prefill-decode setup this maps directly to the prefill pool's
capacity.
Like max_num_queued_reqs, this limit is enforced in the API
server process and covers the prefill backlog across all DP ranks it
routes to, so prefill_throughput in the formula above is the
aggregate throughput of the deployment.
Note: the count is conservative. A partially prefilled request
still contributes its full prompt_len until it transitions out
of the prefill phase, because the scheduler's per-iteration
num_computed_tokens progress is not propagated to the API
server process during prefill (EngineCoreOutput is only
emitted once the request starts producing tokens). Similarly,
prefix-cache hits (num_cached_tokens) are only known to the
OutputProcessor after prefill completes. This overestimates the
real backlog, causing earlier rejection than strictly necessary
— the safe direction for QoS. The impact is limited to long
prompts under chunked prefill; short prompts that prefill in a
single iteration are unaffected.
max_num_scheduled_tokens = Field(default=None, ge=1)
class-attribute
instance-attribute
¶
Maximum number of tokens that the scheduler may issue in a single iteration.
This is usually equal to max_num_batched_tokens, but can be smaller in cases when the model might append tokens into the batch (such as speculative decoding). Defaults to max_num_batched_tokens.
max_num_seqs = Field(default=DEFAULT_MAX_NUM_SEQS, ge=1)
class-attribute
instance-attribute
¶
Maximum number of sequences to be processed in a single iteration.
The default value here is mainly for convenience when testing.
In real usage, this should be set in EngineArgs.create_engine_config.
policy = 'fcfs'
class-attribute
instance-attribute
¶
The scheduling policy to use:
- "fcfs" means first come first served, i.e. requests are handled in order of arrival.
- "priority" means requests are handled based on given priority (lower value means earlier handling) and time of arrival deciding any ties).
pp_microbatch_min_tokens = Field(default=4096, ge=0)
class-attribute
instance-attribute
¶
Pipeline parallelism only. Size prefill chunks at the uncached prefill backlog / pp_size, but not below this value, so they fill every stage. 0 disables.
prefill_schedule_interval = Field(default=1, ge=1)
class-attribute
instance-attribute
¶
Only admit prefill once every N engine steps, leaving the steps in between to decode alone. 1 (the default) admits prefill on every step.
A deferred step carries no prefill at all, including chunks of an already-admitted prompt, so a long prompt can take up to N times as many steps to finish prefilling.
runner_type = 'generate'
class-attribute
instance-attribute
¶
The runner type to launch for the model.
scheduler_cls = None
class-attribute
instance-attribute
¶
The scheduler class to use. "vllm.v1.core.sched.scheduler.Scheduler" is the default scheduler. Can be a class directly or the path to a class of form "mod.custom_class".
scheduler_reserve_full_isl = True
class-attribute
instance-attribute
¶
If True, the scheduler checks whether the full input sequence length fits in the KV cache before admitting a new request, rather than only checking the first chunk. Prevents over-admission and KV cache thrashing with chunked prefill.
stream_interval = Field(default=1, ge=1)
class-attribute
instance-attribute
¶
The interval (or buffer size) for streaming in terms of token length. A smaller value (1) makes streaming smoother by sending each token immediately, while a larger value (e.g., 10) reduces host overhead and may increase throughput by batching multiple tokens before sending.
watermark = Field(default=0.0, ge=0.0, lt=1.0)
class-attribute
instance-attribute
¶
Fraction of total KV cache blocks to keep free (the watermark) when admitting waiting or preempted requests into the running queue. This headroom helps avoid frequent KV cache eviction and the resulting repeated preemption of requests when GPU memory is scarce. Must be in the range [0.0, 1.0); 0.0 (the default) disables the watermark.
_skip_none_validation(value, handler)
classmethod
¶
Skip validation if the value is None when initialisation is delayed.
compile_factors()
¶
WARNING: Whenever a new field is added to this config, add it to
ignored_factors if it does not affect the computation graph.
default_factory(**kwargs)
staticmethod
¶
Create a SchedulerConfig with default values for its InitVars.