Skip to content

fix(load): accept the Hub staging options a quantized load forwards (#5007) - #5016

Merged
Qubitium merged 1 commit into
mainfrom
root/load-hub-kwargs-5007
Nov 17, 2026
Merged

Qubitium merged 1 commit into
mainfrom
root/load-hub-kwargs-5007

Conversation

@Qubitium

Copy link
Copy Markdown
Collaborator

Summary

Fixes #5007. #4972 made a quantized GPTQModel.load() reject every keyword left
after the explicit pops, but the Hub staging options are never popped: they are
forwarded to snapshot_download while the remote checkpoint is resolved, and
they are also listed as accepted by the error message. So the load failed with a
self-contradicting error:

LlamaQModel.from_quantized: unexpected keyword argument(s) for a quantized
checkpoint: `token` (did you mean `token`?). A quantized load accepts
`_commit_hash`, ... `max_workers`, ... `token`, ...

GPTQModel.load("<org>/<private-gptq-repo>", token=...) worked before #4972 and
always raised after it; max_workers, local_dir, endpoint, headers,
etag_timeout, allow_patterns, ignore_patterns and repo_type failed the
same way.

What Changed

  • gptqmodel/models/loader.py: the leftover set is compared against the same
    accepted set the error message prints
    (_accepted_quantized_load_kwargs, which derives the names from
    from_quantized's signature, the recorded pops, and
    inspect.signature(snapshot_download)). A forwarded option is accepted; a
    real typo is still rejected.
  • gptqmodel/utils/hf.py: token joins CONFIG_SELECTION_KWARGS. Model-type
    detection reads the config before the loader stages the checkpoint, so a
    private or gated repository needs the same credential there. None is still
    skipped by get_config_selection_kwargs, so an unset token is not forced into
    the HF call.
  • tests/test_load_strict_kwargs_4945.py: four parametrized Hub-option cases
    (token, max_workers, etag_timeout, repo_type), a Hub-option typo case
    (tokn= -> "did you mean token?"), and a unit test for the config-selection
    forwarding.

Tests

On unmodified origin/main (24a46e337, test file copied into a separate
worktree): 5 failed, 8 passed — all four Hub-option cases raise the
self-contradicting TypeError, and token is missing from the config-selection
set. The typo case already passes there, which is the point: accepting the Hub
options must not accept a misspelling.

On this branch: 13 passed. Neighbouring loader suites
(test_hf_gptqmodel_load_bridge.py, test_loader.py,
test_loader_offload_staging_4385.py, test_loader_double_contract_4941.py,
test_loader_tokenizer_flag_4941.py, test_docs_contract_refs.py): 73
passed
. tests/test_local_model_paths.py: 29 passed. ruff check clean on
all changed files.

Notes

  • The check still derives its accepted set from code (no literal list), so a new
    snapshot_download option is accepted automatically and a new from_quantized
    parameter or popped key keeps working — the existing
    test_new_load_options_are_accepted_from_the_signature_and_pops still covers
    that.
  • Only token was added to the config-selection set: the other Hub options
    (max_workers, local_dir, endpoint, ...) affect the download, not which
    config file is read.

…5007)

#4972 rejected every keyword left in `kwargs_without_internal` after the
explicit pops, but the Hub staging options (`token`, `max_workers`, `local_dir`,
`endpoint`, `headers`, `etag_timeout`, `allow_patterns`, `ignore_patterns`,
`repo_type`, ...) are forwarded un-popped to `snapshot_download` while the
remote checkpoint is resolved. They were also listed as accepted in the error
message, so `GPTQModel.load(repo, token=...)` always failed with the
self-contradicting

    unexpected keyword argument(s) ...: `token` (did you mean `token`?) ...
    A quantized load accepts ..., `max_workers`, ..., `token`, ...

The leftover set is now compared against the same accepted set the message
prints, so a keyword that is forwarded is accepted and a real typo still
raises. `token` also joins `CONFIG_SELECTION_KWARGS`: model-type detection
reads the config before the loader stages the checkpoint, so a private or gated
repository needed the credential there too.
@Qubitium
Qubitium merged commit eedb594 into main Nov 17, 2026
9 checks passed
@Qubitium
Qubitium deleted the root/load-hub-kwargs-5007 branch November 17, 2026 22:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] #4972 (fix of #4945) rejects the Hub options it forwards: GPTQModel.load(quantized, token=...) now raises 'unexpected token (did you mean token?)'

1 participant