From de900fa7e5e1a28cc1faac94b76981993e648f4f Mon Sep 17 00:00:00 2001 From: Angela Yi Date: Wed, 10 Jun 2026 08:05:29 -0700 Subject: [PATCH] fix: AOT compile cache collision for dataclass-based HF configs (#45059) Signed-off-by: Angela Yi --- vllm/config/utils.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/vllm/config/utils.py b/vllm/config/utils.py index a953fcb46e..12e0385aeb 100644 --- a/vllm/config/utils.py +++ b/vllm/config/utils.py @@ -279,6 +279,18 @@ def normalize_value(x): except Exception: return str(x) + # PretrainedConfig (must be before dataclass branch as these are now dataclasses) + if hasattr(x, "to_json_string") and callable(x.to_json_string): + try: + return x.to_json_string() + except (TypeError, ValueError): + # to_json_string() may fail for trust-remote-code configs + # with non-JSON-serializable nested objects. Fall back to + # normalizing the dict representation recursively. + if hasattr(x, "to_dict") and callable(x.to_dict): + return normalize_value(x.to_dict()) + raise + # Dataclasses: represent as (FQN, sorted(field,value) tuple) for stability. if is_dataclass(x): type_fqn = f"{x.__class__.__module__}.{x.__class__.__qualname__}" @@ -296,18 +308,6 @@ def normalize_value(x): if isinstance(x, Sequence) and not isinstance(x, (str, bytes, bytearray)): return tuple(normalize_value(v) for v in x) - # PretrainedConfig - if hasattr(x, "to_json_string") and callable(x.to_json_string): - try: - return x.to_json_string() - except (TypeError, ValueError): - # to_json_string() may fail for trust-remote-code configs - # with non-JSON-serializable nested objects. Fall back to - # normalizing the dict representation recursively. - if hasattr(x, "to_dict") and callable(x.to_dict): - return normalize_value(x.to_dict()) - raise - # Unsupported type: e.g., modules, generators, open files, or objects # without a stable JSON/UUID representation. Hard-error to avoid # under-hashing.