Repository navigation
fix(save): reject unknown save() keywords on the quantized path (#4686) - #4698
Merged
Merged
Conversation
) `BaseQModel.save(..., **kwargs)` forwarded `**kwargs` only on the non-quantized branch. For a quantized model — the normal case — every extra keyword was discarded without an error or a log line, so a typo of a real parameter and an HF option such as `push_to_hub=True` both reported success and did nothing. Raise `TypeError` for any leftover keyword on the quantized branch, with the same difflib close-match hint `QuantizeConfig` uses for unknown kwargs (#4057): `max_shard_sise` now points at `max_shard_size`. The module-replacement writer (`save_quantized_embeddings`) also dropped two of `save()`'s own named parameters. It writes a weight-only replacement checkpoint and has no adapter or split support, so `eora_path`/`split_by` are now rejected there explicitly instead of being ignored. This is the save-side counterpart of #4052/#4057. Closes #4686.
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 #4686
Root cause
BaseQModel.save(save_dir, ..., **kwargs)forwarded**kwargsonly on thenon-quantized branch (
self.save_pretrained(save_dir=save_dir, **kwargs)).For a quantized model — the normal case — every extra keyword was discarded
without an error or a log line. That covered both typos of real parameters and
HF-style options a caller reasonably expects to work.
The model-free weight-only replacement branch (
save_quantized_embeddings) alsodropped two of
save()'s own named parameters,eora_pathandsplit_by.Fix
Unknown keywords now raise
TypeErroron the quantized branch, with the samedifflib close-match hint
QuantizeConfiguses for unknown kwargs (#4057):safe_serializationandpush_to_hubhave no close match, but they still raiseinstead of silently doing nothing — a CI job that "publishes" the checkpoint can
no longer report success without uploading.
eora_path/split_byare rejected explicitly on the module-replacementpath:
save_quantized_embeddingswrites a weight-only replacement checkpoint andhas no adapter or split support, so forwarding them would be a lie. The issue
allowed either forwarding or rejecting; rejecting is the honest option here.
The dense (
save_pretrained) branch is unchanged and still forwards**kwargs.Before / after
The issue's repro, quantized
RTNConfig(bits=4, group_size=128)model:Tests
New
tests/test_save_kwargs_validation_4686.py(5 tests).save()is driventhrough a
BaseQModelshell so the argument handling is checked without payingfor a real quantization run:
test_quantized_save_rejects_a_typo_with_a_close_match_hinttest_quantized_save_rejects_options_it_cannot_honor(parametrized:safe_serialization,push_to_hub+repo_id)test_quantized_save_accepts_its_own_parameters— guard: the six documentedparameters still reach
save_quantizedwith their values intacttest_weight_only_replacement_save_rejects_eora_path_and_split_byFail-before, with the source change reverted and the tests kept:
Pass-after:
The single failure,
test_checkpoint_compat.py::test_untied_lm_head_quantizes_and_reloads,is pre-existing on pristine
origin/main(verified by stash + rerun) andenvironmental:
This host mixes four RTX 4090 (sm_89) with an RTX 5090 (sm_120) at
cuda:4.Scope / limits
eora_path/split_byare rejected rather than implemented for themodule-replacement writer; adding adapter support to that path would be a
separate feature, and the issue explicitly permits rejection.
push_to_hubcase is made loud, not working: it now raises instead ofsilently not uploading. Making it actually upload is a feature request, not
this bug.