Skip to content

test(load): declare require_load_tokenizer on the DummyQModel doubles (#4923) - #4926

Merged
Qubitium merged 1 commit into
mainfrom
root/local-paths-doubles-4923
Nov 17, 2026
Merged

Qubitium merged 1 commit into
mainfrom
root/local-paths-doubles-4923

Conversation

@Qubitium

Copy link
Copy Markdown
Collaborator

Summary

tests/test_local_model_paths.py is red on main @ 436053174: 11 failed, 18 passed, all with

E   AttributeError: type object 'DummyQModel' has no attribute 'require_load_tokenizer'

#4894 (Decision Transformer) made the loader read cls.require_load_tokenizer:

  • gptqmodel/models/loader.py:2056 and :2691 — if cls.require_load_tokenizer:
  • gptqmodel/models/base.py:847 — require_load_tokenizer: bool = True (the BaseQModel default)
  • gptqmodel/models/definitions/decision_transformer.py:33 — require_load_tokenizer = False

The nine DummyQModel doubles in this file mirror BaseQModel'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 on main and it hits every branch that touches the loader.

What Changed

  • tests/test_local_model_paths.py: each DummyQModel declares require_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

cd <worktree>
export CUDA_VISIBLE_DEVICES="" PYTHONPATH=<worktree> GPTQ_BYPASS_SAFETY_CHECKS=1 LOGBAR_ANIMATION=0
python -m pytest tests/test_local_model_paths.py -q
# before (origin/main 436053174): 11 failed, 18 passed
# after:                            29 passed in 6.90s

Also verified with tokenicer==0.0.19 first on PYTHONPATH (the version requirements.txt pins 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.

  • Unit tests executed and passed (this PR makes the existing red nodes green; the file itself is the regression test, so no new node is added).
  • The failure reproduces on unmodified 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

  • Reviewed this PR.
  • Matches existing project structure: the doubles already enumerate BaseQModel attributes, this adds the missing one.
  • No monkeypatching.
  • Minimal surface: 18 insertions (9 attributes + 9 one-line comments) in one test file.
  • Regression considered: the attribute value is the BaseQModel default, 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.

…#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.
@Qubitium
Qubitium merged commit 83f9180 into main Nov 17, 2026
6 checks passed
@Qubitium
Qubitium deleted the root/local-paths-doubles-4923 branch November 17, 2026 18:49
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[TEST] tests/test_local_model_paths.py red on main: the nine DummyQModel doubles never declared require_load_tokenizer (#4894 follow-up)

1 participant