Skip to content

Fix CompilationConfig repr #19091

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import pytest

from vllm.compilation.backends import VllmBackend
from vllm.config import (LoadConfig, ModelConfig, PoolerConfig, VllmConfig,
config, get_field)
from vllm.model_executor.layers.pooler import PoolingType
Expand Down Expand Up @@ -43,6 +44,18 @@ def test_config(test_config, expected_error):
config(test_config)


def test_compile_config_repr_succeeds():
# setup: VllmBackend mutates the config object
config = VllmConfig()
backend = VllmBackend(config)
backend.configure_post_pass()

# test that repr(config) succeeds
val = repr(config)
assert 'VllmConfig' in val
assert 'inductor_passes' in val


def test_get_field():

@dataclass
Expand Down
35 changes: 20 additions & 15 deletions vllm/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ def architectures(self) -> list[str]:
def maybe_pull_model_tokenizer_for_s3(self, model: str,
tokenizer: str) -> None:
"""Pull model/tokenizer from S3 to temporary directory when needed.

Args:
model: Model name or path
tokenizer: Tokenizer name or path
Expand Down Expand Up @@ -1369,9 +1369,9 @@ def get_diff_sampling_param(self) -> dict[str, Any]:
def is_encoder_decoder(self) -> bool:
"""Extract the HF encoder/decoder model flag."""
"""
For Mllama, VLLM overrides HF's is_encoder_decoder flag and sets it to
For Mllama, VLLM overrides HF's is_encoder_decoder flag and sets it to
True to enable cross-attention
Neuron needs all multimodal data to be in the decoder and does not
Neuron needs all multimodal data to be in the decoder and does not
need to explicitly enable cross-attention
"""
if (current_platform.is_neuron()
Expand Down Expand Up @@ -1791,7 +1791,7 @@ class is dynamically inherited by the worker class. This is used to inject
"""Global rank in distributed setup."""

enable_multimodal_encoder_data_parallel: bool = False
""" Use data parallelism instead of tensor parallelism for vision encoder.
""" Use data parallelism instead of tensor parallelism for vision encoder.
Only support LLama4 for now"""

@property
Expand Down Expand Up @@ -2255,9 +2255,9 @@ class DeviceConfig:

device: SkipValidation[Union[Device, torch.device]] = "auto"
"""Device type for vLLM execution.
This parameter is deprecated and will be
removed in a future release.
It will now be set automatically based
This parameter is deprecated and will be
removed in a future release.
It will now be set automatically based
on the current platform."""
device_type: str = field(init=False)
"""Device type from the current platform. This is set in
Expand Down Expand Up @@ -3987,19 +3987,24 @@ def compute_hash(self) -> str:

def __repr__(self) -> str:
exclude = {
"static_forward_context",
"enabled_custom_ops",
"disabled_custom_ops",
"compilation_time",
"bs_to_padded_graph_size",
"pass_config",
"traced_files",
"static_forward_context": True,
"enabled_custom_ops": True,
"disabled_custom_ops": True,
"compilation_time": True,
"bs_to_padded_graph_size": True,
"pass_config": True,
"traced_files": True,
"inductor_compile_config": {
"post_grad_custom_post_pass": True,
},
}
# The cast to string is necessary because Pydantic is mocked in docs
# builds and sphinx-argparse doesn't know the return type of decode()
return str(
TypeAdapter(CompilationConfig).dump_json(
self, exclude=exclude, exclude_unset=True).decode())
self,
exclude=exclude, # type: ignore[arg-type]
exclude_unset=True).decode())

__str__ = __repr__

Expand Down