Skip to content

test(load): declare require_load_tokenizer on the last two loader doubles (#4941) - #4957

Merged
Qubitium merged 1 commit into
mainfrom
fix/issue-4941
Nov 17, 2026
Merged

Qubitium merged 1 commit into
mainfrom
fix/issue-4941

Conversation

@Qubitium

Copy link
Copy Markdown
Collaborator

Fixes #4941.

What was red on f160a408

FAILED tests/test_gguf_load_policy_env_removal.py::test_public_load_uses_the_kernel_policy_to_choose_the_gguf_parser
  AttributeError: type object 'DummyQModel' has no attribute 'require_load_tokenizer'   (loader.py:2070)
FAILED tests/test_lazy_turtle_conversion_cache.py::test_loader_converts_bin_under_configured_offload_path_not_tmpdir
  AttributeError: type object '_DummyQModel' has no attribute 'require_load_tokenizer'  (loader.py:2070)
2 failed, 18 passed

Fix

  • Both doubles declare require_load_tokenizer = True with test(load): declare require_load_tokenizer on the DummyQModel doubles (#4923) #4926's exact comment and placement. No getattr fallback was added to loader.py: no production class legitimately lacks the attribute (BaseQModel declares it True; the only False is Decision Transformer, which declares it explicitly), and a silent default would hide a genuinely mis-declared definition.
  • New tests/test_loader_double_contract_4941.py AST-scans tests/test_*.py for ModelLoader-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 asserts BaseQModel.require_load_tokenizer is True, so this cannot come back a third time.

Sweep

ModelLoader decorator occurrences in tests/: 9 in test_local_model_paths.py (fixed by #4926) + 1 in test_gguf_load_policy_env_removal.py + 1 in test_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 mention ModelLoader use real definition subclasses or inspect source. No further gaps.

Red/green

tree result
f160a408 (same 6 files) 3 failed (both targets + the new guard), 54 passed, 2 skipped, exit 1
this commit 57 passed, 2 skipped, exit 0

ruff check gptqmodel tests: clean. (tests/test_local_model_loading.py does not exist in this tree; tests/test_checkpoint_local_model.py is 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.

…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant