Skip to content

chore(models): delete the test-only ds4rt per-model calibration adapters - #6408

Merged
Qubitium merged 1 commit into
mainfrom
refactor/ds4rt-drop-unreachable-adapters
Nov 29, 2026
Merged

Qubitium merged 1 commit into
mainfrom
refactor/ds4rt-drop-unreachable-adapters

Conversation

@Qubitium

Copy link
Copy Markdown
Collaborator

Summary

ds4rt is deprecated and is being refactored into method-agnostic features (maintainer decision). This is PR-D1 of that plan. It deletes the per-model calibration adapters that ds4rt added in #3606-#3616. None of them has a production caller: nothing in gptqmodel/ or scripts/ imports them, MODEL_MAP reaches none of them, and only their own doc pages and unit tests cite them. It is a pure deletion with no behavior change for any public API, model definition, quantize/pack/save/load path or checkpoint format.

Net: 49 files changed, 129 insertions(+), 5739 deletions(-). That breaks down as gptqmodel +8/-2,810, tests +115/-2,594 and docs +6/-335.

What Changed

  • Deleted 15 production modules, 2,801 lines, all in gptqmodel/utils/:
    • kimi_k3, kimi_k3_core_format, kimi_k3_core_stream, kimi_k31
    • glm5_core, glm5_mtp, glm5_flash_core, glm5_flash_mtp
    • step5_core
    • v41_capture, v41_checkpoint, v41_mixed_replay, v41_recovery, v41_routed_batch
    • exl3_hessian, whose only importer was kimi_k31
  • Deleted 9 dedicated test files:
    • test_glm5_core.py, test_glm5_core_cuda.py, test_glm5_flash_core.py, test_glm5_mtp.py
    • test_step5_core.py
    • test_kimi_k31.py, test_kimi_k3_core_stream.py
    • test_v41_routed_capture.py
    • test_exl3_hessian_accumulator.py
  • Kept, moved and trimmed tests of live code that lived in the deleted files:
    • test_kimi_k3_core_cuda.py → test_exl3_bitstream_oracle.py. It keeps the CPU clean-room trellis decoder oracle for ExllamaV3TorchLinear._unpack_indices / get_inner_weight_tensor.
    • test_kimi_k3_core_format.py → test_exllamav3_padded_output.py. It keeps the two ExllamaV3Linear 128-channel padded-output crop and logical-shape rejection tests.
  • Trimmed mixed tests (only the cases that exercised deleted modules were removed):
    • test_kimi_k3_support.py: dropped the utils fixture and its 9 KimiK3Source / decode_mxfp4 / situ / prepare_moe cases. The GPTQMODEL_KIMI_K3_UTILS env var, which exec'd an arbitrary file, goes with them. The registry, module-plan, fail-closed and latent-MoE oracle cases stay.
    • test_e8m0_default_dtype_5297.py, test_ldexp_cross_device_5263.py: dropped the kimi_k3.decode_mxfp4 cases. The live decode_e8m0_scale and EXL3 prescale cases stay.
    • test_v41_checkpoint_mapped_ple.py: dropped the v41_checkpoint / v41_routed_batch frontier cases. The MappedPLETable and V41DSparkInput cases stay.
  • Docs:
    • Deleted 9 pages: kimi-k3-native-source, kimi-core-calibration, kimi-k31-calibration, glm-core-calibration, glm-native-mtp, glm-flash-native-calibration, step5-native-calibration, v41-routed-calibration, v41-durable-frontiers.
    • Removed their links from docs/README.md and docs/proposed-feature-reference-pages.md.
    • Removed the two kimi_k3.py rows from docs/trust-remote-code-isolation.md.
    • supported-models.md and transformers-5-compat.md no longer mention the "bounded KimiK3Source runner".
  • Text-only edits in live code (definitions/kimi_k3.py, definitions/kimi_linear.py, models/auto.py): the docstring, comments and three NotImplementedError messages no longer point at the deleted runner. The exception types and the substrings that tests match (prefix_sum and block_residual, AttnRes) are unchanged.
  • Kept on purpose, for the follow-up PRs:
    • utils/ple_mmap.py is live: ports/deepseek_v41_flash/engram.py:12 and definitions/deepseek_v41.py:13 import it.
    • utils/v41_source.py, v41_replay.py, v41_inputs.py, v41_dspark.py, v41_native.py (793 lines). They belong to the ports/deepseek_v41 + definitions/deepseek_v41.py stack, which is approved for removal in its own PR. Deleting them here would break that stack's imports:
      • tests/test_deepseek_v41_local_port.py:31-32 imports V41ReplayBatch / V41Source.
      • V41Source.load_main_input, load_dspark_input and load_decoded_block lazily import v41_inputs, v41_dspark and v41_native.
      • test_v41_checkpoint_mapped_ple.py imports V41DSparkInput.
      • v41_native itself imports ports/deepseek_v41.
    • Their pages docs/v41-native-source.md and docs/v41-dspark-replay.md stay with them.
    • definitions/deepseek_v41.py, ports/deepseek_v41/ and the DSv4/GLM MTP calibration stack are untouched. None of the deleted modules is imported by any of them.

