Bases: BaseModelLoader
Model loader that will set model weights to random values.
Source code in vllm/model_executor/model_loader/dummy_loader.py
| class DummyModelLoader(BaseModelLoader):
"""Model loader that will set model weights to random values."""
def __init__(self, load_config: LoadConfig):
super().__init__(load_config)
if load_config.model_loader_extra_config:
raise ValueError(f"Model loader extra config is not supported for "
f"load format {load_config.load_format}")
def download_model(self, model_config: ModelConfig) -> None:
pass # Nothing to download
def load_model(self, vllm_config: VllmConfig,
model_config: ModelConfig) -> nn.Module:
device_config = vllm_config.device_config
target_device = torch.device(device_config.device)
with set_default_torch_dtype(model_config.dtype):
with target_device:
model = initialize_model(vllm_config=vllm_config)
# NOTE(woosuk): For accurate performance evaluation, we assign
# random values to the weights.
initialize_dummy_weights(model)
process_weights_after_loading(model, model_config, target_device)
return model.eval()
|
__init__
Source code in vllm/model_executor/model_loader/dummy_loader.py
| def __init__(self, load_config: LoadConfig):
super().__init__(load_config)
if load_config.model_loader_extra_config:
raise ValueError(f"Model loader extra config is not supported for "
f"load format {load_config.load_format}")
|
download_model
Source code in vllm/model_executor/model_loader/dummy_loader.py
| def download_model(self, model_config: ModelConfig) -> None:
pass # Nothing to download
|
load_model
Source code in vllm/model_executor/model_loader/dummy_loader.py
| def load_model(self, vllm_config: VllmConfig,
model_config: ModelConfig) -> nn.Module:
device_config = vllm_config.device_config
target_device = torch.device(device_config.device)
with set_default_torch_dtype(model_config.dtype):
with target_device:
model = initialize_model(vllm_config=vllm_config)
# NOTE(woosuk): For accurate performance evaluation, we assign
# random values to the weights.
initialize_dummy_weights(model)
process_weights_after_loading(model, model_config, target_device)
return model.eval()
|