Skip to content

vllm.model_executor.model_loader.utils

Utilities for selecting and loading models.

Functions:

_MODEL_ARCH_BY_HASH = dict[int, tuple[type[nn.Module], str]]() module-attribute

Caches the outputs of _get_model_architecture.

_materialize_remaining_meta_tensors(model, device)

Allocate tensors the daemon did not provide (left uninitialized).

_register_processed_tensors(model, tensors, manifest, aliases)

Replace the meta model's parameters and buffers, keeping ties.

build_model_from_processed_weights(vllm_config, model_config, prefix, tensors, manifest, aliases, attrs, load_config)

Build a model on meta and install already post-processed weights.

configure_quant_config(quant_config, model_class)

Pass packed_modules_mapping by reference to quant_config so that quant_config can properly match fused modules

Note that model attributes are passed by reference to quant_config, enabling them to be updated by model_class.new (ex. chatglm, qwen)

Once the SupportsQuant mixin has been added to all models, this function can be removed

get_draft_load_config(vllm_config)

Get load config for the speculative draft model.

initialize_model(vllm_config, *, prefix='', model_class=None, model_config=None)

Initialize a model with the given configurations.

log_layer_backends(model, model_config, load_failed=False)

Log the backends the layers of model selected. The individual selections are logged at DEBUG where they are made.

The model runner calls this for each model it loads; the base loader only when loading fails, as the runner never receives that model.

online_quantization_timing_context(layer, quant_method)

Accumulate online quantization processing time for quant_method.

process_weights_after_loading(model, model_config, target_device)

Post-process loaded weights into runtime format.

Under weights_already_processed (weight cache IPC loader), quant methods skip tensor transforms and must declare supports_pre_processed_weights, otherwise this raises RuntimeError.