Repository navigation
test(load): declare require_load_tokenizer on the DummyQModel doubles (#4923) - #4926
Merged
Merged
Conversation
…#4923) #4894 made the loader read `cls.require_load_tokenizer` (`gptqmodel/models/loader.py:2056`, `:2691`) with `BaseQModel`'s default at `gptqmodel/models/base.py:847`. The nine `DummyQModel` doubles in `tests/test_local_model_paths.py` mirror `BaseQModel`'s attributes by hand and were never updated, so the whole file raised AttributeError: type object 'DummyQModel' has no attribute 'require_load_tokenizer' on main: 11 failed, 18 passed. Each double now declares `require_load_tokenizer = True`, which is exactly what a real model class inherits. `tests/test_local_model_paths.py` goes to 29 passed, with and without tokenicer 0.0.19 on the path. Closes #4923. Refs #4894.
This was referenced Nov 17, 2026
Qubitium
added a commit
that referenced
this pull request
Nov 17, 2026
…bles (#4941) (#4957) #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
sLaffey
pushed a commit
to sLaffey/GPTQModel
that referenced
this pull request
Nov 18, 2026
…odelCloud#4941) (ModelCloud#4954) ModelCloud#4894 added `BaseQModel.require_load_tokenizer` and made `ModelLoader` read it as `cls.require_load_tokenizer` at two call sites. Only `BaseQModel` subclasses inherit the default, so every plain-class loader double (and any third-party definition that does not subclass it) aborted the whole load with AttributeError: type object 'DummyQModel' has no attribute 'require_load_tokenizer' ModelCloud#4926 patched the nine doubles in `tests/test_local_model_paths.py`; two more files were still red on main (`test_gguf_load_policy_env_removal.py:321`, `test_lazy_turtle_conversion_cache.py:238`), and the next double would have broken it again. The loader now resolves the flag through `_requires_tokenizer(cls)`, which returns `getattr(cls, "require_load_tokenizer", True)`: an absent attribute means "text model", which is what every definition did before ModelCloud#4894, and an explicit `False` is the only way to skip the text path (Decision Transformer). This fixes both call sites and every future double at once, instead of one file per round. Tests: new `tests/test_loader_tokenizer_flag_4941.py` drives the real `ModelLoader.from_pretrained` with the `.bin` harness from `test_lazy_turtle_conversion_cache.py`: - a double with no `require_load_tokenizer` must still load its tokenizer (red on main: AttributeError at loader.py:2070) - `require_load_tokenizer = False` must skip it - `require_load_tokenizer = True` must keep it - the helper's table: True -> True, False -> False, absent -> True main @ f160a40: 2 failed, 52 passed over the four loader files. With the fix: 61 passed, and 112 passed over all nine `ModelLoader` test files (the sweep the issue asked for). Closes ModelCloud#4941. Refs ModelCloud#4923, ModelCloud#4894.
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.
Summary
tests/test_local_model_paths.pyis red onmain@436053174: 11 failed, 18 passed, all with#4894 (Decision Transformer) made the loader read
cls.require_load_tokenizer:gptqmodel/models/loader.py:2056and:2691—if cls.require_load_tokenizer:gptqmodel/models/base.py:847—require_load_tokenizer: bool = True(theBaseQModeldefault)gptqmodel/models/definitions/decision_transformer.py:33—require_load_tokenizer = FalseThe nine
DummyQModeldoubles in this file mirrorBaseQModel's attributes by hand (require_dtype,require_fast_init,require_trust_remote_code,require_pkgs,support_offload_to_disk, ...) but were not updated with the new one. Real model classes inherit the default, so this is a test-double gap, not a product bug — but it makes the file red onmainand it hits every branch that touches the loader.What Changed
tests/test_local_model_paths.py: eachDummyQModeldeclaresrequire_load_tokenizer = True, i.e.BaseQModel's default. No product code changed; the loader keeps treating the attribute as required for real definitions.Red nodes that go green:
test_model_loader_requires_lazy_turtle_for_offload_to_disk,test_model_loader_uses_lazy_turtle_for_local_safetensors,test_model_loader_from_pretrained_forwards_dtype_kwarg,test_model_loader_from_pretrained_normalizes_direct_gguf_path,test_model_loader_from_pretrained_native_bonsai_fast_profiles_use_dense_path[auto|fast],test_model_loader_from_pretrained_native_bonsai_fast_auto_enables_fa2_on_cuda,test_model_loader_from_pretrained_native_bonsai_fast_keeps_explicit_attn_impl,test_model_loader_from_pretrained_native_bonsai_low_memory_redirects_with_backend[extra_kwargs0-auto|extra_kwargs1-gguf_torch],test_model_loader_falls_back_when_meta_shell_build_hits_meta_tensor_item.Tests
Also verified with
tokenicer==0.0.19first onPYTHONPATH(the versionrequirements.txtpins as>=0.0.19): 29 passed, so the fix does not depend on the local tokenicer version.ruff check tests/test_local_model_paths.py: All checks passed.origin/main.Model Support / Module Plan
Not applicable: test doubles only, no registry or definition change.
Logic Flow Documentation
Not applicable: no product control flow changed.
Review Requirements
BaseQModelattributes, this adds the missing one.BaseQModeldefault, so no test can change behaviour by it; a definition that really wants the text path disabled sets it explicitly (decision_transformer).Closes #4923. Refs #4894.