Tests

  • Unit tests have been executed and passed, or the reason they are not applicable is documented.
  • I added a new simple/fast unit test for this change, or documented why that is not applicable. No new mechanism replaces anything, so there is nothing new to assert. The structural A/B below shows that every remaining module imports identically and that MODEL_MAP is identical.

Environment: CPU only (CUDA_VISIBLE_DEVICES="", HF_HUB_OFFLINE=1), torch 2.15, transformers 5.23.0. python -P with each tree first on PYTHONPATH. gptqmodel.__file__ was printed for each run and resolves to the tree under test.

Zero remaining references (repo-wide git grep -nP, 0 matches):

git grep -nP '\b(kimi_k3_core_format|kimi_k3_core_stream|kimi_k31|glm5_core|glm5_mtp|glm5_flash_core|glm5_flash_mtp|step5_core|v41_capture|v41_mixed_replay|v41_recovery|v41_routed_batch)\b|(?<![\w])v41_checkpoint\.py|utils[./]v41_checkpoint|(?<![\w])exl3_hessian(?![\w])|utils[./]kimi_k3\b|utils import kimi_k3\b|KIMI_K3_UTILS|KimiK3Source|KimiK31Source|KimiK3EXL3Source|GlmBF16Source|GlmFlashBF16Source|Step5BF16Source|V41Capture|V41Recovery|V41RoutedBatch|BoundedHessianAccumulator|(kimi-k3-native-source|kimi-core-calibration|kimi-k31-calibration|glm-core-calibration|glm-native-mtp|glm-flash-native-calibration|step5-native-calibration|v41-routed-calibration|v41-durable-frontiers)\.md|bounded K3|bounded runner' -- .
# -> 0 matches
python -P -c 'import gptqmodel'   # OK, resolves to the branch tree

Structural A/B (main 6b25d2c vs branch). The script records MODEL_MAP (key → definition qualname, module_tree, loader) and then imports every gptqmodel.* module found by pkgutil.walk_packages:

MODEL_MAP identical: True 210 210
modules only on main: the 15 deleted modules (all imported OK on main)
modules only on branch: []
common modules: 1533   import outcome differs: []
(the same 13 common modules fail identically on both: mlx_* and bitblas_target_detector, because mlx/tvm are not installed)

Pytest A/B, per-node junit outcomes on main vs branch:

  1. Every CPU test file that imports something near the deleted modules, plus the docs contract test. Run at 6b25d2c vs this head, -n 4:

    # main
    pytest tests/test_glm5_core.py tests/test_glm5_core_cuda.py tests/test_glm5_flash_core.py tests/test_glm5_mtp.py tests/test_step5_core.py tests/test_kimi_k31.py tests/test_kimi_k3_core_cuda.py tests/test_kimi_k3_core_format.py tests/test_kimi_k3_core_stream.py tests/test_v41_routed_capture.py tests/test_exl3_hessian_accumulator.py tests/test_kimi_k3_support.py tests/test_e8m0_default_dtype_5297.py tests/test_ldexp_cross_device_5263.py tests/test_v41_checkpoint_mapped_ple.py tests/test_deepseek_v41_local_port.py tests/test_kimi_k3_local_port.py tests/test_model_port_policy.py tests/test_transformers_unpatched.py tests/test_exl3_router_candidates.py tests/test_exllamav3_torch_padding.py tests/test_docs_contract_refs.py
    # -> 1 failed, 721 passed, 112 skipped
    # branch (same list minus deleted files; renamed files under their new names)
    pytest tests/test_exl3_bitstream_oracle.py tests/test_exllamav3_padded_output.py tests/test_kimi_k3_support.py tests/test_e8m0_default_dtype_5297.py tests/test_ldexp_cross_device_5263.py tests/test_v41_checkpoint_mapped_ple.py tests/test_deepseek_v41_local_port.py tests/test_kimi_k3_local_port.py tests/test_model_port_policy.py tests/test_transformers_unpatched.py tests/test_exl3_router_candidates.py tests/test_exllamav3_torch_padding.py tests/test_docs_contract_refs.py
    # -> 1 failed, 506 passed, 85 skipped
    • Common nodes: 592 (506 passed, 85 skipped, 1 failed). 0 differing outcomes. Renamed nodes are mapped to their new file names.
    • Nodes only on main: 242 (215 passed, 27 skipped). All of them are cases of the deleted modules.
    • Nodes only on branch: none.
    • The tests/test_docs_contract_refs.py nodes all pass on both trees.
  2. The tests/module_tree suite plus tests/test_docs_contract_refs.py, -n 8. Run at b1fdd38 vs this change before the rebase. The rebase onto 6b25d2c pulled 4 commits that touch none of this PR's files.

    • main: 11 failed, 3648 passed, 813 skipped, 2 xfailed, 9 errors.
    • branch: identical counts.
    • Common nodes: 4,483. 0 differing outcomes, identical FAILED/ERROR list.

Failures present on both main and branch (not caused by this PR, left alone):

  • tests/test_transformers_unpatched.py::test_gptqmodel_leaves_third_party_libraries_unpatched: the GPTQ v1 fixture fails in load_hf_tokenizer.
  • tests/module_tree/test_deepseek_v41_flash.py: 8 failed and 9 errors, all TypeError: Unsupported DeepSeek V4.1 Flash load arguments: tokenizer.
  • tests/module_tree/test_registered_module_plans.py::...[gemma4] and [gemma4_text]: the registered plan changed.
  • tests/module_tree/test_inkling2_loop_plan.py::test_inkling2_loop_public_loader_uses_local_code_and_checkpoint_keys: the tiny tokenizer cannot encode text.

Skips and what they leave unverified:

  • These tests are deleted, so their skips on main no longer matter: the CUDA cases of test_glm5_core_cuda.py (10), test_glm5_mtp.py (6) and test_kimi_k3_core_cuda.py (6).
  • Still skipped on both trees, CPU-only host:
    • the CUDA parametrizations of test_e8m0_default_dtype_5297.py, test_ldexp_cross_device_5263.py and test_exllamav3_torch_padding.py
    • the two-GPU case in test_ldexp_cross_device_5263.py
    • test_kimi_k3_local_port.py (7): the pinned tokenizer asset is not cached
  • No GPU A/B was run: no quantize, pack, save or load path is touched.
bash format/check.sh   # ruff 0.14.2: All checks passed!

Measured Impact

Not applicable: unreachable code was deleted, and no runtime path changed.

Model Support / Module Plan

Not applicable: no MODEL_MAP entry, alias, module tree or fusion eligibility changes. MODEL_MAP is identical before and after (structural A/B above), and tests/module_tree gives identical per-node outcomes. The only definition edits are the KimiLinearQModel docstring and error-message strings.

Model test node IDs and results: tests/module_tree as above (identical outcomes on 4,483 common nodes).

AWQ onboarding safety

Not applicable: no definition structure, AWQ grouping, search, replay or fold change. KimiLinearQModel.awq_get_modules_for_scaling still raises NotImplementedError; only the message text changed.

Logic Flow Documentation

  • This change does not alter a major logic flow, or the required diagrams and docs page are included below.

Diagram summary: not applicable. Code with no caller is deleted and no decision mechanism is replaced. The one Mermaid node that named the deleted runner (docs/transformers-5-compat.md) now reads quantize() fails closed, which is what the code does.

Review Requirements

