vllm.config.model
¶
Classes:
-
ModelConfig–Configuration for the model.
Functions:
-
get_served_model_name–If the input is a non-empty list, the first model_name in
_ATTENTION_LAYER_TYPES = frozenset({'full_attention', 'indexed_attention', 'deepseek_sparse_attention', 'qwen_sparse_attention'})
module-attribute
¶
layer_types spellings that consume a full attention KV cache. Sparse
attention still caches every token, so it counts as attention here.
ModelConfig
¶
Configuration for the model.
Methods:
-
compile_factors–WARNING: Whenever a new field is added to this config, add it to
-
get_diff_sampling_param–This method returns a dictionary containing the non-default sampling
-
get_mamba_chunk_size–Returns the mamba chunk size if it exists.
-
get_multimodal_config–Get the multimodal configuration of the model.
-
get_num_attention_heads–Returns the number of attention heads per GPU.
-
get_num_kv_heads–Returns the number of KV heads per GPU.
-
get_sliding_window–Get the sliding window size from the HF text config if present.
-
get_total_num_kv_heads–Returns the total number of KV heads.
-
maybe_pull_model_tokenizer_for_runai–Pull model/tokenizer from Object Storage to temporary
-
maybe_untie_word_embeddings–Stop trusting
tie_word_embeddingswhen the checkpoint disagrees. -
try_get_generation_config–This method attempts to retrieve the non-default values of the
-
using_transformers_backend–Check if the model is using the Transformers modeling backend class.
-
validate_model_config_after–Called after post_init.
-
verify_eplb_config–Validate that this model's experts can be evenly distributed by EPLB.
Attributes:
-
allow_deprecated_quantization(bool) –Whether to allow deprecated quantization methods.
-
allowed_local_media_path(str) –Allowing API requests to read local images or videos from directories
-
allowed_media_domains(list[str] | None) –If set, only media URLs that belong to this domain can be used for
-
architecture(str) –The architecture vllm actually used.
-
attn_type(AttnTypeStr) –Determine the attention type based on model configuration.
-
checkpoint_prepare_on_startup(bool) –Prepare each engine for a process checkpoint once it starts, as
-
code_revision(str | None) –The specific revision to use for the model code on the Hugging Face Hub.
-
config_format(str | ConfigFormat) –The format of the model config to load:
-
convert(ConvertOption) –Convert the model using adapters defined in
-
disable_sliding_window(bool) –Whether to disable sliding window. If True, we will disable the sliding
-
dtype(ModelDType | dtype) –Data type for model weights and activations:
-
enable_cumem_allocator(bool) –Enable the custom cumem allocator to leverage advanced GPU memory
-
enable_nccl_comm_suspend(bool) –Enable releasing NCCL communicator memory during sleep mode
-
enable_prompt_embeds(bool) –If
True, enables passing text embeddings as inputs via the -
enable_sleep_mode(bool) –Enable sleep mode for the engine (only cuda and
-
enable_trace_replay(bool) –Whether to allow requests to set
-
enforce_eager(bool) –Whether to always use eager-mode PyTorch. If True, we will disable CUDA
-
generation_config(str) –The folder path to the generation config. Defaults to
"auto", the -
head_dtype(dtype) –The "head" refers to the last Linear layer(s) of an LLM,
-
hf_config(PreTrainedConfig) –The Hugging Face config of the model.
-
hf_config_path(str | None) –Name or path of the Hugging Face config to use. If unspecified, model
-
hf_overrides(HfOverrides) –If a dictionary, contains arguments to be forwarded to the Hugging Face
-
hf_text_config(PreTrainedConfig) –The Hugging Face config of the text model (same as hf_config for text models).
-
hf_token(bool | str | None) –The token to use as HTTP bearer authorization for remote files . If
-
io_processor_plugin(str | None) –IOProcessor plugin name to load at model startup
-
is_diffusion(bool) –Detect discrete diffusion (dLLM) models from HF config.
-
is_encoder_decoder(bool) –Extract the HF encoder/decoder model flag.
-
is_submodel_config(bool) –Whether this is a view derived from an already-validated
VllmConfig: a -
logits_processors(list[str | type[LogitsProcessor]] | None) –One or more logits processors' fully-qualified class names or class
-
logprobs_mode(LogprobsMode) –Indicates the content returned in the logprobs and prompt_logprobs.
-
masked_token_ids(list[int] | None) –Token ids that are never sampled (their logits are set to -inf before
-
max_logprobs(int) –Maximum number of log probabilities to return when
logprobsis -
max_model_len(int) –Model context length (prompt and output). If unspecified, will be
-
may_use_target_embed(bool) –For a speculative decoding draft model, whether it may reuse the
-
model(str) –Name or path of the Hugging Face model to use. It is also used as the
-
model_class_overrides(dict[str, str]) –Override the model class used for one or more architectures, mapping the
-
model_impl(str | ModelImpl) –Which implementation of the model to use:
-
model_weights(str) –Original model weights path. Used when the model is pulled from object
-
multimodal_config(MultiModalConfig | None) –Configuration for multimodal model. If
None, this will be inferred -
override_generation_config(dict[str, Any]) –Overrides or sets generation config. e.g.
{"temperature": 0.5}. If -
pooler_config(PoolerConfig | None) –Pooler config which controls the behaviour of output pooling in pooling
-
quantization(QuantizationMethods | str | None) –Method used to quantize the weights. If
None, we first check the -
quantization_config(dict[str, Any] | QuantizationConfigArgs | None) –User-facing quantization configuration. Carries per-layer-kind specs
-
renderer_num_workers(int | None) –Number of worker threads in the renderer thread pool. The pool is
-
return_sampling_mask(bool) –Whether to return the post-processing token support for each sample.
-
revision(str | None) –The specific model version to use. It can be a branch name, a tag name,
-
runner(RunnerOption) –The type of model runner to use. Each vLLM instance only supports one
-
score_type(ScoreType) –Scoring API handles score/rerank for:
-
seed(int) –Random seed for reproducibility.
-
served_model_name(str | list[str] | None) –The model name(s) used in the API. If multiple names are provided, the
-
skip_tokenizer_init(bool) –Skip initialization of tokenizer and detokenizer. Expects valid
-
sleep_mode_backend(str) –Mechanism used to free and restore GPU state for sleep mode.
"cumem" -
sleep_mode_offload_cudagraph(bool) –Back up CUDA graph memory to CPU during sleep, restored in place on wake.
-
sleep_preserve_parameter_names(list[str]) –Parameter-name globs to preserve across level-2 sleep.
-
spec_target_max_model_len(int | None) –Specify the maximum length for spec decoding draft models.
-
speculator_config_class(str | None) –For a speculative decoding draft model, the config class of the
-
tokenizer(str) –Name or path of the Hugging Face tokenizer to use. If unspecified, model
-
tokenizer_mode(TokenizerMode | str) –Tokenizer mode:
-
tokenizer_revision(str | None) –The specific revision to use for the tokenizer on the Hugging Face Hub.
-
trust_remote_code(bool) –Trust remote code (e.g., from HuggingFace) when downloading the model
-
use_fp64_gumbel(bool) –Whether to use FP64 (instead of FP32) random noise for Gumbel-max and
-
word_embeddings_untied_by_checkpoint(bool) –Whether
tie_word_embeddingswas overridden toFalsebecause the checkpoint
allow_deprecated_quantization = False
class-attribute
instance-attribute
¶
Whether to allow deprecated quantization methods.
allowed_local_media_path = ''
class-attribute
instance-attribute
¶
Allowing API requests to read local images or videos from directories specified by the server file system. This is a security risk. Should only be enabled in trusted environments.
allowed_media_domains = None
class-attribute
instance-attribute
¶
If set, only media URLs that belong to this domain can be used for multi-modal inputs.
architecture
property
¶
The architecture vllm actually used.
attn_type
property
¶
Determine the attention type based on model configuration.
checkpoint_prepare_on_startup = False
class-attribute
instance-attribute
¶
Prepare each engine for a process checkpoint once it starts, as
/checkpoint/prepare does. It serves only after /checkpoint/restore.
Requires sleep mode.
code_revision = None
class-attribute
instance-attribute
¶
The specific revision to use for the model code on the Hugging Face Hub. It can be a branch name, a tag name, or a commit id. If unspecified, will use the default version.
config_format = 'auto'
class-attribute
instance-attribute
¶
The format of the model config to load:
- "auto" will try to load the config in hf format if available after trying to load in mistral format.
- "hf" will load the config in hf format.
- "mistral" will load the config in mistral format.
convert = 'auto'
class-attribute
instance-attribute
¶
Convert the model using adapters defined in vllm.model_executor.models.adapters. The most common use case is to adapt a text generation model to be used for pooling tasks.
disable_sliding_window = False
class-attribute
instance-attribute
¶
Whether to disable sliding window. If True, we will disable the sliding window functionality of the model, capping to sliding window size. If the model does not support sliding window, this argument is ignored.
dtype = 'auto'
class-attribute
instance-attribute
¶
Data type for model weights and activations:
- "auto" will use FP16 precision for FP32 and FP16 models, and BF16 precision for BF16 models.
- "half" for FP16. Recommended for AWQ quantization.
- "float16" is the same as "half".
- "bfloat16" for a balance between precision and range.
- "float" is shorthand for FP32 precision.
- "float32" for FP32 precision.
enable_cumem_allocator = False
class-attribute
instance-attribute
¶
Enable the custom cumem allocator to leverage advanced GPU memory allocation features such as multi-node NVLink support.
Sleep mode automatically enables this allocator. Only cuda and hip platforms are supported.
enable_nccl_comm_suspend = False
class-attribute
instance-attribute
¶
Enable releasing NCCL communicator memory during sleep mode
(ncclCommSuspend/ncclCommResume). Experimental; when disabled
(the default) sleep still releases weights/KV-cache memory as before.
enable_prompt_embeds = False
class-attribute
instance-attribute
¶
If True, enables passing text embeddings as inputs via the
prompt_embeds key.
WARNING: The vLLM engine may crash if incorrect shape of embeddings is passed. Only enable this flag for trusted users!
enable_sleep_mode = False
class-attribute
instance-attribute
¶
Enable sleep mode for the engine (only cuda and hip platforms are supported).
enable_trace_replay = False
class-attribute
instance-attribute
¶
Whether to allow requests to set
SamplingParams.trace_decode_token_ids, which forces decoding to follow a
predetermined token sequence while still computing real logprobs. Reserved
for debugging and RL workflows: enabling it reserves a per-request trace
buffer, so it is off by default.
enforce_eager = False
class-attribute
instance-attribute
¶
Whether to always use eager-mode PyTorch. If True, we will disable CUDA graph and always execute the model in eager mode. If False, we will use CUDA graph and eager execution in hybrid for maximal performance and flexibility.
NOTE: This disables both torch.compile and CUDA graphs, and is
equivalent to setting -cc.mode=none -cc.cudagraph_mode=none.
generation_config = 'auto'
class-attribute
instance-attribute
¶
The folder path to the generation config. Defaults to "auto", the
generation config will be loaded from model path. If set to "vllm", no
generation config is loaded, vLLM defaults will be used. If set to a folder
path, the generation config will be loaded from the specified folder path.
If max_new_tokens is specified in generation config, then it sets a
server-wide limit on the number of output tokens for all requests.
head_dtype
property
¶
The "head" refers to the last Linear layer(s) of an LLM, such as the lm_head in a generation model, or the score or classifier in a classification model.
- Pooling models default to an fp32 head; use --hf-overrides '{"head_dtype": "model"}' to disable it.
- Generation models default to the model dtype; set --hf-overrides '{"head_dtype": "float32"}' to run the lm_head in fp32, which is required for RL training-inference consistency (the trainer computes logits in fp32).
hf_config = field(init=False)
class-attribute
instance-attribute
¶
The Hugging Face config of the model.
hf_config_path = None
class-attribute
instance-attribute
¶
Name or path of the Hugging Face config to use. If unspecified, model name or path will be used.
hf_overrides = field(default_factory=dict)
class-attribute
instance-attribute
¶
If a dictionary, contains arguments to be forwarded to the Hugging Face config. If a callable, it is called to update the HuggingFace config.
hf_text_config = field(init=False)
class-attribute
instance-attribute
¶
The Hugging Face config of the text model (same as hf_config for text models).
hf_token = Field(default=None, repr=False, exclude=True)
class-attribute
instance-attribute
¶
The token to use as HTTP bearer authorization for remote files . If
True, will use the token generated when running hf auth login
(stored in ~/.cache/huggingface/token).
io_processor_plugin = None
class-attribute
instance-attribute
¶
IOProcessor plugin name to load at model startup
is_diffusion
cached
property
¶
Detect discrete diffusion (dLLM) models from HF config.
is_encoder_decoder
cached
property
¶
Extract the HF encoder/decoder model flag.
is_submodel_config = field(default=False, init=False)
class-attribute
instance-attribute
¶
Whether this is a view derived from an already-validated VllmConfig: a
submodule view from VllmConfig.with_hf_config (e.g. a multimodal model's text
stack, whose architecture list may be empty) or a draft model's view that
reuses the target's configs. Deployment-level validation must not run against
it.
logits_processors = None
class-attribute
instance-attribute
¶
One or more logits processors' fully-qualified class names or class definitions
logprobs_mode = 'raw_logprobs'
class-attribute
instance-attribute
¶
Indicates the content returned in the logprobs and prompt_logprobs. Supported mode: 1) raw_logprobs, 2) processed_logprobs, 3) raw_logits, 4) processed_logits. Raw means the values before applying any logit processors, like bad words. Processed means the values after applying all processors, including temperature and top_k/top_p. Note: for prompt_logprobs, processed_ and raw_ yield identical results because prompt tokens do not go through sampling processors.
masked_token_ids = None
class-attribute
instance-attribute
¶
Token ids that are never sampled (their logits are set to -inf before sampling), e.g. the lm_head rows past the tokenizer or placeholder tokens. Prompt logprobs are unaffected.
max_logprobs = Field(default=20, ge=-1)
class-attribute
instance-attribute
¶
Maximum number of log probabilities to return when logprobs is
specified in SamplingParams. The default value comes the default for the
OpenAI Chat Completions API. -1 means no cap, i.e. all (output_length *
vocab_size) logprobs are allowed to be returned and it may cause OOM.
max_model_len = Field(default=None, ge=-1)
class-attribute
instance-attribute
¶
Model context length (prompt and output). If unspecified, will be automatically derived from the model config.
When passing via --max-model-len, supports k/m/g/K/M/G in human-readable
format. Examples:
- 1k -> 1000
- 1K -> 1024
- 25.6k -> 25,600
- -1 or 'auto' -> Automatically choose the maximum model length that fits in GPU memory. This will use the model's maximum context length if it fits, otherwise it will find the largest length that can be accommodated.
may_use_target_embed
property
¶
For a speculative decoding draft model, whether it may reuse the target's input embedding under pipeline parallelism.
model = 'Qwen/Qwen3-0.6B'
class-attribute
instance-attribute
¶
Name or path of the Hugging Face model to use. It is also used as the
content for model_name tag in metrics output when served_model_name is
not specified.
model_class_overrides = field(default_factory=dict)
class-attribute
instance-attribute
¶
Override the model class used for one or more architectures, mapping the
architecture name to a "module:class" target (the same format accepted by
ModelRegistry.register_model). This registers the target class at runtime,
e.g. {"GlmMoeDsaForCausalLM":
"vllm.models.deepseek_v32.nvidia.model:DeepseekV32ForCausalLM"}. This
argument is for development and debugging purposes only.
model_impl = 'auto'
class-attribute
instance-attribute
¶
Which implementation of the model to use:
- "auto" will try to use the vLLM implementation, if it exists, and fall back to the Transformers implementation if no vLLM implementation is available.
- "vllm" will use the vLLM model implementation.
- "transformers" will use the Transformers model implementation.
- "terratorch" will use the TerraTorch model implementation.
model_weights = ''
class-attribute
instance-attribute
¶
Original model weights path. Used when the model is pulled from object
storage (e.g., RunAI) to preserve the original URI while model points to
the local directory.
multimodal_config = None
class-attribute
instance-attribute
¶
Configuration for multimodal model. If None, this will be inferred
from the architecture of self.model.
override_generation_config = field(default_factory=dict)
class-attribute
instance-attribute
¶
Overrides or sets generation config. e.g. {"temperature": 0.5}. If
used with --generation-config auto, the override parameters will be
merged with the default config from the model. If used with
--generation-config vllm, only the override parameters are used.
pooler_config = None
class-attribute
instance-attribute
¶
Pooler config which controls the behaviour of output pooling in pooling models.
quantization = None
class-attribute
instance-attribute
¶
Method used to quantize the weights. If None, we first check the
quantization_config attribute in the model config file. If that is
None, we assume the model weights are not quantized and use dtype to
determine the data type of the weights.
quantization_config = None
class-attribute
instance-attribute
¶
User-facing quantization configuration. Carries per-layer-kind specs
(linear, moe) and ignore patterns; see QuantizationConfigArgs.
Auto-populated from the matching online shorthand when quantization is
one of the values in ONLINE_QUANT_SHORTHAND_NAMES.
renderer_num_workers = None
class-attribute
instance-attribute
¶
Number of worker threads in the renderer thread pool. The pool is
consumed by the async renderer path (e.g. the OpenAI-compatible API
server started by vllm serve) to parallelize tokenization, chat
template rendering, and multimodal preprocessing across concurrent
requests.
If unset, defaults to 4 for the async renderer path, or to 1 for pooling runners (their preprocessing runs on the renderer workers, which is not compatible with the multimodal processor cache when multi-threaded). A single worker serializes tokenization of long prompts in each API server process and can cap the request rate well below what the engine can sustain.
The offline LLM entrypoint uses the synchronous renderer path and
processes prompts (including multimodal preprocessing) serially, so
this setting has no effect there (the offline default is 1).
return_sampling_mask = False
class-attribute
instance-attribute
¶
Whether to return the post-processing token support for each sample.
revision = None
class-attribute
instance-attribute
¶
The specific model version to use. It can be a branch name, a tag name, or a commit id. If unspecified, will use the default version.
runner = 'auto'
class-attribute
instance-attribute
¶
The type of model runner to use. Each vLLM instance only supports one model runner, even if the same model can be used for multiple types.
score_type
property
¶
Scoring API handles score/rerank for:
- "classify" task (score_type: cross-encoder models)
- "embed" task (score_type: bi-encoder models)
- "token_embed" task (score_type: late interaction models)
seed = Field(default=0, ge=0, le=2 ** 32 - 1)
class-attribute
instance-attribute
¶
Random seed for reproducibility.
The seed must be in the range [0, 2**32 - 1].
We must set the global seed because otherwise, different tensor parallel workers would sample different tokens, leading to inconsistent results.
served_model_name = None
class-attribute
instance-attribute
¶
The model name(s) used in the API. If multiple names are provided, the
server will respond to any of the provided names. The model name in the
model field of a response will be the first name in this list. If not
specified, the model name will be the same as the --model argument. Noted
that this name(s) will also be used in model_name tag content of
prometheus metrics, if multiple names provided, metrics tag will take the
first one.
skip_tokenizer_init = False
class-attribute
instance-attribute
¶
Skip initialization of tokenizer and detokenizer. Expects valid
prompt_token_ids and None for prompt from the input. The generated
output will contain token ids.
sleep_mode_backend = 'cumem'
class-attribute
instance-attribute
¶
Mechanism used to free and restore GPU state for sleep mode. "cumem"
(default) uses the built-in CuMemAllocator and is behavior-compatible
with prior releases. Additional backends (CUDA checkpoint, CRIU, durable
snapshot) may be registered in-tree or by plugins (RFC #34303).
sleep_mode_offload_cudagraph = False
class-attribute
instance-attribute
¶
Back up CUDA graph memory to CPU during sleep, restored in place on wake. Takes effect with enable_sleep_mode, the cumem backend and CUDA graphs.
sleep_preserve_parameter_names = field(default_factory=list)
class-attribute
instance-attribute
¶
Parameter-name globs to preserve across level-2 sleep.
Use target globs for frozen Engram table weights and scales omitted by the
trainer (e.g. *.engram.embed_tokens.weight*).
Use draft.<name> for draft-private parameters, or draft.* for all.
The sender must omit these parameters; loaders must preserve their storage.
spec_target_max_model_len = None
class-attribute
instance-attribute
¶
Specify the maximum length for spec decoding draft models.
speculator_config_class
property
¶
For a speculative decoding draft model, the config class of the
speculator it's for, if it declares one (see SpeculativeDraftModel).
tokenizer = None
class-attribute
instance-attribute
¶
Name or path of the Hugging Face tokenizer to use. If unspecified, model name or path will be used.
tokenizer_mode = 'auto'
class-attribute
instance-attribute
¶
Tokenizer mode:
- "auto" will use the tokenizer from
mistral_commonfor Mistral models if available, otherwise it will use the "hf" tokenizer. - "hf" will use the fast tokenizer if available.
- "alpamayo2_super" uses the "hf" tokenizer with Alpamayo 2 Super's
trajectory and special tokens added; selected automatically for
nvidia/Alpamayo2-Super. - "hy_v4" uses the HF tokenizer with HYV4 VL chat rendering.
- "mistral" will always use the tokenizer from
mistral_common. - "deepseek_v32" will always use the tokenizer from
deepseek_v32. - "deepseek_v4" will always use the tokenizer from
deepseek_v4. - "deepseek_v41" will use the DeepSeek V4.1 prompt encoder.
- "kimi_k3" requires a tokenizer with native Kimi K3 XTML chat encoding. It rejects the generic Hugging Face Jinja fallback.
- "glm5_next" uses the "hf" tokenizer and renderer on the Python frontend;
the Rust frontend renders GLM-5.3 and GLM-5.3-Flash prompts natively,
and selects this under "auto" for the
glm5_nextmodel type (GLM-5.3-Flash). GLM-5.3-Flash multimodal inputs require the Rust frontend; Python supports text-only inference with image and video limits set to zero. - "cohere" uses the standard HF tokenizer but renders the chat template
via the
cohere_melodylibrary (cmd3 / cmd4 templates) instead of Jinja, and surfaces grounded-citation metadata on responses. - Other custom values can be supported via plugins.
To swap the Rust BPE backend that powers HF fast tokenizers for the
fastokens implementation, set
VLLM_USE_FASTOKENS=1 instead — that override applies to any mode that
loads an HF fast tokenizer (hf, deepseek_v32, deepseek_v4, …).
tokenizer_revision = None
class-attribute
instance-attribute
¶
The specific revision to use for the tokenizer on the Hugging Face Hub. It can be a branch name, a tag name, or a commit id. If unspecified, will use the default version.
trust_remote_code = False
class-attribute
instance-attribute
¶
Trust remote code (e.g., from HuggingFace) when downloading the model and tokenizer.
use_fp64_gumbel = False
class-attribute
instance-attribute
¶
Whether to use FP64 (instead of FP32) random noise for Gumbel-max and equivalent exponential-race sampling. FP64 preserves lower-tail sampling events that fp32 uniform/exponential draws can truncate, at the cost of significantly lower throughput on most GPUs.
word_embeddings_untied_by_checkpoint = field(default=False, init=False)
class-attribute
instance-attribute
¶
Whether tie_word_embeddings was overridden to False because the checkpoint
contains an lm_head of its own. The two may still turn out to be identical, in
which case they are re-tied once the weights have been loaded.
_apply_dict_overrides(config, overrides)
classmethod
¶
Apply dict overrides, handling both nested configs and dict values.
_get_transformers_backend_cls()
¶
Determine which Transformers modeling backend class will be used if
model_impl is set to transformers or auto.
_skip_none_validation(value, handler)
classmethod
¶
Skip validation if the value is None when initialisation is delayed.
_supports_multimodal_for_mm_prefix()
¶
Whether multimodal inputs can still appear for this deployment.
This runs more than once per config: once early in __post_init__
(before multimodal_config exists), again after it is created, and
then for every get_model_arch_config regeneration -- notably
with_hf_config, which deep-copies this ModelConfig and swaps
hf_config for a text-only submodule (e.g. Gemma4ForCausalLM).
The result is cached for correctness, not just to save work: on the
with_hf_config copy the submodule architecture has no registered
multimodal processor, so re-querying the registry would raise and be
treated as text-only, wrongly clearing is_mm_prefix_lm even when a
vision modality is still enabled (e.g. image=0 but video allowed).
The deep-copied cache preserves the top-level decision instead.
_supports_multimodal_inputs()
¶
Checks if the model supports multimodal inputs. Returns True if the model is multimodal with any non-zero supported modalities, otherwise returns False, effectively running in text-only mode.
_update_nested(target, updates)
classmethod
¶
Recursively updates a config or dict with nested updates.
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.
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.
get_diff_sampling_param()
¶
This method returns a dictionary containing the non-default sampling
parameters with override_generation_config applied.
The default sampling parameters are:
- vLLM's neutral defaults if
self.generation_config="vllm" - the model's defaults if
self.generation_config="auto" - as defined in
generation_config.jsonifself.generation_config="path/to/generation_config/dir"
Returns:
get_mamba_chunk_size()
¶
Returns the mamba chunk size if it exists.
get_multimodal_config()
¶
get_num_attention_heads(parallel_config, arch_config=None)
¶
Returns the number of attention heads per GPU.
Pass arch_config (from model_arch_config[layer_idx]) to size a
single layer of a heterogeneous model rather than the model as a whole.
get_num_kv_heads(parallel_config, arch_config=None)
¶
Returns the number of KV heads per GPU.
Pass arch_config (from model_arch_config[layer_idx]) to size a
single layer of a heterogeneous model rather than the model as a whole.
get_sliding_window()
¶
Get the sliding window size from the HF text config if present.
get_total_num_kv_heads()
¶
Returns the total number of KV heads.
maybe_pull_model_tokenizer_for_runai(model, tokenizer)
¶
maybe_untie_word_embeddings()
¶
Stop trusting tie_word_embeddings when the checkpoint disagrees.
A config may claim the word embeddings are tied while the checkpoint
ships an lm_head of its own. Tying regardless would silently discard
that tensor, so build the lm_head as if untied and let it load. The
two are compared once loaded, and re-tied if they turn out to match, by
maybe_retie_word_embeddings.
Transformers makes the same decision in PreTrainedModel.tie_weights,
where it can compare the two tensors directly.
try_get_generation_config()
¶
This method attempts to retrieve the non-default values of the generation config for this model.
The generation config can contain information about special tokens, as
well as sampling parameters. Which is why this method exists separately
to get_diff_sampling_param.
Returns:
using_transformers_backend()
¶
Check if the model is using the Transformers modeling backend class.
validate_model_config_after()
¶
Called after post_init.
verify_eplb_config(parallel_config, *, num_experts=None, config_name='eplb_config.num_redundant_experts', disable_config_name=None)
¶
Validate that this model's experts can be evenly distributed by EPLB.
_get_and_verify_max_len(hf_config, model_arch_config, tokenizer_config, max_model_len, disable_sliding_window, sliding_window, spec_target_max_model_len=None, encoder_config=None)
¶
Get and verify the model's maximum length.
_modelopt_mixed_has_nvfp4(quant_config)
¶
Whether a ModelOpt MIXED_PRECISION checkpoint quantizes any layer to NVFP4.
W4A16_NVFP4 is excluded on purpose: it quantizes weights only, so there
is no activation quantization for the fusion passes to act on.
get_served_model_name(model, served_model_name)
¶
If the input is a non-empty list, the first model_name in
served_model_name is taken.
If the input is a non-empty string, it is used directly.
For cases where the input is either an empty string or an
empty list, the fallback is to use self.model.