Repository navigation
test(docs): anchor the four drifting base.py citations by symbol (#4967) - #4971
Merged
Merged
Conversation
`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
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.
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
tests/test_docs_contract_refs.pyis red onmain@c52ae996dagain: four citations intogptqmodel/models/base.pyare 114 lines out of the 8-line window, becausebase.pykeeps growing under them (#4894, #4906, #4912, #4930):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 nextbase.pychange.What Changed
tests/test_docs_contract_refs.py: the citation table now accepts a symbol-anchored form.citedis either a line number (unchanged behaviour:path.py:Nplus the 8-line window) orSYMBOL_CITATION, where the doc must citepath.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.gptqmodel/models/base.py::<symbol>:docs/awq-scale-folding.md—_select_prev_opdocs/calibration-replay.md—capture_layer_type_replay_kwargs,_build_layer_type_position_embeddingsdocs/fp8-scale-semantics.md—_decoder_fp8_scale_semantics:5531on the adjacent:postnormrow (it pointed into_select_prev_op's new body) tobase.py::_select_prev_opandPOST_NORM_FLAGatbase.py:560..github/workflows/awq_cpu.yml: the test now runs pre-merge as the first file of the CPUunitsuite, anddocs/**plustests/test_docs_contract_refs.pyare added to the workflow's path filter. That is the issue's "run this test in the pre-merge CPU suite" request: anygptqmodel/models/**,gptqmodel/quantization/**ordocs/**change now runs it. (It is the repository's only CPU pytest job; the test is 6 s.)Tests
Red proof that the new form is enforced, not merely satisfied — the new test copied onto unmodified
origin/main(docs still citing line numbers):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.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
Kernel Accuracy Requirements
Not applicable: no kernel or numerics.
Closes #4967.