Skip to content

test(generation): bind the KV-quant hook on the compile-policy harness - #6670

Merged
Qubitium merged 1 commit into
mainfrom
fix/generate-kv-hook-harness
Dec 1, 2026
Merged

Qubitium merged 1 commit into
mainfrom
fix/generate-kv-hook-harness

Conversation

@Qubitium

@Qubitium Qubitium commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

Summary

The #4669 generation compile-policy tests are red on origin/main: five generate() tests raise AttributeError: '_Harness' object has no attribute '_prepare_kv_quant_cache'.

Root cause is the test double, not the product. #6603 (feat(turboquant): add runtime softmax-attention KV-cache quantization) added BaseQModel._prepare_kv_quant_cache and generate() now calls it unconditionally on every input branch. Every real wrapper inherits the method; the _Harness double binds only _kernels_support_compile, _generation_compile_kwargs and generate, so it never reaches its assertions.

What Changed

tests/test_generation_compile_policy_4669.py (+1): bind the real hook on _Harness:

_prepare_kv_quant_cache = BaseQModel._prepare_kv_quant_cache

The harness has no kv_quant attribute, so the real method returns the kwargs unchanged — exactly the pre-#6603 behavior these policy tests assert. No product code change.

Tests

  • Unit tests have been executed and passed.
  • A new test is not applicable: this repairs the existing harness; the five tests are the regression.
export HF_HOME=/root/.cache/huggingface HF_HUB_OFFLINE=1 CUDA_VISIBLE_DEVICES=""

python -P -m pytest -p no:cacheprovider -q -rs --timeout 900 tests/test_generation_compile_policy_4669.py
#   origin/main 0127a0313: 5 failed, 12 passed
#     AttributeError: '_Harness' object has no attribute '_prepare_kv_quant_cache'
#     (test_generate_keeps_an_explicit_opt_in, ..._callers_kwargs_on_the_string_branch,
#      ..._tensor_branch, test_generate_leaves_a_dense_model_alone,
#      test_generate_passes_the_opt_out_to_the_model)
#   branch 41423019b:       17 passed

bash format/check.sh   # All checks passed! (ruff 0.14.2)

Measured Impact

Not applicable: test-only change.

Model Support / Module Plan

Not applicable: no MODEL_MAP, module-tree, plan or definition change.

AWQ onboarding safety

Not applicable: no AWQ grouping, search, replay or fold change.

Logic Flow Documentation

Not applicable: the harness now mirrors the real BaseQModel.generate() call chain; no shipped control flow changes.

Review Requirements

  • Reviewed this PR.
  • Checked that the code matches existing project structure, APIs, and conventions.
  • Avoided unnecessary monkeypatching and used the project's normal extension points where possible.
  • Minimized and compacted the impacted code surface.
  • Considered and eliminated potential regressions.

Kernel Accuracy Requirements

Not applicable: no kernel, dispatch or fusion change.

Notes

  • The real method is bound rather than stubbed so the tests keep exercising the production hook (which is a no-op without kv_quant).
  • tests/test_optimize_generate_cpu_offload_5099.py only references BaseQModel.generate in its docstring and does not bind it.

🤖 Generated with Claude Code

#6603 added BaseQModel._prepare_kv_quant_cache and generate() now calls it
unconditionally. The _Harness double in the #4669 policy tests binds only
the three policy methods, so the five generate() tests raised
AttributeError before reaching their assertions.

Bind the real method (the harness has no kv_quant, so it returns the
kwargs unchanged) instead of duplicating a stub.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Qubitium
Qubitium marked this pull request as ready for review December 1, 2026 17:44
@Qubitium
Qubitium merged commit 8e7ed20 into main Dec 1, 2026
6 checks passed
@Qubitium
Qubitium deleted the fix/generate-kv-hook-harness branch December 1, 2026 17:44
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