I or an AI agent (such as Codex or Claude) have:

  • 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 changes. The two preserved EXL3 tests run on CPU and pass unchanged.

Notes

  • Policy violations this deletion removes (AGENTS.md):
    • gptqmodel/utils/step5_core.py:136-170 loaded <reference_root>/families/step5/golden.py through importlib.util.spec_from_file_location + exec_module. It inserted that root at sys.path[0] permanently and imported shape_invariant.install(). None of this had a trust_remote_code or GPTQ_BYPASS_SAFETY_CHECKS gate (fix(security): gate checkpoint code imports on trust_remote_code (#3968) #3981 gated kimi_k3/kimi_k31 but missed this file).
    • gptqmodel/utils/glm5_flash_core.py:71-74 (install_bounded_kda) permanently replaced chunk_kimi_delta_attention on the vendored gptqmodel/models/ports/native/glm5_next/modeling_glm5_next.py module. That is a monkeypatch of a model module.
    • tests/test_kimi_k3_support.py:25 read GPTQMODEL_KIMI_K3_UTILS and exec'd the file it named.
  • Follow-ups (separate PRs, already approved):
    • Removing ports/deepseek_v41 + definitions/deepseek_v41.py should also delete utils/v41_{source,replay,inputs,dspark,native}.py, docs/v41-native-source.md, docs/v41-dspark-replay.md, tests/test_deepseek_v41_local_port.py and the V41DSparkInput case in tests/test_v41_checkpoint_mapped_ple.py.
    • Removing the DSv4/GLM MTP calibration stack is independent of this PR.
  • No compatibility shims: the deleted modules were never part of the public API, and nothing re-exports them.

🤖 Generated with Claude Code

ds4rt is deprecated and is being refactored into method-agnostic features.
The per-model calibration adapters it added (#3606-#3616) have no production
caller: nothing in gptqmodel/ or scripts/ imports them, MODEL_MAP reaches
none of them, and only their own doc pages and unit tests cite them.

Delete 14 adapter utils plus exl3_hessian.py (its only user was kimi_k31):
kimi_k3, kimi_k3_core_format, kimi_k3_core_stream, kimi_k31, glm5_core,
glm5_mtp, glm5_flash_core, glm5_flash_mtp, step5_core, v41_capture,
v41_checkpoint, v41_mixed_replay, v41_recovery and v41_routed_batch, with
their 9 dedicated test files, their 9 doc pages and the index links.

This also removes two policy violations that lived only in this code:
step5_core.py ran an external families/step5/golden.py through exec_module
with no trust_remote_code / GPTQ_BYPASS_SAFETY_CHECKS gate, and
glm5_flash_core.py replaced chunk_kimi_delta_attention on the vendored
glm5_next port module. The GPTQMODEL_KIMI_K3_UTILS env var in
test_kimi_k3_support.py, which exec'd an arbitrary file, goes too.

Kept:
- ple_mmap.py: used by the deepseek_v41_flash port and definitions/deepseek_v41.
- v41_source, v41_replay, v41_inputs, v41_dspark, v41_native: imported by
  tests/test_deepseek_v41_local_port.py, test_v41_checkpoint_mapped_ple.py
  and (v41_native) ports/deepseek_v41. They go with the separate
  ports/deepseek_v41 removal.
- Tests of live code that lived in deleted files move to
  test_exl3_bitstream_oracle.py (ExllamaV3TorchLinear bitstream decode) and
  test_exllamav3_padded_output.py (ExllamaV3Linear padded output crop).

The Kimi K3 definition, auto.py, kimi_linear.py and docs no longer point at
the deleted "bounded KimiK3Source runner"; the NotImplementedError types and
the substrings the tests match are unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Qubitium
Qubitium marked this pull request as ready for review November 29, 2026 14:25
@Qubitium
Qubitium merged commit 878f13a into main Nov 29, 2026
6 checks passed
@Qubitium
Qubitium deleted the refactor/ds4rt-drop-unreachable-adapters branch November 29, 2026 14:25
Qubitium pushed a commit that referenced this pull request Nov 29, 2026
Picks up main's commits since the previous merge base (6b25d2c):
#6395, #6399, #6407, #6408, #6409, #6410. Auto-merged cleanly; the
stable-ABI guards report no new offenders.
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