Skip to content

vllm.config.compilation

Classes:

Functions:

CUDAGraphCaptureDefaults dataclass

Default capture limits, separate from explicit compilation settings.

Leaving both split limits unset preserves the shared token grid. Platforms opting into independent grids supply both prefill and decode limits.

CUDAGraphMode

Bases: Enum

Constants for the cudagraph mode in CompilationConfig. Meanwhile, the subset enum NONE, PIECEWISE and FULL are also treated as concrete runtime mode for cudagraph runtime dispatching.

CompilationConfig

Configuration for compilation.

You must pass CompilationConfig to VLLMConfig constructor. VLLMConfig's post_init does further initialization. If used outside of the VLLMConfig, some fields will be left in an improper state.

It contains PassConfig, which controls the custom fusion/transformation passes. The rest has three parts:

Why we have different sizes for cudagraph and inductor: - cudagraph: a cudagraph captured for a specific size can only be used for the same size. We need to capture all the sizes we want to use. - inductor: a graph compiled by inductor for a general shape can be used for different sizes. Inductor can also compile for specific sizes, where it can have more information to optimize the graph with fully static shapes. However, we find the general shape compilation is sufficient for most cases. It might be beneficial to compile for certain small batchsizes, where inductor is good at optimizing.

Methods:

Attributes:

backend = '' class-attribute instance-attribute

The backend for compilation. It needs to be a string:

  • "" (empty string): use the default backend ("inductor" on CUDA-alike platforms).
  • "eager"/"openxla"/...: use the specified backend registered in PyTorch.
  • "full.module.name": a qualified name which can be used to import the

backend function. We use string to avoid serialization issues when using compilation in a distributed setting. When the compilation mode is 1 or 2, the backend is used for the compilation directly (it sees the whole graph). When the compilation mode is 3, the backend supports both whole graph and piecewise compilation, available backends include eager, inductor, and custom backends, the latter of which can be defined via get_compile_backend. Furthermore, compilation is only piecewise if splitting ops is set accordingly and use_inductor_graph_partition is off. Note that the default options for splitting ops are sufficient for piecewise compilation.

cache_dir = '' class-attribute instance-attribute

The directory to store the compiled graph, to accelerate Inductor compilation. By default, it will use model-related information to generate a cache directory.

compilation_time = field(default=0.0, init=False) class-attribute instance-attribute

time taken for compilation

compile_cache_save_format = field(default_factory=lambda: envs.VLLM_COMPILE_CACHE_SAVE_FORMAT) class-attribute instance-attribute

Format for saving torch compile cache:

  • "binary": saves as binary file (multiprocess safe)

  • "unpacked": saves as directory structure for inspection/debugging (NOT multiprocess safe)

Defaults to VLLM_COMPILE_CACHE_SAVE_FORMAT if not specified.

compile_mm_encoder = False class-attribute instance-attribute

Whether or not to compile the multimodal encoder. Currently, this only works for Qwen2_5_vl and mLLaMa4 models on selected platforms. It may also work for models loaded with the Transformers modeling backend if the encoder is compilable. Disabled by default until more models are supported/tested to work.

compile_ranges_endpoints = None class-attribute instance-attribute

Endpoints for Inductor compile ranges. The compile ranges are [1, endpoints[0]], [endpoints[0] + 1, endpoints[1]], ..., [endpoints[-1] + 1, max_num_batched_tokens]. Compile sizes are also used single element ranges, the range is represented as [compile_sizes[i], compile_sizes[i]].

If a range overlaps with the compile size, graph for compile size will be prioritized, i.e. if we have a range [1, 8] and a compile size 4, graph for compile size 4 will be compiled and used instead of the graph for range [1, 8].

compile_sizes = None class-attribute instance-attribute

Sizes to compile for inductor. In addition to integers, it also supports "cudagraph_capture_sizes" to specify the sizes for cudagraph capture.

cudagraph_capture_sizes = None class-attribute instance-attribute

Sizes to capture cudagraph. - None (default): capture sizes are inferred from vllm config. - list[int]: capture sizes are specified as given.

Deprecated with model runner V2, which takes prefill_cudagraph_capture_token_sizes and decode_cudagraph_capture_request_sizes instead. Set there, these token counts are the prefill sizes and, rounded up to whole requests of the target model's query length, the decode sizes. After config resolution it holds the token count of every captured graph.

