Skip to content
Closed
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
39 changes: 33 additions & 6 deletions vllm/model_executor/layers/quantization/quark/quark.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,39 @@ def __init__(
self.dynamic_mxfp4_quant = False

def maybe_update_config(self, model_name: str, revision: str | None = None):
self.hf_config = get_config(
model=model_name,
trust_remote_code=False, # or get from model_config if available
revision=revision,
config_format="auto",
)
try:
self.hf_config = get_config(
model=model_name,
trust_remote_code=False,
revision=revision,
config_format="auto",
)
except (RuntimeError, ValueError) as e:
# Some local quantized checkpoints rely on custom HF config code.
# Retry only for the explicit trust-remote-code failure mode.
error_text = str(e)
if (
"trust_remote_code=True" not in error_text
and "contains custom code which must be executed" not in error_text
and "requires you to execute the configuration file" not in error_text
):
raise

import logging

logger = logging.getLogger(__name__)
logger.warning(
"The model %s requires custom code to be executed. "
"Falling back to `trust_remote_code=True`.",
model_name,
)

self.hf_config = get_config(
model=model_name,
trust_remote_code=True,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

--trust-remote-code needs to be explicitly provided if it is required, doesn't it, to avoid security risks?
Why would you override this silently?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the review! Yes, --trust-remote-code is needed in the CLI.
Please see updated details #37408 (comment).

revision=revision,
config_format="auto",
)
Comment thread
xuebwang-amd marked this conversation as resolved.

quant_config = getattr(self.hf_config, "quantization_config", None)
if quant_config is not None:
Expand Down
Loading