vllm.model_executor.model_loader.base_loader
¶
Classes:
-
BaseModelLoader–Base class for model loaders.
Functions:
-
bind_model_loader–Record
loaderas the loader that loadedmodel. -
get_bound_model_loader–Return the loader that loaded
model, if it was recorded. -
log_model_inspection–Log model structure if VLLM_LOG_MODEL_INSPECTION=1.
-
log_online_quantization–Log the online-quantized layer count and types, when applicable.
-
log_online_quantization_time–Log online quantization processing time, when applicable.
-
unbind_model_loader–Forget the loader recorded for
model. A loader that references its
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.
Source code in vllm/model_executor/model_loader/base_loader.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 | |
create_model(vllm_config, model_config, prefix='')
¶
Create a model with the given configurations.
Source code in vllm/model_executor/model_loader/base_loader.py
download_model(model_config)
abstractmethod
¶
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).
Source code in vllm/model_executor/model_loader/base_loader.py
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.
Source code in vllm/model_executor/model_loader/base_loader.py
load_weights(model, model_config)
abstractmethod
¶
Load weights into a model. This standalone API allows inplace weights loading for an already-initialized model
Source code in vllm/model_executor/model_loader/base_loader.py
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.
Source code in vllm/model_executor/model_loader/base_loader.py
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.
Source code in vllm/model_executor/model_loader/base_loader.py
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.
Source code in vllm/model_executor/model_loader/base_loader.py
_get_online_quantization_config(vllm_config)
¶
Return the online quantization config when one is configured.
Source code in vllm/model_executor/model_loader/base_loader.py
bind_model_loader(model, loader)
¶
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.
Source code in vllm/model_executor/model_loader/base_loader.py
log_online_quantization(vllm_config)
¶
Log the online-quantized layer count and types, when applicable.
Source code in vllm/model_executor/model_loader/base_loader.py
log_online_quantization_time(vllm_config)
¶
Log online quantization processing time, when applicable.
Source code in vllm/model_executor/model_loader/base_loader.py
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.