cudagraph_copy_inputs = False class-attribute instance-attribute

Deprecated: has no effect and will be removed in v0.37.0. The model runner already passes persistent input buffers to CUDA graphs.

cudagraph_decoder_replay = True class-attribute instance-attribute

Run the decoder replay layers of YOCO models (e.g. DeepSeek-V4.1) in CUDA graphs of their own, and trim them in PIECEWISE graph steps. Requires breakable PIECEWISE graphs; off under LoRA, prompt embeddings and non-first PP ranks.

cudagraph_mm_encoder = False class-attribute instance-attribute

Enable CUDA graph capture for multimodal encoder (ViT). When enabled, captures full encoder forward as CUDA graph for each token budget level.

cudagraph_mode = None class-attribute instance-attribute

The mode of the cudagraph:

  • NONE, no cudagraph capture.
  • PIECEWISE.
  • FULL.
  • FULL_DECODE_ONLY.
  • FULL_AND_PIECEWISE. (v1 default)

PIECEWISE mode build piecewise cudagraph only, keeping the cudagraph incompatible ops (i.e. some attention ops) outside the cudagraph for general flexibility.

FULL mode: Capture full cudagraph for all batches. Can be good for small models or workloads with small prompts; not supported by many backends. Generally for performance FULL_AND_PIECEWISE is better.

FULL_DECODE_ONLY mode: Capture full cudagraph for decode batches only. Mixed prefill-decode batches are run without cudagraphs. Can be good for decode instances in a P/D setup where prefill is not as important so we can save some memory.

FULL_AND_PIECEWISE mode: Capture full cudagraph for decode batches and piecewise cudagraph for prefill and mixed prefill-decode batches. This is the most performant mode for most models and is the default.

Currently, the cudagraph mode is only used for the v1 engine. Note that the cudagraph logic is generally orthogonal to the compilation logic. While piecewise cudagraphs require piecewise compilation (mode=VLLM_COMPILE and non-empty splitting_ops), full cudagraphs are supported with and without compilation.

Warning: This flag is new and subject to change in addition more modes may be added.

cudagraph_num_of_warmups = 0 class-attribute instance-attribute

Number of warmup runs for cudagraph. It means the first several runs will be treated as warmup runs. Only after that, the execution will be recorded, and the recorded cudagraph will be used for subsequent runs.

cudagraph_specialize_lora = True class-attribute instance-attribute

Whether to create separate cuda graphs for cases with and without active LoRA adapters. When set to False, the LoRA-enabled cuda graph will be used for all cases, incurring the overhead of running LoRA ops even when no adapters are active. Setting this to True will remove this overhead at the cost of increased startup time and slightly higher memory usage. When enable_lora is False, this option has no effect.

custom_ops = field(default_factory=list) class-attribute instance-attribute

Fine-grained control over which custom ops to enable/disable. Use 'all' to enable all, 'none' to disable all. Also specify a list of custom op names to enable (prefixed with a '+'), or disable (prefixed with a '-'). Examples:

  • ['all', '-op1'] to enable all except op1
  • ['none', '+op1', '+op2'] to enable only op1 and op2

By default, all custom ops are enabled when running without Inductor and disabled when running with Inductor: mode>CompilationMode.NONE and backend="inductor". Inductor generates (fused) Triton kernels for disabled custom ops.

debug_dump_path = None class-attribute instance-attribute

The path to dump the debug information.

decode_cudagraph_capture_request_sizes = None class-attribute instance-attribute

Request counts of the FULL CUDA graphs for uniform decode batches, whose requests all have the same query length q: 1 + num_speculative_tokens for the target model, K or K + 1 for DSpark, DFlash and multi-module MTP drafters. A runner captures n requests as n * q tokens, for each n up to the most requests its batches have and the recorded max_cudagraph_capture_size // q. One-token draft decodes (EAGLE, EAGLE3, MTP) take the request-count grid up to max_num_seqs instead. [] captures none. None (default): the request-count grid up to max_decode_cudagraph_capture_requests.

With adaptive verification, the target model's decode batches mix query lengths, so they take token-keyed FULL graphs instead: the token-count grid up to max_decode_cudagraph_capture_requests * (1 + num_speculative_tokens) tokens, within max_decode_cudagraph_capture_tokens. These request counts then set the draft decode graphs alone.

decoder_replay_cudagraph_capture_sizes = field(default_factory=list) class-attribute instance-attribute

Decoder replay CUDA graph sizes for YOCO models (e.g. DeepSeek-V4.1), at most max_num_batched_tokens. If empty: the powers of two below sliding_window, then multiples of sliding_window up to min(max_cudagraph_capture_size, max_num_seqs * sliding_window), coarser past 16 * sliding_window. Larger replay batches run eagerly.

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

For YOCO models (e.g. DeepSeek-V4.1), PIECEWISE graphs with at least this many padded tokens trim the decoder replay batch; must exceed the replay window (128), below which nothing trims. Independent of the replay graph capture sizes; eager steps still trim.

disabled_custom_ops = field(default_factory=Counter, init=False) class-attribute instance-attribute

custom ops that are disabled

dynamic_shapes_config = field(default_factory=DynamicShapesConfig) class-attribute instance-attribute

Configuration for dynamic shapes options

enabled_custom_ops = field(default_factory=Counter, init=False) class-attribute instance-attribute

custom ops that are enabled

encoder_compilation_time = field(default=0.0, init=False) class-attribute instance-attribute

time taken for multimodal encoder compilation

encoder_cudagraph_max_frames_per_batch = None class-attribute instance-attribute

Maximum total video frames per batch for encoder CUDA graph capture. Controls the cu_seqlens buffer size (one entry per attention sequence, i.e. one per video frame). If None (default), auto-inferred as encoder_cudagraph_max_vision_items_per_batch * max_frames_per_video (model-specific value according to processing_info). Positive value overrides auto-inference and applies to all budget levels. If we limit the video count per prompt to 0, it will also be set to 0 (i.e., fall back to image-only mode).

encoder_cudagraph_max_token_budget = 5120 class-attribute instance-attribute

Largest auto-generated encoder CUDA graph token budget; must be positive or None. A batch with more tokens runs eagerly. The default balances graph memory against replay coverage; performance depends on the model, batch shape, and hardware. None captures up to the model's largest budget. Ignored when encoder_cudagraph_token_budgets is set.

encoder_cudagraph_max_vision_items_per_batch = 0 class-attribute instance-attribute

Maximum number of images/videos per batch for encoder CUDA graph capture. Determines the fixed batch size used during graph capture. If 0 (default), auto-inferred as max_budget // min_budget from the model's budget range. User-provided positive value overrides auto-inference. A batch with more items runs eagerly in one forward.

encoder_cudagraph_token_budgets = field(default_factory=list) class-attribute instance-attribute

Token budget levels for encoder CUDA graph capture. Each budget defines a fixed token capacity. At runtime, a batch replays the smallest budget that holds it, or runs eagerly if none does. If empty (default), generated over the model's budget range: quarter-octave steps up to 1024 tokens, steps of 128 up to 2560, then 1/8-octave steps, up to encoder_cudagraph_max_token_budget. User-provided values override auto-inference. Example: [2048, 4096, 8192, 13824]

fast_moe_cold_start = None class-attribute instance-attribute

Optimization for fast MOE cold start.

This is a bit of a hack that assumes that: 1. the only decoder forward pass being run is the current model 2. the decoder forward pass runs all of the MOEs in the order in which they are initialized

When the above two conditions hold, this option greatly decreases cold start time for MOE models.

The options are: - True: optimization is always on - False: optimization is always off - None: optimization is on usually but off for speculative decoding

If conditions 1&2 don't hold then this option will lead to silent incorrectness. The only condition in which this doesn't hold is speculative decoding, where there is a draft model that may have MOEs in them.

NB: We're working on a longer-term solution that doesn't need these assumptions.

inductor_compile_config = field(default_factory=dict) class-attribute instance-attribute

Additional configurations for inductor. - None: use default configurations.

inductor_passes = field(default_factory=dict) class-attribute instance-attribute

Additional passes for inductor. It is a dictionary from pass name to pass function qualified name. We use function name because the config uses JSON format. If we pass the config from Python, functions can also be passed directly via Python object constructor, e.g. CompilationConfig(inductor_passes={"a": func}).

ir_enable_torch_wrap = None class-attribute instance-attribute

If True, enable vllm_ir torch custom op wrapping during the forward pass. When False, torch custom op wrapping is disabled, allowing Dynamo to trace the selected implementation directly or avoiding torch custom op overhead in eager mode. Defaults to True when using Inductor with vllm-compile (backend=="inductor" and mode == VLLM_COMPILE), False otherwise.

local_cache_dir = field(default=None, init=False) class-attribute instance-attribute

local cache dir for each rank

max_cudagraph_capture_size = None class-attribute instance-attribute

The maximum cudagraph capture size.

If cudagraph_capture_sizes is specified, this will be set to the largest size in that list (or checked for consistency if specified). If cudagraph_capture_sizes is not specified, the list of sizes is generated automatically following the pattern:

[1, 2, 4] + list(range(8, 256, 8)) + list(
range(256, max_cudagraph_capture_size + 1, 16))

If not specified, max_cudagraph_capture_size is capped at 512 by default, or 1024 on data center Blackwell GPUs. This avoids OOM in tight memory scenarios with small max_num_seqs, and limits capture of large graphs that increase startup time and memory usage. Uniform decode sizes are appended only within this default ceiling.

Deprecated with model runner V2, which takes max_prefill_cudagraph_capture_tokens (tokens) and max_decode_cudagraph_capture_requests (requests) instead. After config resolution it holds the token count of the widest captured graph.

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

Largest request count of a decode CUDA graph; with adaptive verification it also bounds the verify graphs' tokens (see decode_cudagraph_capture_request_sizes). None (default): max_num_seqs on SM100 GPUs, otherwise the most requests that the platform's default max_cudagraph_capture_size holds at the target model's query lengths. Graphs no wider than the widest prefill graph mostly reuse its memory in the shared graph pool. Wider graphs, and FULL graphs of models with large per-token buffers (e.g. DeepSeek's indexer at a long max_model_len), take memory from the KV cache.

max_decode_cudagraph_capture_tokens = Field(default=None, ge=1) class-attribute instance-attribute

Token budget of a uniform decode CUDA graph: each runner captures n requests at query length q only while n * q fits, and wider decode batches take the prefill graphs. It also bounds adaptive verification's token-keyed graphs. None (default): 8192 on SM100 GPUs, otherwise no budget. Wider decode graphs take memory from the KV cache.

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

Largest token count of a prefill CUDA graph. None (default): 8192 on SM100 GPUs, otherwise the platform's default max_cudagraph_capture_size; at most max_num_batched_tokens. More and wider graphs take memory from the KV cache and lengthen startup.

mode = None class-attribute instance-attribute

The compilation approach used for torch.compile-based compilation of the model.

  • None: If None, we will select the default compilation mode. For V1 engine this is 3.
  • 0: NONE: No torch.compile compilation is applied, model runs in fully eager pytorch mode. The model runs as-is.
  • 1: STOCK_TORCH_COMPILE: The standard torch.compile compilation pipeline.
  • 2: DYNAMO_TRACE_ONCE: Single Dynamo trace through the model, avoiding recompilation by removing guards. Requires no dynamic-shape-dependent control-flow.
  • 3: VLLM_COMPILE: Custom vLLM Inductor-based backend with caching, piecewise compilation, shape specialization, and custom passes.

pass_config = field(default_factory=PassConfig) class-attribute instance-attribute

Custom inductor passes, see PassConfig for more details

prefill_cudagraph_capture_token_sizes = None class-attribute instance-attribute

Token counts of the CUDA graphs for prefill batches: every batch that is not a uniform decode batch, i.e. one with a prefill or with requests of different query lengths, and every batch when cudagraph_mode is FULL or PIECEWISE. Decode batches under adaptive verification are the exception; see decode_cudagraph_capture_request_sizes. [] captures none, and sizes above max_num_batched_tokens are dropped. None (default): the token-count grid up to max_prefill_cudagraph_capture_tokens.

splitting_ops = None class-attribute instance-attribute

A list of ops to exclude from cudagraphs, used in piecewise compilation.

The behavior depends on use_inductor_graph_partition:

  • When use_inductor_graph_partition=False (default): These ops are used for Dynamo FX-level graph splitting. The graph is split at these ops before Inductor compilation, creating separate subgraphs for cudagraph capture.

  • When use_inductor_graph_partition=True: These ops are used to register Inductor partition rules. The graph partitioning happens at Inductor codegen time after all passes and fusions are finished, allowing compilation and custom passes to operate on the full graph while still excluding these ops from cudagraphs.

If None, defaults to attention ops for piecewise cudagraphs. If empty list [], no ops are excluded (suitable for full cudagraphs).

