Skip to content

vllm.model_executor.model_loader.base_loader

Classes:

Functions:

BaseModelLoader

Bases: ABC

Base class for model loaders.

Methods:

  • create_model –

    Create a model with the given configurations.

  • download_model –

    Download a model so that it can be immediately loaded.

  • get_all_weights –

    Iterate over all weights by checkpoint name, for filtered

  • get_external_weight_memory –

    Get weights memory from external process;

  • load_model –

    Load a model with the given configurations.

  • load_weights –

    Load weights into a model. This standalone API allows

  • on_sleep –

    Called before Worker.sleep(level) frees the GPU memory holding

  • on_wake_up –

    Called after Worker.wake_up(tags) returns.

  • reload_model –

    Reload model's weights in place from this loader's source.

create_model(vllm_config, model_config, prefix='')

Create a model with the given configurations.

download_model(model_config) abstractmethod

Download a model so that it can be immediately loaded.

get_all_weights(model_config, model)

Iterate over all weights by checkpoint name, for filtered partial reloads (e.g. FT expert reload after scale_down).

get_external_weight_memory(vllm_config)

Get weights memory from external process; 0 when the weights are not external.

load_model(vllm_config, model_config, prefix='')

Load a model with the given configurations.

load_weights(model, model_config) abstractmethod

Load weights into a model. This standalone API allows inplace weights loading for an already-initialized model

on_sleep(level)

Called before Worker.sleep(level) frees the GPU memory holding the weights of the model this loader loaded.

No-op by default. Override to release or pause any external state that depends on that memory remaining valid before it becomes invalid.

on_wake_up(tags)

Called after Worker.wake_up(tags) returns.

No-op by default. Override to resume whatever on_sleep paused. tags is the same argument wake_up was called with; the weights are woken only when it is None or includes "weights". Once woken after a level-1 sleep, the weights are valid here. After a level-2 sleep they are not: they only become valid once the reload_model call that follows has completed.

reload_model(vllm_config, model_config, model, *, is_checkpoint_format=True)

Reload model's weights in place from this loader's source.

Used by reload_weights() when no weights are provided. After a level-2 sleep this is the point where weights become valid again. The default streams get_all_weights() through the generic in-place reload. Loaders that write final weights into the model themselves override it; the instance that loaded model is then reused, so state it keeps across on_sleep/on_wake_up sees the reload.

_get_online_quantization_config(vllm_config)

Return the online quantization config when one is configured.

bind_model_loader(model, loader)

Record loader as the loader that loaded model.

get_bound_model_loader(model)

Return the loader that loaded model, if it was recorded.

log_model_inspection(model)

Log model structure if VLLM_LOG_MODEL_INSPECTION=1.

log_online_quantization(vllm_config)

Log the online-quantized layer count and types, when applicable.

log_online_quantization_time(vllm_config)

Log online quantization processing time, when applicable.

unbind_model_loader(model)

Forget the loader recorded for model. A loader that references its model keeps the entry, and so the model, alive until this is called.