Skip to content

vllm.config.vllm

Classes:

Functions:

OptimizationLevel

Bases: IntEnum

Optimization level enum.

Attributes:

  • O0 –

    O0 : No optimization. no compilation, no cudagraphs, no other

  • O1 –

    O1: Quick optimizations. Dynamo+Inductor compilation and Piecewise

  • O2 –

    O2: Full optimizations. -O1 as well as Full and Piecewise cudagraphs.

  • O3 –

    O3: Currently the same as -O2s.

O0 = 0 class-attribute instance-attribute

O0 : No optimization. no compilation, no cudagraphs, no other optimization, just starting up immediately

O1 = 1 class-attribute instance-attribute

O1: Quick optimizations. Dynamo+Inductor compilation and Piecewise cudagraphs

O2 = 2 class-attribute instance-attribute

O2: Full optimizations. -O1 as well as Full and Piecewise cudagraphs.

O3 = 3 class-attribute instance-attribute

O3: Currently the same as -O2s.

VllmConfig

Dataclass which contains all vllm-related configuration. This simplifies passing around the distinct configurations in the codebase.

Methods:

Attributes:

additional_config = Field(default_factory=dict) class-attribute instance-attribute

Additional config for specified platform. Different platforms may support different configs. Make sure the configs are valid for the platform you are using. Contents must be hashable.

attention_config = Field(default_factory=AttentionConfig) class-attribute instance-attribute

Attention configuration.

aux_output_config = Field(default_factory=AuxOutputConfig) class-attribute instance-attribute

Execution auxiliary output configuration.

cache_config = Field(default_factory=CacheConfig) class-attribute instance-attribute

Cache configuration.

compilation_config = Field(default_factory=CompilationConfig) class-attribute instance-attribute

torch.compile and cudagraph capture configuration for the model.

As a shorthand, one can append compilation arguments via -cc.parameter=argument such as -cc.mode=3 (same as -cc='{"mode":3}').

You can specify the full compilation config like so: {"mode": 3, "cudagraph_capture_sizes": [1, 2, 4, 8]}

device_config = Field(default_factory=DeviceConfig) class-attribute instance-attribute

Device configuration.

diffusion_config = None class-attribute instance-attribute

Diffusion LLM (dLLM) configuration.

ec_events_config = None class-attribute instance-attribute

The configurations for encoder cache event publishing.

ec_manager_config = Field(default_factory=EncoderCacheManagerConfig) class-attribute instance-attribute

The configurations for custom encoder cache manager.

ec_transfer_config = None class-attribute instance-attribute

The configurations for distributed EC cache transfer.

engram_config = None class-attribute instance-attribute

N-gram embedding storage and sharding settings.

gpu_iteration_timing property

Whether the output worker times logged iterations with CUDA events. Otherwise they are logged without an elapsed time.

instance_id = '' class-attribute instance-attribute

The ID of the vLLM instance.

kernel_config = Field(default_factory=KernelConfig) class-attribute instance-attribute

Kernel configuration.

kv_events_config = None class-attribute instance-attribute

The configurations for event publishing.

kv_transfer_config = None class-attribute instance-attribute

The configurations for distributed KV cache transfer.

load_config = Field(default_factory=LoadConfig) class-attribute instance-attribute

Load configuration.

logging_config = Field(default_factory=LoggingConfig) class-attribute instance-attribute

Logging configuration.

lora_config = None class-attribute instance-attribute

LoRA configuration.

mamba_config = Field(default_factory=MambaConfig) class-attribute instance-attribute

Mamba configuration.

model_config = None class-attribute instance-attribute

Model configuration.

needs_dp_coordinator property

Determine if the DPCoordinator process is needed.

The DPCoordinator is needed in two cases: 1. For MoE models with DP > 1: to handle wave coordination (even in external LB mode, since wave coordination runs in the coordinator) 2. For non-MoE models in internal/hybrid LB mode: to collect and publish queue stats for load balancing across DP ranks

Returns:

  • bool –

    True if DPCoordinator process is needed, False otherwise.

num_hash_lookahead_tokens = Field(default=0, init=False) class-attribute instance-attribute

Tokens after each block that its hash covers; 0 unless draft KV reads ahead.

