Repository navigation
fix(load): default an absent require_load_tokenizer to the text path (#4941) - #4954
Merged
Merged
Conversation
…4941) #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' #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 #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 #4941. Refs #4923, #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
#4894 added
BaseQModel.require_load_tokenizerand madeModelLoaderread it ascls.require_load_tokenizerat two call sites (gptqmodel/models/loader.py:2070,:2710). OnlyBaseQModelsubclasses inherit the default, so every plain-class loader double — and any third-party definition that does not subclassBaseQModel— aborted the whole load:#4926 patched the nine doubles in
tests/test_local_model_paths.py. Two more files were still red onmain@f160a408d:so the GGUF parser-selection guard and the
.binconversion offload-path guard were not running.What Changed
gptqmodel/models/loader.py: new_requires_tokenizer(cls)returninggetattr(cls, "require_load_tokenizer", True), used at both call sites. An absent attribute means "text model" — the behaviour every definition had before feat(decision-transformer): tokenizer-optional load and tensor calibration inputs (#4755) #4894 — and an explicitFalseis the only way to skip the text path (Decision Transformer). This fixes both sites and every future double at once rather than one file per round.tests/test_loader_tokenizer_flag_4941.py(new): drives the realModelLoader.from_pretrainedwith the.binsource harness fromtest_lazy_turtle_conversion_cache.py.require_load_tokenizermust still load its tokenizer (the red case)require_load_tokenizer = Falsemust skip it,Truemust keep itTrue → True,False → False, absent →TrueNo change for any real definition: they all inherit
BaseQModel.require_load_tokenizer = True(or declareFalse), so the value read is identical to before.Tests
Red proof for the new file (behavioural tests only, helper-based rows removed so the run exercises the real path) on unmodified
origin/main:With the fix: 7 passed.
The sweep the issue asked for — every test file that mentions
ModelLoader:python -m pytest tests/test_backend_config_reuse_4446.py tests/test_lazy_turtle_conversion_cache.py \ tests/test_gguf_load_policy_env_removal.py tests/test_rocm_exl3_auto.py tests/test_local_model_paths.py \ tests/test_loader_tokenizer_flag_4941.py tests/test_moe_reload_meta_4400.py tests/test_kernel_config.py \ tests/test_loader_offload_staging_4385.py -q # 112 passedruff checkon both changed files: All checks passed.Model Support / Module Plan
Not applicable: no registry or definition change;
decision_transformer'srequire_load_tokenizer = Falsekeeps working and is asserted.Logic Flow Documentation
Not applicable: no new decision. The same two branches read the same value through one accessor; the accessor's default is documented in its docstring and pinned by the table test.
Review Requirements
_get_tokenizer_load_kwargs, no new API surface.loader.py+20/−2, one test file.BaseQModeldefaultTrue), and the explicit opt-out is covered by its own test.Kernel Accuracy Requirements
Not applicable: no kernel or numerics.
Closes #4941. Refs #4923, #4894.