vllm.model_executor.model_loader.utils
¶
Utilities for selecting and loading models.
Functions:
-
build_model_from_processed_weights–Build a model on meta and install already post-processed weights.
-
configure_quant_config–Pass packed_modules_mapping by reference to quant_config so that
-
get_draft_load_config–Get load config for the speculative draft model.
-
initialize_model–Initialize a model with the given configurations.
-
log_layer_backends–Log the backends the layers of
modelselected. The individual -
online_quantization_timing_context–Accumulate online quantization processing time for
quant_method. -
process_weights_after_loading–Post-process loaded weights into runtime format.
_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).
Source code in vllm/model_executor/model_loader/utils.py
_register_processed_tensors(model, tensors, manifest, aliases)
¶
Replace the meta model's parameters and buffers, keeping ties.
Source code in vllm/model_executor/model_loader/utils.py
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.
Source code in vllm/model_executor/model_loader/utils.py
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
Source code in vllm/model_executor/model_loader/utils.py
get_draft_load_config(vllm_config)
¶
Get load config for the speculative draft model.
Source code in vllm/model_executor/model_loader/utils.py
initialize_model(vllm_config, *, prefix='', model_class=None, model_config=None)
¶
Initialize a model with the given configurations.
Source code in vllm/model_executor/model_loader/utils.py
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.
Source code in vllm/model_executor/model_loader/utils.py
online_quantization_timing_context(layer, quant_method)
¶
Accumulate online quantization processing time for quant_method.
Source code in vllm/model_executor/model_loader/utils.py
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.