Repository navigation
test(load): declare require_load_tokenizer on the last two loader doubles (#4941) - #4957
Merged
Merged
Conversation
…bles (#4941) #4894 made ``ModelLoader`` read ``cls.require_load_tokenizer`` (with ``BaseQModel``'s default of ``True``) at ``gptqmodel/models/loader.py:2070`` and ``:2710``. #4926 declared it on the nine ``DummyQModel`` doubles in ``tests/test_local_model_paths.py`` but only swept that file, so two more plain-class doubles - which mirror ``BaseQModel``'s attributes by hand instead of inheriting them - were still red on main: tests/test_gguf_load_policy_env_removal.py:321 DummyQModel tests/test_lazy_turtle_conversion_cache.py:238 _DummyQModel Both raised ``AttributeError: type object 'DummyQModel' has no attribute 'require_load_tokenizer'`` from loader.py:2070 before the loader did any work, so the GGUF parser-selection guard and the ``.bin`` conversion offload-path guard were not running. Both doubles now declare ``require_load_tokenizer = True``, matching ``BaseQModel``'s default and #4926's wording. A full sweep of ``tests/`` for ``ModelLoader`` doubles (AST walk for classes decorated with ``ModelLoader``, plus every block carrying the doubles' ``require_trust_remote_code``/``require_pkgs``/``supports_desc_act`` markers) finds exactly these two beyond the nine already fixed; the other files that mention ``ModelLoader`` decorate real ``BaseQModel`` subclasses (``LlamaQModel``, ``OlmoeQModel``) and inherit the attribute. Adds ``tests/test_loader_double_contract_4941.py`` so this cannot come back a third time: it statically scans every test module for ``ModelLoader``-decorated classes (they are nested inside test functions, so importing would not expose them) and fails naming any double that does not declare the attribute, pins the two doubles from this issue, and checks ``BaseQModel`` still declares the default the doubles mirror. f160a40: 3 failed (both target tests + the new guard), 54 passed, 2 skipped this commit: 57 passed, 2 skipped
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 #4941.
What was red on
f160a408Fix
require_load_tokenizer = Truewith test(load): declare require_load_tokenizer on the DummyQModel doubles (#4923) #4926's exact comment and placement. Nogetattrfallback was added toloader.py: no production class legitimately lacks the attribute (BaseQModeldeclares itTrue; the onlyFalseis Decision Transformer, which declares it explicitly), and a silent default would hide a genuinely mis-declared definition.tests/test_loader_double_contract_4941.pyAST-scanstests/test_*.pyforModelLoader-decorated classes (they are nested in test functions, so importing cannot expose them) and fails naming any that lack the attribute. It also pins the two doubles from this issue and assertsBaseQModel.require_load_tokenizer is True, so this cannot come back a third time.Sweep
ModelLoaderdecorator occurrences intests/: 9 intest_local_model_paths.py(fixed by #4926) + 1 intest_gguf_load_policy_env_removal.py+ 1 intest_lazy_turtle_conversion_cache.py. The double-marker sweep (require_trust_remote_code =,require_pkgs = [],supports_desc_act = [,loader_requires_dtype) hits only those three files. The other files that mentionModelLoaderuse real definition subclasses or inspect source. No further gaps.Red/green
f160a408(same 6 files)ruff check gptqmodel tests: clean. (tests/test_local_model_loading.pydoes not exist in this tree;tests/test_checkpoint_local_model.pyis the closest loader suite and was run instead — 2 skipped, needs two GPUs +GPTQMODEL_CHECKPOINT_TEST_MODEL.)Residual risk
The guard is static: a double built at runtime (
ModelLoader(some_dict)/type("X", ...)) escapes it, and a double declaring the attribute with a wrong value would pass — the value is a per-model policy, not a contract.