Skip to content
Merged
Empty file.
37 changes: 37 additions & 0 deletions tests/transformers_utils/test_config_parser_registry.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# SPDX-License-Identifier: Apache-2.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add this directory to "Async Engine, Inputs, Utils, Worker Test" so it's actually being run in CI

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Added in #24615

# SPDX-FileCopyrightText: Copyright contributors to the vLLM project

from pathlib import Path
from typing import Optional, Union

import pytest
from transformers import PretrainedConfig

from vllm.transformers_utils.config import (get_config_parser,
register_config_parser)
from vllm.transformers_utils.config_parser_base import ConfigParserBase


@register_config_parser("custom_config_parser")
class CustomConfigParser(ConfigParserBase):

def parse(self,
model: Union[str, Path],
trust_remote_code: bool,
revision: Optional[str] = None,
code_revision: Optional[str] = None,
**kwargs) -> tuple[dict, PretrainedConfig]:
raise NotImplementedError


def test_register_config_parser():
assert isinstance(get_config_parser("custom_config_parser"),
CustomConfigParser)


def test_invalid_config_parser():
with pytest.raises(ValueError):

@register_config_parser("invalid_config_parser")
class InvalidConfigParser:
pass
5 changes: 1 addition & 4 deletions vllm/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ class ModelConfig:
`--media-io-kwargs '{"video": {"num_frames": 40} }'` """
use_async_output_proc: bool = True
"""Whether to use async output processor."""
config_format: Union[str, ConfigFormat] = ConfigFormat.AUTO.value
config_format: Union[str, ConfigFormat] = "auto"
"""The format of the model config to load:\n
- "auto" will try to load the config in hf format if available else it
will try to load in mistral format.\n
Expand Down Expand Up @@ -625,9 +625,6 @@ def __post_init__(self) -> None:
raise ValueError(
"Sleep mode is not supported on current platform.")

if isinstance(self.config_format, str):
self.config_format = ConfigFormat(self.config_format)

hf_config = get_config(self.hf_config_path or self.model,
self.trust_remote_code,
self.revision,
Expand Down
7 changes: 3 additions & 4 deletions vllm/engine/arg_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@

import vllm.envs as envs
from vllm.config import (BlockSize, CacheConfig, CacheDType, CompilationConfig,
ConfigFormat, ConfigType, ConvertOption,
DecodingConfig, DetailedTraceModules, Device,
DeviceConfig, DistributedExecutorBackend, EPLBConfig,
ConfigType, ConvertOption, DecodingConfig,
DetailedTraceModules, Device, DeviceConfig,
DistributedExecutorBackend, EPLBConfig,
GuidedDecodingBackend, HfOverrides, KVEventsConfig,
KVTransferConfig, LoadConfig, LogprobsMode,
LoRAConfig, MambaDType, MMEncoderTPMode, ModelConfig,
Expand Down Expand Up @@ -547,7 +547,6 @@ def add_cli_args(parser: FlexibleArgumentParser) -> FlexibleArgumentParser:
help="Disable async output processing. This may result in "
"lower performance.")
model_group.add_argument("--config-format",
choices=[f.value for f in ConfigFormat],
**model_kwargs["config_format"])
# This one is a special case because it can bool
# or str. TODO: Handle this in get_kwargs
Expand Down
Loading