vllm.model_executor.model_loader.utils ¶
Utilities for selecting and loading models.
Functions:
-
configure_quant_config–Pass packed_modules_mapping by reference to quant_config so that
-
initialize_model–Initialize a model with the given configurations.
-
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.
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
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
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.
Source code in vllm/model_executor/model_loader/utils.py
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 | |