Skip to content

fix(gemma4): restore the unused full-length KV-store hook and absorb transformers 5.23 drift (#5325 section C) - #6282

Merged
Qubitium merged 1 commit into
mainfrom
fix/5325-tf523-issue
Nov 29, 2026
Merged

Qubitium merged 1 commit into
mainfrom
fix/5325-tf523-issue

Conversation

@Qubitium

@Qubitium Qubitium commented Nov 29, 2026 •

Copy link
Copy Markdown
Collaborator

Part of #5325 (section C — transformers 5.22 → 5.23 drift)

Rebased onto 356a5e03

This branch was moved from 89dbcf91 to 356a5e03 (current main at push
time) by applying the 89dbcf91..f3cb9982 diff with git apply -3 and
resolving the one gemma4.py conflict by hand.

Post-rebase verification on 356a5e03:

cd tests && CUDA_VISIBLE_DEVICES="" PYTHONPATH=<clone>:<clone>/tests \
  /root/venv/bin/python -m pytest test_gemma4_support.py \
  test_kv_cache_estimate_layer_kinds_4542.py test_qwen2_audio_support.py \
  module_tree/test_lfm3_native_leaf_tags_5325.py \
  test_awq_shared_kv_states_replay.py -q -p no:cacheprovider
# 52 passed, 1 warning

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 check passes on
all five changed files.

What this changes

Four of the five files address stale section-C expectations; one restores a real product hook.

  1. Gemma 4 unused full-length KV store (gptqmodel/models/definitions/gemma4.py, tests/test_gemma4_support.py)
    _disable_unused_gemma4_full_length_kv_store() is restored and called from both Gemma4TextQModel and Gemma4ForConditionalGenerationGPTQ hook starts. The test no longer pins the installed Transformers default: it asserts kv_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.
  2. Gemma3n measured cache / keys=None (tests/test_kv_cache_estimate_layer_kinds_4542.py)
    5.23 shared layers leave keys=None, and _measured called .numel() on it. Factored _allocated_cache_layers(), which skips keys is None, values is None and zero-element tensors, while still asserting cache_layers == estimate.growing_layers, shared_layers == 5 and byte equality.
  3. Qwen2-Audio meta .item() (tests/test_qwen2_audio_support.py)
    5.23's masking_utils._ignore_bidirectional_mask_sdpa calls .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 an isinstance assertion so a revert to AutoModelFor* is caught.
  4. LFM3 native leaves (tests/module_tree/test_lfm3_native_leaf_tags_5325.py, new)
    The g_proj:!:nosrc / conv:!:nosrc tags already exist on main (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 remote gate_proj alias so they cannot silently regress.

Red evidence

  • Gemma 4, 5.23 precondition: RED (r20 precondition): expected [False, False, True, True], got [False, False, False, False]
  • Gemma 4, hook absent: item1 pre-fix flags after hook: [False, False, True, True] (the hook did not disable the store)
  • Gemma3n: AttributeError: 'NoneType' object has no attribute 'numel'; and with a zero-element placeholder counted, item2 pre-fix filter count: 2 expected 1
  • Qwen2-Audio: RuntimeError: Tensor.item() cannot be called on meta tensors
  • LFM3, r20 tree: r20-tree undeclared: {'conv.conv': 13, 'self_attn.g_proj': 11}

Green evidence

cd tests && CUDA_VISIBLE_DEVICES="" PYTHONPATH=<clone>:<clone>/tests \
  /root/venv/bin/python -m pytest \
  test_gemma4_support.py test_kv_cache_estimate_layer_kinds_4542.py \
  test_qwen2_audio_support.py module_tree/test_lfm3_native_leaf_tags_5325.py \
  -q -p no:cacheprovider
41 passed, 1 warning in 12.95s

Also green on the merged tree: test_gemma4_unified_support.py and the module_tree registry-leaf coverage node.

/root/venv/bin/ruff check gptqmodel/models/definitions/gemma4.py \
  tests/test_gemma4_support.py tests/test_kv_cache_estimate_layer_kinds_4542.py \
  tests/test_qwen2_audio_support.py tests/module_tree/test_lfm3_native_leaf_tags_5325.py
All checks passed!

Unverified

  • Transformers 5.22 is not installable in this environment; the 5.22 shape is constructed explicitly in the test and its cache_utils semantics were checked against the downloaded 5.22.1 source.
  • CPU-only (CUDA_VISIBLE_DEVICES=""); no CUDA/ROCm run. No CUDA-side behaviour is changed.
  • tests/module_tree/ as a whole still needs timm (60 unrelated skips) and had 6 pre-existing test_nemotron_omni_local_port.py failures from a missing _mamba_ssm_cpu_unavailable_reason helper — both unrelated to this branch and tracked separately.

@Qubitium
Qubitium force-pushed the fix/5325-tf523-issue branch from bab582d to f3cb998 Compare November 29, 2026 04:53
@Qubitium Qubitium changed the title fix(lfm3): tag native gate/conv leaves and absorb transformers 5.23 drift (#5325) fix(gemma4): restore the unused full-length KV-store hook and absorb transformers 5.23 drift (#5325 section C) Nov 29, 2026
@Qubitium
Qubitium marked this pull request as ready for review November 29, 2026 08:07
…transformers 5.23 drift (#5325 section C)

Rebased onto 356a5e0, keeping #6317's KV-shared consumer replay hooks
(awq_module_replay_inputs / awq_get_modules_for_scaling) alongside this
PR's unused full-length KV-store guard.
@Qubitium
Qubitium force-pushed the fix/5325-tf523-issue branch from f3cb998 to d1bbc61 Compare November 29, 2026 08:10
@Qubitium
Qubitium merged commit 300de52 into main Nov 29, 2026
6 checks passed
@Qubitium
Qubitium deleted the fix/5325-tf523-issue branch November 29, 2026 08:16
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.

1 participant