num_lookahead_tokens property

KV slots to reserve past the tokens the target model is scheduled for.

The drafter writes KV for positions beyond the target model's query range, so every component that reserves blocks must add this margin: the scheduler through allocate_slots, and the worker warmup, which builds its own SchedulerOutputs. Consumers must read this property rather than re-deriving their own per-method lookahead, so the scheduler and warmup cannot drift apart.

num_prefill_lookahead_tokens property

Prefill tokens past the computed range that the drafter reads.

Mid-prefill the drafter consumes tokens the target model has not been scheduled for yet, so every component that has to keep them available must apply this margin: the scheduler, which never ends a chunk within it and shifts encoder scheduling by it, and the components that read num_reprefillable_tokens. Consumers must read this property rather than re-deriving their own per-method lookahead, so those components cannot drift apart.

num_reprefillable_tokens property

Trailing computed tokens whose drafter KV is not final yet: of the num_prefill_lookahead_tokens read past the prompt end, only the first is sampled, so the rest are rewritten later.

num_scheduled_spec_tokens property

See SpeculatorConfig.num_scheduled_spec_tokens.

observability_config = Field(default_factory=ObservabilityConfig) class-attribute instance-attribute

Observability configuration.

offload_config = Field(default_factory=OffloadConfig) class-attribute instance-attribute

Model weight offloading configuration.

optimization_level = OptimizationLevel.O2 class-attribute instance-attribute

The optimization level. These levels trade startup time cost for performance, with -O0 having the best startup time and -O3 having the best performance. -O2 is used by default. See OptimizationLevel for full description.

parallel_config = Field(default_factory=ParallelConfig) class-attribute instance-attribute

Parallel configuration.

performance_mode = 'balanced' class-attribute instance-attribute

Performance mode for runtime behavior, 'balanced' is the default. 'interactivity' favors low end-to-end per-request latency at small batch sizes (fine-grained CUDA graphs, latency-oriented kernels). 'throughput' favors aggregate tokens/sec at high concurrency (larger CUDA graphs, more aggressive batching, throughput-oriented kernels).

profiler_config = Field(default_factory=ProfilerConfig) class-attribute instance-attribute

Profiling configuration.

quant_config = None class-attribute instance-attribute

Quantization configuration.

reasoning_config = None class-attribute instance-attribute

The configurations for reasoning model.

scheduler_config = Field(default_factory=SchedulerConfig.default_factory) class-attribute instance-attribute

Scheduler configuration.

shutdown_timeout = Field(default=0, ge=0) class-attribute instance-attribute

Shutdown grace period for in-flight requests. Shutdown will be delayed for up to this amount of time to allow already-running requests to complete. Any remaining requests are aborted once the timeout is reached.

speculative_config = None class-attribute instance-attribute

Speculative decoding configuration.

structured_outputs_config = Field(default_factory=StructuredOutputsConfig) class-attribute instance-attribute

Structured outputs configuration.

uniform_decode_query_len property

Query length of every request in a uniform decode batch.

A decode step submits one query for the newly sampled token plus one for each draft token, so the widest uniform decode batch the scheduler can build is max_num_seqs * uniform_decode_query_len tokens. Anything that has to cover a decode batch reads this, so the sizing rule cannot drift between the places that apply it.

This deliberately does not derive from the KV slots a drafter reserves past the target's query range, which is a reservation contract rather than a query-length one. The two do not differ by a constant: DFlash reserves num_speculative_tokens + 1 slots yet still verifies 1 + num_speculative_tokens queries, while EAGLE reserves num_speculative_tokens and verifies the same 1 + n. Deriving one from the other would under-size EAGLE by a full request width, which is the failure this property exists to prevent.

use_cumem_cudagraph_pool property

Whether CUDA graphs go to the cuMem pool that sleep offloads.

use_replayssm_trackers property

Mamba2 ReplaySSM whose rings follow the runner-committed trackers.

watchdog_config = Field(default_factory=WatchdogConfig) class-attribute instance-attribute

Configuration for the stack-dump watchdog.

watermark_config = None class-attribute instance-attribute

Text watermarking configuration.

weight_transfer_config = None class-attribute instance-attribute

The configurations for weight transfer during RL training.

__post_init__()

Verify configs are valid & consistent with each other.

_apply_optimization_level_defaults(defaults)

Apply optimization level defaults using self as root.

Recursively applies values from defaults into nested config objects. Only fields present in defaults are overwritten.

If the user configuration does not specify a value for a default field and if the default field is still None after all user selections are applied, then default values will be applied to the field. User specified fields will not be overridden by the default.

Parameters:

  • defaults

    (dict[str, Any]) –

    Dictionary of default values to apply.

_disable_cudagraphs_for_stock_torch_compile()

Disable CUDA graphs, which the CUDA graph manager would otherwise capture around the stock-compiled model.

_get_dbo_unsupported_features()

Collect what the model runner cannot combine with DBO.

The runner microbatches a decoder forward pass (drafting runs whole, after it). Anything else that slices or replays the batch differently (adapters, pipeline stages, prefill context parallelism, encoders) is not handled yet.

_get_model_runner_unsupported_features()

Collect features the GPU model runner does not support.

_get_quantization_config(model_config, load_config) staticmethod

Get the quantization config.

_get_standalone_cpu_model_runner_unsupported_features()

Collect features not supported by the standalone CPU model runner.

_limit_max_model_len_to_draft()

Lower max_model_len to the draft model's when the model runner can't serve longer sequences.

_maybe_fall_back_from_auto_one_sided_all2all()

Keep the "auto" all2all default to models one-sided supports.

_one_sided_all2all_unsupported_reason()

Why the deployment cannot use flashinfer_nvlink_one_sided, if it can't.

_post_init_kv_transfer_config()

Update KVTransferConfig based on top-level configs in VllmConfig.

Right now, this function reads the offloading settings from CacheConfig and configures the KVTransferConfig accordingly.

_raise_dbo_thresholds_for_spec_decode()

The speculative counterpart of ParallelConfig's DBO threshold check.

A uniform decode batch below one request per microbatch cannot be split on a request boundary, and an idle DP rank's one-request dummy batch must stay below the thresholds too. Such batches gain nothing from microbatching, so raise the thresholds rather than reject the config.

_reject_mismatched_float_kv_cache()

Reject an explicit float16/bfloat16 KV dtype that differs from the model.

_resolve_and_verify_engram_config()

Resolve defaults and validate n-gram embedding settings.

_resolve_extensible_kv_cache()

Settle enable_extensible_kv_cache: on where supported if unset, an error if explicitly requested where unsupported.

Runs once per model: configs derived for sub-models (with_hf_config) may pick a different runner, and must not revisit the decision.

_resolve_mm_embedding_inputs()

Accept embedding inputs, tensor optional, on disaggregated consumers.

An EC consumer loads embeddings from its connector. A KV consumer receives the prompt KV produced from those embeddings, so it does not need the tensors either. On every other deployment a missing tensor is a client error and must keep failing fast in the frontend.

_resolve_mm_encoder_only()

Enable encoder-only mode for a dedicated EC producer.

_resolve_mm_processor_device()

Settle --mm-processor-device=auto now that the EC role is known.

"auto" means "the accelerator, but only where the processor has it to itself and its output can be handed over without a copy back to host": an encode-only instance whose tensor transport carries device tensors. Every other deployment keeps the processor on CPU.

An explicit device -- from --mm-processor-device or straight from mm_processor_kwargs -- is already folded in by MultiModalConfig, so it is left alone here and validated by _validate_mm_processor_device.

_resolve_mm_video_decode_device()

Default video decoding to torchcodec GPU backend for EPD encoder-only instance if the mm processor runs on CUDA.

The processor consumes the decoded frames on-device in that case, so keeping the frames on the GPU skips the host round-trip through the CPU media path. An explicit codec/backend choice in --media-io-kwargs is left alone, and the default is skipped where torchcodec (or its FFmpeg runtime) is unavailable.

_resolve_num_hash_lookahead_tokens()

Resolve the hash lookahead after the relevant configs are finalized.

_resolve_specialized_decode_switch()

kernel_config.monokernel and additional_config={"decode_backend": "latency_specialized"} are one switch: setting either sets both, whichever one a model reads.

_set_compile_ranges()

