[UX] Add model_class_overrides for development and debugging (#47148)
Signed-off-by: Jee Jee Li <jeejeelee@inferact.ai> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
co-authored by
mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
parent
c64c356990
commit
32ab064621
@@ -649,6 +649,30 @@ def test_nested_hf_overrides():
|
||||
assert model_config.hf_config.vision_config.hidden_size == 512
|
||||
|
||||
|
||||
def test_model_class_overrides_registers_target():
|
||||
"""`model_class_overrides` redirects an architecture to a custom class."""
|
||||
from vllm.model_executor.models import ModelRegistry
|
||||
|
||||
arch = "_TestModelClassOverrideArch"
|
||||
target = "vllm.model_executor.models.llama:LlamaForCausalLM"
|
||||
assert arch not in ModelRegistry.models
|
||||
|
||||
model_config = ModelConfig(
|
||||
"facebook/opt-125m",
|
||||
model_class_overrides={arch: target},
|
||||
)
|
||||
try:
|
||||
# Accessing `.registry` is the chokepoint that applies the overrides;
|
||||
# it has already run during construction.
|
||||
registered = model_config.registry.models[arch]
|
||||
assert registered.module_name == "vllm.model_executor.models.llama"
|
||||
assert registered.class_name == "LlamaForCausalLM"
|
||||
# Idempotent: a second access does not re-register or error out.
|
||||
assert model_config.registry.models[arch] is registered
|
||||
finally:
|
||||
ModelRegistry.models.pop(arch, None)
|
||||
|
||||
|
||||
@pytest.mark.skipif(
|
||||
current_platform.is_rocm(), reason="Encoder Decoder models not supported on ROCm."
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user