static_all_moe_layers = field(default_factory=list, init=False) class-attribute instance-attribute

The names of all the MOE layers in the model

static_forward_context = field(default_factory=dict, init=False) class-attribute instance-attribute

Per-model forward context Map from layer name to layer objects that need to be accessed outside model code, e.g., Attention, FusedMOE when dp_size>1.

traced_files = field(default_factory=set, init=False) class-attribute instance-attribute

files that are traced for compilation

use_breakable_cudagraph = None class-attribute instance-attribute

Whether to use breakable CUDA graphs (runtime stream-capture breaks instead of torch.compile FX graph splitting).

Resolved by VllmConfig.post_init: an explicit VLLM_USE_BREAKABLE_CUDAGRAPH env var takes precedence, otherwise it is auto-enabled for breakable-by-default architectures (and for tuned batch-invariant setups). None means unresolved; readers fall back to envs.VLLM_USE_BREAKABLE_CUDAGRAPH so standalone CompilationConfig users keep working. Stored per-config (and pickled to workers) rather than written back to os.environ.

use_inductor_graph_partition = None class-attribute instance-attribute

Use inductor graph partition to split the graph at cudagraph_unsafe ops. This partition happens at inductor codegen time after all passes and fusions are finished. It generates a single call function which wraps cudagraph-safe ops into partition functions and leave cudagraph-unsafe ops outside the partition functions. For a graph with N cudagraph-unsafe ops (e.g., Attention), there would be N+1 partitions. To mark an op as cudagraph unsafe, we can add tags=(torch._C.Tag.cudagraph_unsafe) when register the custom op.

This config supports both full cudagraph and piecewise cudagraph without compiling twice. For piecewise cudagraph, it applies vLLM CUDAGraph wrapper to each partition. For N+1 partitions, there would be N+1 CUDAGraph wrapper instances.

For full CUDAGraph, we always apply a single CUDAGraph wrapper outside the inductor call function in the model runner. The top-level full cudagraph capture ignores all partitioning.

_skip_none_validation(value, handler) classmethod

Skip validation if the value is None when initialisation is delayed.

compile_factors()

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.

WARNING: Whenever a new field is added to this config, add it to ignored_factors if it does not affect the computation graph.

custom_op_log_check()

This method logs the enabled/disabled custom ops and checks that the passed custom_ops field only contains relevant ops. It is called at the end of set_current_vllm_config, after the custom ops have been instantiated.

enable_custom_op_by_default(op)

Enable op unless custom_ops already enables or disables it.

Idempotent, because VllmConfig.__post_init__ runs again on every replace() and shares this config with the original.

get_compile_ranges()

Get the compile ranges for the compilation config.

init_backend(vllm_config, prefix='', is_encoder=False, use_aot_compile=True)

Initialize the backend for the compilation config from a vllm config.

Parameters:

  • vllm_config

    (VllmConfig) –

    The vllm config to initialize the backend from.

  • prefix

    (str, default: '' ) –

    Cache directory prefix for this compiled module.

  • is_encoder

    (bool, default: False ) –

    Whether this module is used in an encoder (as opposed to a text backbone).

  • use_aot_compile

    (bool, default: True ) –

    Whether the module permits AOT and direct artifacts.

Returns:

  • str | Callable –

    The backend for the compilation config.

post_init_cudagraph_sizes()

To complete the initialization after cudagraph related configs are set. This includes: - initialize compile_sizes

resolve_cudagraph_mode_and_sizes(min_cg_support, min_cg_attn_backend, uniform_decode_query_len=1, kv_cache_config=None, max_num_reqs=None, is_profiling=False, piecewise_capture_available=True)

Resolve the CUDA Graphs mode the attention backends can support.

Downgrades the configured mode to the best supported one and stores it, or raises a ValueError if the requested CUDA Graphs cannot be supported.

uses_rope_kernel()

Whether RoPE should lower to a kernel instead of Inductor codegen.

True when the RoPE custom op is enabled or a RoPE fusion pass is on, so RoPE left unfused keeps the kernel. Safe before custom_ops resolution.

validate_cudagraph_mode_before(value) classmethod

Enable parsing of the cudagraph_mode enum type from string.

validate_mode_before(value) classmethod

Enable parsing the mode field from string mode names. Accepts both integers (0-3) and string names, like NONE, STOCK_TORCH_COMPILE, DYNAMO_TRACE_ONCE, VLLM_COMPILE.

