fix: move dummy format loader check before quantization checks (#12532)
This commit is contained in:
@@ -383,6 +383,10 @@ class DefaultModelLoader(BaseModelLoader):
|
|||||||
allow_patterns = ["*.pt"]
|
allow_patterns = ["*.pt"]
|
||||||
elif load_format == LoadFormat.NPCACHE:
|
elif load_format == LoadFormat.NPCACHE:
|
||||||
allow_patterns = ["*.bin"]
|
allow_patterns = ["*.bin"]
|
||||||
|
elif load_format == LoadFormat.DUMMY:
|
||||||
|
raise ValueError(
|
||||||
|
f"DUMMY load_format should use DummyModelLoader and not call _prepare_weights"
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
raise ValueError(f"Unknown load_format: {load_format}")
|
raise ValueError(f"Unknown load_format: {load_format}")
|
||||||
|
|
||||||
@@ -2045,6 +2049,9 @@ def get_model_loader(
|
|||||||
) -> BaseModelLoader:
|
) -> BaseModelLoader:
|
||||||
"""Get a model loader based on the load format."""
|
"""Get a model loader based on the load format."""
|
||||||
|
|
||||||
|
if load_config.load_format == LoadFormat.DUMMY:
|
||||||
|
return DummyModelLoader(load_config)
|
||||||
|
|
||||||
if model_config and (
|
if model_config and (
|
||||||
(hasattr(model_config, "modelopt_quant") and model_config.modelopt_quant)
|
(hasattr(model_config, "modelopt_quant") and model_config.modelopt_quant)
|
||||||
or model_config.quantization in ["modelopt_fp8", "modelopt_fp4", "modelopt"]
|
or model_config.quantization in ["modelopt_fp8", "modelopt_fp4", "modelopt"]
|
||||||
@@ -2071,9 +2078,6 @@ def get_model_loader(
|
|||||||
if isinstance(load_config.load_format, type):
|
if isinstance(load_config.load_format, type):
|
||||||
return load_config.load_format(load_config)
|
return load_config.load_format(load_config)
|
||||||
|
|
||||||
if load_config.load_format == LoadFormat.DUMMY:
|
|
||||||
return DummyModelLoader(load_config)
|
|
||||||
|
|
||||||
if load_config.load_format == LoadFormat.SHARDED_STATE:
|
if load_config.load_format == LoadFormat.SHARDED_STATE:
|
||||||
return ShardedStateLoader(load_config)
|
return ShardedStateLoader(load_config)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user