-
-
Notifications
You must be signed in to change notification settings - Fork 13.4k
[Bugfix] FIx TorchAO config bugs #34430
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -609,6 +609,7 @@ def __post_init__(self): | |
| self.weight_transfer_config = WeightTransferConfig( | ||
| **self.weight_transfer_config | ||
| ) | ||
| self._normalize_hf_overrides() | ||
| # Setup plugins | ||
| from vllm.plugins import load_general_plugins | ||
|
|
||
|
|
@@ -634,6 +635,47 @@ def __post_init__(self): | |
| self.tokenizer, | ||
| ) | ||
|
|
||
| def _normalize_hf_overrides(self) -> None: | ||
| """Normalize hf_overrides to a dict or callable. | ||
|
|
||
| Supports JSON strings and JSON files when prefixed with '@'. | ||
| """ | ||
| if self.hf_overrides is None or callable(self.hf_overrides): | ||
| return | ||
| if isinstance(self.hf_overrides, dict): | ||
| return | ||
| if not isinstance(self.hf_overrides, str): | ||
| raise TypeError( | ||
| "hf_overrides must be a dict, a callable, or a JSON string." | ||
| ) | ||
|
|
||
| raw = self.hf_overrides.strip() | ||
| if raw.startswith("@"): | ||
| path = raw[1:] | ||
| if not path: | ||
| raise ValueError("hf_overrides file path is empty.") | ||
| try: | ||
| with open(path, encoding="utf-8") as handle: | ||
| self.hf_overrides = json.load(handle) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The loaded JSON from the file should be validated to be a dictionary. The loaded_json = json.load(handle)
if not isinstance(loaded_json, dict):
raise ValueError(
f"hf_overrides file must contain a JSON object: {path}"
)
self.hf_overrides = loaded_json |
||
| except FileNotFoundError as exc: | ||
| raise FileNotFoundError(f"hf_overrides file not found: {path}") from exc | ||
| except json.JSONDecodeError as exc: | ||
| raise ValueError( | ||
| f"hf_overrides file is not valid JSON: {path}" | ||
| ) from exc | ||
| return | ||
|
|
||
| if re.match(r"(?s)^\s*{.*}\s*$", raw): | ||
| try: | ||
| self.hf_overrides = json.loads(raw) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to the file loading case, the loaded JSON from the string should be validated to be a dictionary. If the string is a valid JSON primitive (e.g., loaded_json = json.loads(raw)
if not isinstance(loaded_json, dict):
raise ValueError("hf_overrides string must be a JSON object.")
self.hf_overrides = loaded_json |
||
| return | ||
| except json.JSONDecodeError as exc: | ||
| raise ValueError("hf_overrides is not valid JSON.") from exc | ||
|
|
||
| raise ValueError( | ||
| "hf_overrides must be a JSON object string or '@' followed by a JSON file." | ||
| ) | ||
|
|
||
| @staticmethod | ||
| def add_cli_args(parser: FlexibleArgumentParser) -> FlexibleArgumentParser: | ||
| """Shared CLI arguments for vLLM engine.""" | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need to have this option? does passing around
'{"quantization_config_file": "/tmp/torchao.json"}in command line work?