Repository navigation
fix(gemma4): restore the unused full-length KV-store hook and absorb transformers 5.23 drift (#5325 section C) - #6282
Merged
Merged
Conversation
Qubitium
force-pushed
the
fix/5325-tf523-issue
branch
from
November 29, 2026 04:53
bab582d to
f3cb998
Compare
Qubitium
marked this pull request as ready for review
November 29, 2026 08:07
Qubitium
force-pushed
the
fix/5325-tf523-issue
branch
from
November 29, 2026 08:10
f3cb998 to
d1bbc61
Compare
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.
Part of #5325 (section C — transformers 5.22 → 5.23 drift)
Rebased onto
356a5e03This branch was moved from
89dbcf91to356a5e03(currentmainat pushtime) by applying the
89dbcf91..f3cb9982diff withgit apply -3andresolving the one
gemma4.pyconflict by hand.gptqmodel/models/definitions/gemma4.py. fix(awq): supply KV-shared state for Gemma consumer replay #6317 (merged afterthis branch was opened) added the KV-shared consumer replay hooks
(
_gemma4_awq_replay_inputs,awq_module_replay_inputs,awq_get_modules_for_scaling, backed by_kv_shared_replay.py). Both sidesare kept: fix(awq): supply KV-shared state for Gemma consumer replay #6317's wiring is untouched and this branch's
_disable_unused_gemma4_full_length_kv_store()plus its twopre_quantize_generate_hook_start()calls are added alongside it.Post-rebase verification on
356a5e03:On that same base before the rebase, the same set minus the new LFM3 file was
48 passed; the LFM3 file did not exist (0 collected).
ruff checkpasses onall five changed files.
What this changes
Four of the five files address stale section-C expectations; one restores a real product hook.
gptqmodel/models/definitions/gemma4.py,tests/test_gemma4_support.py)_disable_unused_gemma4_full_length_kv_store()is restored and called from bothGemma4TextQModelandGemma4ForConditionalGenerationGPTQhook starts. The test no longer pins the installed Transformers default: it assertskv_sharing_modes, explicitly constructs the 5.22 shape ([False, False, True, True]), runs the hook, and asserts the flags go to[False, False, False, False]— so it exercises the product behaviour on both 5.22 and 5.23. The producer variant asserts["store", "store", "reuse", "reuse"]/[True, True, False, False]is preserved.keys=None(tests/test_kv_cache_estimate_layer_kinds_4542.py)5.23 shared layers leave
keys=None, and_measuredcalled.numel()on it. Factored_allocated_cache_layers(), which skipskeys is None,values is Noneand zero-element tensors, while still assertingcache_layers == estimate.growing_layers,shared_layers == 5and byte equality..item()(tests/test_qwen2_audio_support.py)5.23's
masking_utils._ignore_bidirectional_mask_sdpacalls.item()on a meta tensor. The product already avoids that path by using the vendored native class (landed by Port every supported model onto the Transformers 5.23 ABI; never patch Transformers #4620); the test now pins the vendored class with anisinstanceassertion so a revert toAutoModelFor*is caught.tests/module_tree/test_lfm3_native_leaf_tags_5325.py, new)The
g_proj:!:nosrc/conv:!:nosrctags already exist onmain(added by fix(awq): add the bias to the FP32 GEMV reduction and keep split-K partials wide (#5736) #5947/Port every supported model onto the Transformers 5.23 ABI; never patch Transformers #4620), so no definition change is needed. The new test pins both native leaves and the remotegate_projalias so they cannot silently regress.Red evidence
RED (r20 precondition): expected [False, False, True, True], got [False, False, False, False]item1 pre-fix flags after hook: [False, False, True, True](the hook did not disable the store)AttributeError: 'NoneType' object has no attribute 'numel'; and with a zero-element placeholder counted,item2 pre-fix filter count: 2 expected 1RuntimeError: Tensor.item() cannot be called on meta tensorsr20-tree undeclared: {'conv.conv': 13, 'self_attn.g_proj': 11}Green evidence
Also green on the merged tree:
test_gemma4_unified_support.pyand themodule_treeregistry-leaf coverage node.Unverified
cache_utilssemantics were checked against the downloaded 5.22.1 source.CUDA_VISIBLE_DEVICES=""); no CUDA/ROCm run. No CUDA-side behaviour is changed.tests/module_tree/as a whole still needstimm(60 unrelated skips) and had 6 pre-existingtest_nemotron_omni_local_port.pyfailures from a missing_mamba_ssm_cpu_unavailable_reasonhelper — both unrelated to this branch and tracked separately.