validate_pass_config_before(value) classmethod

Enable parsing of the pass_config field from a dictionary.

CompilationMode

Bases: IntEnum

The compilation approach used for torch.compile-based compilation of the model.

Attributes:

  • DYNAMO_TRACE_ONCE –

    Single Dynamo trace through the model, avoiding recompilation.

  • NONE –

    No torch.compile compilation is applied, model runs in fully eager pytorch mode.

  • STOCK_TORCH_COMPILE –

    The standard torch.compile compilation pipeline.

  • VLLM_COMPILE –

    Custom vLLM Inductor-based backend with caching, piecewise compilation,

DYNAMO_TRACE_ONCE = 2 class-attribute instance-attribute

Single Dynamo trace through the model, avoiding recompilation.

NONE = 0 class-attribute instance-attribute

No torch.compile compilation is applied, model runs in fully eager pytorch mode. The model runs as-is.

STOCK_TORCH_COMPILE = 1 class-attribute instance-attribute

The standard torch.compile compilation pipeline.

VLLM_COMPILE = 3 class-attribute instance-attribute

Custom vLLM Inductor-based backend with caching, piecewise compilation, shape specialization, and custom passes.

DynamicShapesConfig

Configuration to control/debug torch compile dynamic shapes.

Methods:

  • compile_factors –

    Provide the factors used for hashing DynamicShapesConfig.

Attributes:

assume_32_bit_indexing = False class-attribute instance-attribute

whether all tensor sizes can use 32 bit indexing.

evaluate_guards = False class-attribute instance-attribute

A debug mode to detect and fail if Dynamo ever specializes a dynamic shape by guarding on it. When True, dynamic shape guards are not dropped from dynamo. And a failure will be triggered if a recompilation ever happens due to that. This mode requires VLLM_USE_BYTECODE_HOOK to be 0. Enabling this allow observing the dynamic shapes guards in the tlparse artifacts also. When type is backed, aot_compile must be disabled for this mode to work. until this change picked up https://github.com/pytorch/pytorch/pull/169239.

type = DynamicShapesType.BACKED class-attribute instance-attribute

Controls the type of dynamic shapes handling to use with torch.compile().

  • BACKED: Default PyTorch behavior with potential guards ignored.
  • UNBACKED: No guards guaranteed (most sound) but may throw data dependent errors.
  • BACKED_SIZE_OBLIVIOUS: Experimental safer alternative to backed/unbacked.

compile_factors()

Provide the factors used for hashing DynamicShapesConfig.

DynamicShapesType

Bases: StrEnum

Types of dynamic shapes handling in torch.compile(). see Dynamic shapes and vllm guard dropping in torch_compile.md for more details.

Attributes:

  • BACKED –

    Use backed dynamic shapes. torch.compile() guards on backed dynamic

  • BACKED_SIZE_OBLIVIOUS –

    Experimental flag that treats backed symbols as unbacked when explicit

  • UNBACKED –

    Use unbacked dynamic shapes. Guaranteed not to be guarded on and not

BACKED = 'backed' class-attribute instance-attribute

Use backed dynamic shapes. torch.compile() guards on backed dynamic shapes and may add guards. Symbols are specialized to 0, 1, or >=2 even without encountering branching on those ranges.

BACKED_SIZE_OBLIVIOUS = 'backed_size_oblivious' class-attribute instance-attribute

Experimental flag that treats backed symbols as unbacked when explicit unbacked handling is defined.

UNBACKED = 'unbacked' class-attribute instance-attribute

Use unbacked dynamic shapes. Guaranteed not to be guarded on and not 0/1 specialized, but may throw data dependent errors when branches require their value without explicit unbacked handling.

PassConfig

Configuration for custom Inductor passes.

This is separate from general CompilationConfig so that inductor passes don't all have access to full configuration - that would create a cycle as the PassManager is set as a property of config.

You must pass PassConfig to VLLMConfig constructor via the CompilationConfig constructor. VLLMConfig's post_init does further initialization. If used outside of the VLLMConfig, some fields may be left in an improper state.

Methods:

Attributes:

eliminate_noops = Field(default=True) class-attribute instance-attribute

Eliminate no-op ops.

enable_qk_norm_rope_fusion = None class-attribute instance-attribute

Enable fused Q/K RMSNorm + RoPE pass.

