Skip to content

test(docs): anchor the four drifting base.py citations by symbol (#4967) - #4971

Merged
Qubitium merged 1 commit into
mainfrom
root/docs-contract-refs-4967
Nov 17, 2026
Merged

Qubitium merged 1 commit into
mainfrom
root/docs-contract-refs-4967

Conversation

@Qubitium

@Qubitium Qubitium commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

tests/test_docs_contract_refs.py is red on main @ c52ae996d again: four citations into gptqmodel/models/base.py are 114 lines out of the 8-line window, because base.py keeps growing under them (#4894, #4906, #4912, #4930):

E  docs/awq-scale-folding.md cites `_select_prev_op` at gptqmodel/models/base.py:5489, but it is defined at [5667]
E  docs/calibration-replay.md cites `capture_layer_type_replay_kwargs` at gptqmodel/models/base.py:4022, but it is defined at [4200]
E  docs/calibration-replay.md cites `_build_layer_type_position_embeddings` at gptqmodel/models/base.py:4005, but it is defined at [4183]
E  docs/fp8-scale-semantics.md cites `_decoder_fp8_scale_semantics` at gptqmodel/models/base.py:4752, but it is defined at [4930]
4 failed, 16 passed

Drift of def _select_prev_op: 5490 (#4852) → 5503 (#4894) → 5530 (#4906) → 5558 (#4912) → 5603 (#4930) → 5667 (current main, after #4965). Re-anchoring the numbers would rot again at the next base.py change.

What Changed

  • tests/test_docs_contract_refs.py: the citation table now accepts a symbol-anchored form. cited is either a line number (unchanged behaviour: path.py:N plus the 8-line window) or SYMBOL_CITATION, where the doc must cite path.py::symbol. The symbol is still resolved in the source, so a renamed or removed symbol still fails — only the line number stops being part of the contract. The line form stays for files that are not growing.
  • The four drifting docs now use gptqmodel/models/base.py::<symbol>:
    • docs/awq-scale-folding.md — _select_prev_op
    • docs/calibration-replay.md — capture_layer_type_replay_kwargs, _build_layer_type_position_embeddings
    • docs/fp8-scale-semantics.md — _decoder_fp8_scale_semantics
  • Also re-anchored the stale :5531 on the adjacent :postnorm row (it pointed into _select_prev_op's new body) to base.py::_select_prev_op and POST_NORM_FLAG at base.py:560.
  • .github/workflows/awq_cpu.yml: the test now runs pre-merge as the first file of the CPU unit suite, and docs/** plus tests/test_docs_contract_refs.py are added to the workflow's path filter. That is the issue's "run this test in the pre-merge CPU suite" request: any gptqmodel/models/**, gptqmodel/quantization/** or docs/** change now runs it. (It is the repository's only CPU pytest job; the test is 6 s.)

Tests

cd <worktree>
export CUDA_VISIBLE_DEVICES="" PYTHONPATH=<worktree> GPTQ_BYPASS_SAFETY_CHECKS=1 LOGBAR_ANIMATION=0
python -m pytest tests/test_docs_contract_refs.py -q
# origin/main c52ae996d:            4 failed, 16 passed
# with this PR:                     20 passed in 6.34s

Red proof that the new form is enforced, not merely satisfied — the new test copied onto unmodified origin/main (docs still citing line numbers):

E  docs/awq-scale-folding.md no longer cites base.py::_select_prev_op
E  docs/calibration-replay.md no longer cites base.py::capture_layer_type_replay_kwargs
E  docs/calibration-replay.md no longer cites base.py::_build_layer_type_position_embeddings
E  docs/fp8-scale-semantics.md no longer cites base.py::_decoder_fp8_scale_semantics
4 failed, 16 passed

So a doc that loses the citation, or a source that loses the symbol, still fails. ruff check tests/test_docs_contract_refs.py: All checks passed.

  • Unit tests executed and passed (red on unmodified main, green here).
  • The existing guard is the regression test; its red proof is above.

Model Support / Module Plan

Not applicable: docs and a test guard.

Logic Flow Documentation

Not applicable: no product control flow. The guard's two citation forms are documented in the table's header comment.

Review Requirements

  • Reviewed this PR.
  • Matches existing project structure: one sentinel in the existing table, no new test file.
  • No monkeypatching.
  • Minimal surface: 25 insertions / 12 deletions across 5 files.
  • Regression considered: every other citation keeps the line-number form and still passes (16 of 20 nodes were already green and stay green).

Kernel Accuracy Requirements

Not applicable: no kernel or numerics.

Closes #4967.

`tests/test_docs_contract_refs.py` was red on main again: four citations into
`gptqmodel/models/base.py` were 114 lines out of the 8-line window, because
base.py keeps growing under them (#4894, #4906, #4912, #4930):

  docs/awq-scale-folding.md        _select_prev_op                        5489 -> 5667
  docs/calibration-replay.md       capture_layer_type_replay_kwargs       4022 -> 4200
  docs/calibration-replay.md       _build_layer_type_position_embeddings  4005 -> 4183
  docs/fp8-scale-semantics.md      _decoder_fp8_scale_semantics           4752 -> 4930

Re-anchoring the numbers would rot again at the next base.py change, so the
guard now accepts a symbol-anchored citation (`path.py::symbol`) and those four
docs use it. The test still resolves the symbol in the source, so a renamed or
removed symbol fails; only the line number stops being part of the contract.
The line-number form stays for files that are not growing.

Also re-anchored the stale `:5531` on the adjacent `:postnorm` row to
`base.py::_select_prev_op` and `POST_NORM_FLAG` (base.py:560).

And the test now runs pre-merge: it is the first file in the AWQ CPU `unit`
suite, and `docs/**` plus the test itself are added to that workflow's path
filter, so a base.py or docs change runs it.

On unmodified main: 4 failed, 16 passed. With the fix: 20 passed. Copying only
the new test onto main (docs still citing line numbers) also fails all four,
which proves the new form is actually enforced.

Closes #4967.
@Qubitium
Qubitium merged commit 5a131c6 into main Nov 17, 2026
9 checks passed
@Qubitium
Qubitium deleted the root/docs-contract-refs-4967 branch November 17, 2026 20:12
Qubitium added a commit that referenced this pull request Nov 17, 2026
* `tests/test_docs_contract_refs.py` + the four docs it pins — took main's
  #4971 symbol anchors (`path::symbol`) over this branch's line-number pins,
  which is what that guard was changed to for exactly this file. Also converted
  the one remaining `_quantize_summary_counts` pin to the symbol form, because
  this branch's `base.py` moved it from 347 to 356.
* `gptqmodel/utils/model.py` — main refactored the local `mapped_device` into
  the shared `_device_map_target` helper (#4915/#4964). Took that, and added the
  `include_disk=` parameter back to it so this branch's intentional-disk-offload
  restore path can still tell a disk offload from a never-materialized slot.

Verification: `tests/test_docs_contract_refs.py`,
`test_cpu_offload_tied_both_copies_4943.py`,
`test_cpu_offload_device_map_tied_head_4866.py`,
`test_load_strict_kwargs_4945.py`, `test_loader_offload_staging_4385.py`,
`test_hf_gptqmodel_load_bridge.py` -> 84 passed. `ruff check gptqmodel tests`
clean.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant