[Model] Add torch.compile support for InternVL vision encoder (#38049)

Signed-off-by: tianrengao <terrygao87@gmail.com>
This commit is contained in:
Terry Gao
2026-03-25 23:52:29 -07:00
committed by GitHub
parent 2bfbdca23c
commit 38de822310
2 changed files with 20 additions and 3 deletions

View File

@@ -296,7 +296,15 @@ def normalize_value(x):
# PretrainedConfig
if hasattr(x, "to_json_string") and callable(x.to_json_string):
return 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