fi_allreduce_fusion_max_size_mb = None class-attribute instance-attribute

The threshold of the communicated tensor sizes under which vllm should use flashinfer fused allreduce. Specified as a float in MB. Unspecified will fallback to default values which are compute capability and world size dependent. See FI_ALLREDUCE_FUSION_MAX_SIZE_MB, keyed by device capability.

fuse_act_padding = None class-attribute instance-attribute

Fuse the custom RMSNorm + padding ops.

fuse_act_quant = None class-attribute instance-attribute

Fuse the custom SiluMul + quant ops.

fuse_allreduce_rms = None class-attribute instance-attribute

Enable flashinfer allreduce fusion.

fuse_attn_quant = None class-attribute instance-attribute

Fuse the custom Attention and MLAAttention + quant ops.

fuse_mla_dual_rms_norm = None class-attribute instance-attribute

Fuse paired q/kv RMS norms in MLA attention.

fuse_norm_quant = None class-attribute instance-attribute

Fuse the custom RMSNorm + quant ops.

fuse_qk_norm_rope_kvcache = Field(default=None) class-attribute instance-attribute

Fuse QK RMSNorm + RoPE/MRoPE + KV cache update into an AITER HIP kernel. Supersedes both enable_qk_norm_rope_fusion and fuse_rope_kvcache for layers that support it. Auto-enabled at O2+ on ROCm for models with QK-norm (e.g. Qwen3-MoE and Qwen3-VL-class architectures).

fuse_rope_kvcache = None class-attribute instance-attribute

Fuse the QK rope + KV cache ops.

fuse_rope_kvcache_cat_mla = None class-attribute instance-attribute

Enable fused MLA KV cache update with RoPE.

rope_kvcache_fusion_max_token_num = 256 class-attribute instance-attribute

The threshold for ROCm AITER RoPE+KVCache fusion e.g. for small batch decode. Larger batch sizes e.g. during prefill will use the unfused kernels. Also applies to the fused QK-Norm+RoPE/MRoPE+KVCache pass.

_skip_none_validation(value, handler) classmethod

Skip validation if the value is None when initialisation is delayed.

compile_factors()

Produces a hash unique to the pass configuration. Any new fields that affect compilation should be added to the hash. Any future fields that don't affect compilation should be excluded.

flashinfer_max_size(world_size)

Returns the max communication size in bytes for flashinfer allreduce fusion for the given world size. Returns None if world size is not supported by configs as it's not supported by flashinfer.

log_enabled_passes()

Log the enabled custom fusion passes. This is called at the end of VLLMConfig post_init, after all defaults are finalized. TODO also log the compile ranges for which this is enabled.

_walk_grid(limit, step)

Sizes 1, ..., limit, each the next multiple of the largest power of two not above step(size).

decode_cudagraph_capture_grid(max_requests)

The request-count grid up to max_requests: every count up to 6, then a step of the largest power of two not above 0.65 * n^(2/3) (2 from 8, 4 from 16, 8 from 48, 16 from 128, 32 from 352): 64 sizes at 1024.

decode_cudagraph_capture_max_tokens(config)

The most tokens a uniform decode graph holds: the recorded max, which attention backends size their buffers by, within the decode token budget.

decode_cudagraph_capture_shapes(sizes, query_lens, max_tokens)

The (num_reqs, query_len) uniform decode graphs for the request counts sizes, for each query length up to the most requests it maps to and max_tokens tokens. A batch pads to the smallest graph that holds it, so the first size above a limit is captured at the limit and larger ones are unreachable.

prefill_cudagraph_capture_grid(max_tokens, dense_head=False)

The token-count grid up to max_tokens: 1, 2, 4, every 8 up to 64, four sizes per doubling up to 1024 (every count up to 32 with dense_head), then every 256 tokens, and every 512 once 7% of the size exceeds 512: 54 sizes at 8192.

validate_cudagraph_capture_grid(sizes, limit)

Normalize a platform grid, rejecting sizes outside its resolved limit.

varlen_decode_cudagraph_capture_grid(max_tokens, dense_head=False)

The token-count grid of adaptive verification's decode graphs: 1, 2, 4 (every count up to 32 with dense_head), then 4 sizes per doubling from 8 to 1024, every 128 up to 4096 and every 256 beyond. Adaptive verification picks its verify budget from the captured sizes, so it needs a finer grid than prefill.