Repository navigation
fix(load): reject unknown kwargs and a dropped quantize_config on quantized loads (#4945) - #4972
Merged
Merged
Conversation
Qubitium
force-pushed
the
root/load-strict-kwargs-4945
branch
from
November 17, 2026 20:16
737e193 to
e3a551c
Compare
…ntized loads (#4945) `ModelLoader.from_quantized` popped the options it knew and let every other keyword reach `QuantizeConfig.from_pretrained`, which ignored it. A typo of a real option (`dtpye=`, `attn_implmentation=`, `devcie_map=`) or an option that does not apply (`bits=`) therefore "succeeded" and changed nothing, while the unquantized path raises from the HF constructor. A passed `quantize_config` was dropped the same way: the checkpoint's config won without a word. Wrap the keyword dict in `_TrackedKwargs`, which records every key consumed by `pop`, and raise `TypeError` for whatever is left after the internal keys are normalised. The accepted set is derived from `inspect.signature(cls.from_quantized)`, the recorded pops, and `inspect.signature(snapshot_download)` (the Hub staging options), so a newly added parameter or pop is accepted without editing a literal list. The message reuses the difflib close-match style of #4686: `dtpye` now points at `dtype`. VLLM/SGLang keep their explicit passthrough runtime options. `GPTQModel.load(quantized, quantize_config=...)` now raises `ValueError` instead of ignoring the argument: a quantized checkpoint's bits/group_size/method/format come from the checkpoint, and forwarding a different config was not provably safe. Two loader tests passed `quantize_config=` to `from_quantized`, relying on the silent drop; they now call it without that argument. Closes #4945. Also switch the `extract_adapter_rank_patterns` citation in docs/adapter-rank-pattern-matching.md to the symbol form (`config.py::extract_adapter_rank_patterns`). #4970 added ~137 lines above that definition, so the old `config.py:5595` citation fails `tests/test_docs_contract_refs.py` on pristine main and blocks the required AWQ CPU (unit) check.
Qubitium
force-pushed
the
root/load-strict-kwargs-4945
branch
from
November 17, 2026 20:23
e3a551c to
30379bb
Compare
This was referenced Nov 17, 2026
sLaffey
pushed a commit
to sLaffey/GPTQModel
that referenced
this pull request
Nov 18, 2026
…odelCloud#5007) (ModelCloud#5016) ModelCloud#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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #4945
Summary
GPTQModel.load()handled extra arguments differently on its two paths. Anunquantized load reaches the HF constructor, which raises for an unknown
keyword. A quantized load popped the options it knew and let the rest reach
QuantizeConfig.from_pretrained, which ignored them, sodtpye=,attn_implmentation=,devcie_map=andbits=all "succeeded" and changednothing.
GPTQModel.load(quantized_path, quantize_config)was dropped the sameway: the checkpoint's own config won with no message.
This is the load-side twin of #4686 (quantized
save(**kwargs)), and it reusesthat fix's
difflibclose-match message style so both paths read the same.What Changed
ModelLoader.from_quantizednow wraps its keyword dict in_TrackedKwargs,which records every key consumed by
pop. After the internal keys arenormalised (
INTERNAL_HF_GGUF_FILE_KWARG,device_map,backend,dtype,format,subfolder,revision,attn_implementation,tokenizer_trust_remote_code, the HF cache options, the checkpoint-offloadoptions,
max_memory, ...) any leftover key raisesTypeError._accepted_quantized_load_kwargs()combinesinspect.signature(cls.from_quantized)with the recorded pops and
inspect.signature(snapshot_download)(the Hubstaging options the loader forwards). A newly added parameter or a new
pop()is accepted automatically;tests/test_load_strict_kwargs_4945.pypins this with a synthetic
from_quantizedthat has a brand-new parameterand a brand-new popped key.
format=is popped once and passed explicitly toQuantizeConfig.from_pretrained, which is the only place that read it from**kwargs.QuantizeConfig.from_pretraineditself is unchanged.GPTQModel.load(quantized_path, quantize_config=...)now raisesValueError(the preferred option in the issue) instead of ignoring the argument: a
quantized checkpoint's bits/group_size/method/format come from the
checkpoint. Forwarding was not provably safe (it would contradict the tensors
on disk), so it is rejected with a message that says what to do instead.
VLLM/SGLangremain explicit passthrough engines: their runtime options(
gpu_memory_utilization,max_model_len,enforce_eager, ...) are owned bythe engine and are not rejected.
quantize_config=tofrom_quantizedwererelying on the silent drop; they now call it without that argument, which is
what the loader actually accepted.
docs/config-serialization.mddocuments the new contract and the flow.Exact error messages
Accepted kwargs
Derived at call time from the signature, the recorded pops, and the Hub
snapshot options:
adapter,adapter_revision,adapter_sha256,allow_patterns,allow_remote_adapter,attn_implementation,backend,cache_dir,device,device_map,dry_run,dtype,endpoint,etag_timeout,force_download,format,fuse,gguf_file,headers,ignore_patterns,kernel,library_name,library_version,local_dir,local_files_only,max_memory,max_workers,module_tree,p2p,proxies,repo_id,repo_type,resume_download,revision,runtime,subfolder,token,tokenizer_trust_remote_code,torch_dtype,tqdm_class,trust_remote_code,use_auth_token,user_agent, plus the internal_commit_hashand_gptqmodel_hf_gguf_fileand the checkpoint-offload optionsoffload_folder,offload_state_dict,offload_bufferswhen popped.Note:
tokenizer=is not a load option (the tokenizer is read from thecheckpoint); the accepted spelling is
tokenizer_trust_remote_code=. A literaltokenizer=now raises instead of being ignored.Logic flow
flowchart TD A["GPTQModel.load(path, **kwargs)"] --> B{"checkpoint has a GPTQModel<br/>quantization config?"} B -- yes --> C{"quantize_config= also passed?"} C -- yes --> D["ValueError: config comes<br/>from the checkpoint"] C -- no --> E["ModelLoader.from_quantized<br/>(_TrackedKwargs records every pop)"] E --> F{"backend is VLLM or SGLang?"} F -- yes --> G["pass through: engine owns<br/>its runtime options"] F -- no --> H{"kwargs left after<br/>normalisation?"} H -- no --> I["continue the load"] H -- yes --> J["TypeError naming each key,<br/>difflib hint when close"] B -- no --> K["from_pretrained: HF constructor<br/>already raises for unknown keys"]The same diagram is in
docs/config-serialization.md(linked fromdocs/README.md).Tests
New
tests/test_load_strict_kwargs_4945.py(7 tests, CPU): quantizesHuggingFaceTB/SmolLM2-135Monce (GPTQ 4-bit g128, 8 calibration rows), thendtpye=torch.float16->TypeError, namesdtpye, suggestsdtypeattn_implmentation="eager"->TypeError, suggestsattn_implementationbits=8->TypeError, no close match, still rejectedAWQConfig(bits=8, group_size=32)->ValueError, config comes from the checkpointdtype=,attn_implementation=,device="cpu",backend=,format=still loadTypeErrorfordtpye=Red on unmodified
origin/main(test copied into a detached worktree atorigin/main, source change absent):The two passes are the "valid kwargs still work" and unquantized-path tests,
which must pass on main; the five assertions that describe the bug fail
(
Failed: DID NOT RAISE TypeError/DID NOT RAISE ValueError, and themissing helper).
Green on the branch:
The one failure is
test_save_loaded_quantized_model.py::TestSave::test_save_2_triton(
TritonV2Linear does not support device: cpu) on this CPU-only runner; itfails identically on unmodified
origin/main(verified in the base worktree).Lint:
Model Support / Module Plan
Not applicable: no model, alias, or definition change.
AWQ onboarding safety
Not applicable: no model onboarding or AWQ grouping/search/replay/fold change.
Review Requirements
Kernel Accuracy Requirements
Not applicable: no kernel change.
Notes
docs/adapter-rank-pattern-matching.mdnow citesconfig.py::extract_adapter_rank_patternsin the symbol form instead ofconfig.py:5595. fix(config): validate smoother parameters at construction (#4953) #4970 added ~137 lines above that definition, so the oldline citation fails
tests/test_docs_contract_refs.pyon pristineorigin/main(verified:
1 failed, 19 passedin a detached worktree at55f9d9fc7), whichfails the required AWQ CPU (unit) check for every PR. This is a two-line doc/test
anchor change, not part of the load fix.
loading with defaults. This is intentional and matches the unquantized path.
GPTQModel.load(quantized, quantize_config=...)now raises.The issue preferred rejection; forwarding was not provably safe.
use_auth_tokenand the Hub staging options remain accepted so existingremote loads are unaffected.