Set the compile ranges for the compilation config.

_set_config_default(config_obj, key, value)

Set config attribute to default if not already set by user.

Parameters:

  • config_obj

    (Any) –

    Configuration object to update.

  • key

    (str) –

    Attribute name.

  • value

    (Any) –

    Default value (static or callable).

_set_cudagraph_sizes()

VLLM defines the default candidate list of batch sizes for CUDA graph capture as:

```python default_max_graph_size = platform_defaults.legacy_max_tokens decode_query_len = self.uniform_decode_query_len max_graph_size = min( max_num_seqs * decode_query_len * 2, default_max_graph_size )

1, 2, 4, then multiples of 8 up to 256 and then multiples of 16

up to max_graph_size

cudagraph_capture_sizes = [1, 2, 4] + list(range(8, 256, 8)) + list( range(256, max_graph_size + 1, 16))

max_num_batched_tokens is also appended to the list if it fits within max_cudagraph_capture_size, so the max batch size is captured even when off-stride. Uniform decode sizes are appended when they fit within the platform's default capture ceiling, since they need not land on an 8- or 16-token stride.

In the end, vllm_config.compilation_config.cudagraph_capture_sizes will be the final sizes to capture cudagraph (in ascending order).

These sizes are used to capture and reuse CUDA graphs for performance-critical paths (e.g., decoding). Capturing enables significantly faster kernel dispatch by avoiding Python overhead. The list is then filtered based on max_num_batched_tokens (e.g., 8192 on most GPUs), which controls the total allowed number of tokens in a batch. Since each sequence may have a variable number of tokens, the maximum usable batch size will depend on actual sequence lengths.

Example: With max_num_batched_tokens = 8192, and typical sequences averaging ~32 tokens, most practical batch sizes fall below 256. However, the system will still allow capture sizes up to the platform default if shape and memory permit.

Note: If users explicitly specify cudagraph capture sizes in the compilation config, those will override this default logic. At runtime:

- If batch size <= one of the `cudagraph_capture_sizes`, the closest
padded CUDA graph will be used.
- If batch size > largest `cudagraph_capture_sizes`, cudagraph will
not be used.

_set_max_num_scheduled_tokens()

In most cases, the scheduler may schedule a batch with as many tokens as the worker is configured to handle.

_split_cudagraph_capture_sizes(legacy_sizes, target_query_lens)

Resolve the prefill (token) and decode (request) CUDA graph capture sizes, each from its own sizes, cap or default and never from the other's, and record every graph's token count in cudagraph_capture_sizes and max_cudagraph_capture_size.

Parameters:

  • legacy_sizes

    (bool) –

    The deprecated cudagraph_capture_sizes or max_cudagraph_capture_size was set before resolution.

  • target_query_lens

    (dict[int, int]) –

    The target model's decode query lengths, each mapped to the most requests its batches have.

_sync_draft_all2all_backend()

Make the draft follow the target's final all2all backend.

The draft's ParallelConfig is built before this config, so it holds the target's backend from before any fallback, while both share one EP communicator.

_uses_breakable_cudagraph_for_batch_invariance()

Avoid freezing runtime-M tile lookup in compiled forward (#54243). Breakable graphs look up tuned bf16, unquantized qkv/o/gate_up/down tiles at capture; lm_head runs outside compiled forward and does not benefit. gpt-oss MXFP4 quantizes only MoE experts; its dense Linear layers stay bf16. Plain "mxfp4" is excluded: as an online shorthand it also quantizes Linear layers. An online quantization_config that quantizes Linear layers (linear or targets) is excluded; a moe-only one is not.

_validate_batch_sharded_sampling()

Validate enable_batch_sharded_sampling against the rest of the config.

_validate_mm_processor_device()

Hand the EC config to MultiModalConfig, which owns the rule.

_verify_aux_output_compatibility()

Reject configurations unsupported by enabled auxiliary outputs.

_verify_direct_reload_compat()

Reject configurations that direct weight reload cannot support.

_verify_kv_transfer_compat()

Reject configurations that silently corrupt KV transfers.

adjust_dcp_kv_cache_interleave_size(kv_cache_groups)

Resolve the NIXL and MoRIIO P/D DCP interleave from the global KV cache groups.

Called once by the engine core before profiling; workers only assign the result via set_kv_cache_layout.

compile_debug_dump_path()

Returns a rank-aware path for dumping torch.compile debug information.

compile_factors(include_version=True)

WARNING: Whenever a new field is added to this config, ensure that it is included in the factors list if it affects the computation graph.

Provide a hash that uniquely identifies all the configs that affect the structure of the computation graph from input ids/embeddings to the final hidden states, excluding anything before input ids/embeddings and after the final hidden states.

Parameters:

  • include_version

    (bool, default: True ) –

    Include the vLLM version in the hash.

enable_trace_function_call_for_thread()

Set up function tracing for the current thread, if enabled via the VLLM_TRACE_FUNCTION environment variable.

get_decode_cudagraph_query_lens(decode_query_len)

Map each uniform decode query length of a target-shaped runner, whose widest is decode_query_len, to the most requests its batches have.

Dynamic speculative decoding drafts as many tokens as its schedule gives the batch size, so a query length only runs up to the largest batch size that drafts its number of tokens.

get_draft_decode_cudagraph_request_sizes()

Request counts of the FULL graphs of one-token draft decodes (see SpeculatorConfig.one_token_draft_decodes): the request-count grid up to max_num_seqs. The target's decode cap can be far lower: off SM100 its default is 512 / (1 + K) requests, 64 at K=7. Above it the K - 1 draft steps would run eagerly and pay their host launch time on every step, while their graphs are small. Empty without such steps or decode graphs.

get_varlen_decode_cudagraph_token_sizes(decode_query_len)

Token counts of the FULL decode graphs for adaptive verification, whose decode batches mix query lengths up to decode_query_len: the token-count grid up to max_decode_cudagraph_capture_requests requests of decode_query_len tokens each, within the decode token budget.

validate_block_size()

Validate block_size against DCP and mamba constraints.

Called after Platform.update_block_size_for_backend() has finalised block_size.

_has_heterogeneous_moe_layers(model_config)

Whether MoE layers differ in num_experts or top_k (per-layer block_configs).

_one_sided_model_unsupported_reason(model_config)

Why a model's MoE layers cannot use flashinfer_nvlink_one_sided.

default_breakable_cudagraph_architectures() cached

Architectures defaulting to breakable CUDA graphs on this platform.

enable_act_fusion(cfg)

Enable if either SiLU+Mul or quant FP8 custom op is active; otherwise Inductor handles fusion. Also enable for FP4 models as FP4 quant is always custom so Inductor cannot fuse it.

enable_allreduce_rms_fusion(cfg)

Enable if TP > 1 and Hopper/Blackwell and flashinfer installed.

enable_mla_dual_rms_norm_fusion(cfg)

Enable MLA dual RMS norm fusion on ROCm with AITER.

enable_norm_fusion(cfg)

Enable if either RMS norm or quant FP8 custom op is active; otherwise Inductor handles fusion.

enable_norm_pad_fusion(cfg)

Enable if using AITER RMSNorm and hidden size is 2880 i.e. gpt-oss.

enable_qk_norm_rope_kvcache(cfg)

Enable fused QK-norm + RoPE/MRoPE + KV cache update with AITER.

enable_rope_kvcache_fusion(cfg)

Enable if the RoPE custom op or another RoPE fusion is requested and use_inductor_graph_partition is enabled.

enable_rope_kvcache_mla_fusion(cfg)

Enable if use_inductor_graph_partition is enabled.

get_cached_compilation_config() cached

Cache config to avoid repeated calls to get_current_vllm_config()

get_layers_from_vllm_config(vllm_config, layer_type, layer_names=None)

Get layers from the vLLM config.

Parameters:

  • vllm_config

    (VllmConfig) –

    The vLLM config.

  • layer_type

    (type[T]) –

    The type of the layer to get.

  • layer_names

    (Iterable[str] | None, default: None ) –

    The names of the layers to get. If None, return all layers.

set_current_vllm_config(vllm_config, check_compile=False, prefix=None)

Temporarily set the current vLLM config. Used during model initialization. We save the current vLLM config in a global variable, so that all modules can access it, e.g. custom ops can access the vLLM config to determine how to dispatch.