Skip to content

chore(ds4rt): delete plumbing left without callers - #6660

Merged
Qubitium merged 1 commit into
mainfrom
refactor/ds4rt-x1-dead-plumbing
Dec 1, 2026
Merged

Qubitium merged 1 commit into
mainfrom
refactor/ds4rt-x1-dead-plumbing

Conversation

@Qubitium

@Qubitium Qubitium commented Dec 1, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Delete the ds4rt plumbing that no longer has a caller on current main: the DS4/GLM base-replay model hooks, the never-written distributed_quant_device read, and the retired EXL3Config.module_include allowlist. module_include stays accepted so existing quantize_config.json files still load; it warns once on load, quantization rejects it with a ValueError, and re-saving drops it. The items that still have live callers (the test-only safetensors-reference fixture, the #3585 shard-reuse probe, LazyTurtle) are left alone and listed below.

What Changed

  • Removed configure_base_replay_store / create_quantization_layer_output_writer from DeepSeekV4QModel, GlmMoeDsaQModel and Glm5NextQModel, and removed the generic model-hook dispatch in ForwardExecutor._output_collection. CalibrationConfig.spill_path (G2, feat(calibration): CalibrationConfig.spill_path streams layer inputs to disk for every processor #6656) is now the only output-collection path.
  • Removed GLM5's _prune_glm5_next_replay_frontier; it was reachable only through the deleted writer hook (and its dedicated test).
  • Removed the named_module.state["distributed_quant_device"] read in build_subset_plan; no production code ever wrote the key.
  • Retired EXL3Config.module_include: the field is still accepted for checkpoint compatibility and warns once, but EXL3Processor setup and clone_exllamav3_config_for_module (the DeepSeek V4.1 flash projection path) now reject it with a ValueError instead of silently quantizing every module. to_dict() no longer emits it. The replacement is dynamic negative rules.
  • Deleted tests that only exercised the deleted code: tests/test_stage_modules.py::test_forward_executor_run_single_streams_outputs_through_model_writer, ::test_forward_executor_run_single_skips_durable_output_batch, tests/test_deepseek_v4_support.py::test_deepseek_v4_configures_base_replay_store_with_resolved_path, tests/test_glm5_next_support.py::test_replay_frontier_prunes_only_older_exact_layer_directories, and tests/test_subset_plan.py::test_build_subset_plan_preserves_distributed_family_device_assignment. The two module_include allowlist tests were replaced by three tests: load/warn/re-save, quantize-time rejection, and the dynamic negative-rule equivalent.

Item-by-item audit (all checked on origin/main = f442095e2)

Item 0-caller evidence Result
offload_to_safetensors_reference git grep finds no definition in gptqmodel/; the only definition is the test fixture tests/offload_test_utils.py:68, called from 6 tests in tests/test_offload_files.py (:495,2291,2355,2389,2424,2496). kept: R5 already removed the production function. The remaining helper is an explicitly test-only fixture that exercises the live writer's legacy reference-index resolution (get_state_dict_for_save / _module_source_reference_index); deleting it would drop that coverage, not dead production code.
#3585 shard-reuse probe _existing_shard_matches is defined at gptqmodel/utils/model.py:6123 and called at :6341 inside streaming_state_dict_to_shards, which writer.py:2331,3088 and the DeepSeek V4.1 flash writer still call. kept: the final save still calls it, exactly the condition the task sets for leaving it.
LazyTurtle active-source staging git grep finds no class, method or configure_active_source_staging in gptqmodel/; only four historical docstrings in weight_loader/ mention the name (they describe what CheckpointSource replaced). nothing left to delete.
EXL3Config.module_include It was a serialized _OUTPUT_FIELDS entry, validated in __post_init__, used by module_is_included() and the processor filter. git grep found no production setter after the earlier ds4rt removals. retired with load compatibility and a quantize-time error (gptqmodel/quantization/config.py +17/−39, gptqmodel/looper/exllamav3_processor.py +13/−3; tests +67/−18). Old configs load and warn once; re-saving drops the key; quantization raises ValueError with the dynamic-negative-rule example. A test pins that the example rule excludes exactly the modules the old allowlist excluded.
DS4/GLM configure_base_replay_store / create_quantization_layer_output_writer Before this change the only definitions were the six model methods; the only callers were ForwardExecutor._output_collection (a getattr string lookup) and two tests/test_stage_modules.py tests that installed a fake. G2 #6656 replaced the path with CalibrationConfig.spill_path. An AST scan for the names as attributes / getattr strings / subscripts now returns 0 hits. deleted (deepseek_v4.py, glm_moe_dsa.py, glm5_next.py, forward_executor.py; 193 lines deleted, 1 added net of imports). The GLM5-only prune helper and its test went with it.
named_module.state["distributed_quant_device"] The only read was stage_subset.py:595; the only writer anywhere was tests/test_subset_plan.py:244 inside the dedicated test. AST scan for the string returns 0 hits. deleted (stage_subset.py read and the dedicated test; -56 lines).
ds4rt docs pages git grep of every deleted symbol in docs/ returns no hits. The 9 docs/exl3-*.md pages and docs/looper-causal-replay.md document EXL3/looper code that E1 has not deleted, so they are not pages that document X1-deleted code. kept; no link changes needed. tests/test_docs_contract_refs.py passes (267 passed).

Tests

CPU, python -P, clone first on PYTHONPATH, CUDA_VISIBLE_DEVICES= (the host has no usable NVIDIA driver):

# touched-module unit tests (includes the new deprecation test)
/root/venv/bin/python -P -m pytest -o addopts= -q -p no:cacheprovider -rs \
  tests/test_exllamav3.py tests/test_deepseek_v4_support.py tests/test_stage_modules.py \
  tests/test_glm5_next_support.py tests/test_glm_moe_dsa_support.py \
  tests/test_checkpoint_metadata_contracts.py
# 115 passed, 2 skipped (ROCm GPU required) — included in the 281-pass combined run

# map target list (offload / lazy-turtle / export / split-save)
/root/venv/bin/python -P -m pytest -o addopts= -q -p no:cacheprovider -rs \
  tests/test_offload_files.py tests/test_lazy_turtle_materialize_map.py \
  tests/test_lazy_turtle_conversion_mapping.py tests/test_config_only_export.py \
  tests/test_split_by_layer_save.py
# included in the 281-pass combined run (same skips)

# retirement behaviour and the other touched tests
/root/venv/bin/python -P -m pytest -o addopts= -q -p no:cacheprovider \
  tests/test_exllamav3.py::test_exllamav3_module_include_is_retired_and_ignored \
  tests/test_exllamav3.py::test_exllamav3_module_include_rejected_at_quantize_setup \
  tests/test_exllamav3.py::test_exllamav3_dynamic_negative_rule_replaces_module_include_allowlist \
  tests/test_quantize_config_offload_tempdir.py tests/test_subset_plan.py
# 19 passed

# docs contract (copy-runnable blocks + file:line/symbol citations)
/root/venv/bin/python -P -m pytest -o addopts= -q -p no:cacheprovider tests/test_docs_contract_refs.py
# 267 passed

# module-tree inventory
/root/venv/bin/python -P tests/module_tree/awq_fold_inventory.py --check
# changed: none

# formatting
bash format/check.sh   # with the venv's ruff 0.14.2
# All checks passed!

# Combined final run over the 13 files above on the rebased tree: 281 passed, 8 skipped.

E2 (the 486-file e2_files.txt list used by the previous wave), one pytest process per file, 32-way, 1200 s per file, base f442095e2 vs this branch (run before the final rebase onto 0127a0313; #6657 only touches AWQ fold code and its tests, none of the files here):

# same command for both trees:
bash <scratch>/run_e2.sh <tree> <out> <scratch>/e2_files.txt 32
python <scratch>/compare_e2.py <base-out> <branch-out>
  • E2 ran before the final quantize-time-guard amendment; the two new guard tests are covered by the targeted batch above. 486/486 files completed on both sides. Exit codes: base {0: 462, 1: 13, 5: 8, 124: 3} vs branch {0: 463, 1: 13, 5: 8, 124: 2}.
  • Test statuses: base 11,603 passed / 2,033 skipped / 22 failed / 7 errored; branch 11,600 passed / 2,033 skipped / 21 failed / 7 errored. The only status deltas are the six tests this PR deletes/replaces (five pass -> absent, one absent -> pass) and tests/test_checkpoint_quantization.py: it hit the 1200 s per-file cap on base under the 32-way load, then passed alone with a 1800 s cap (54 passed, 4 skipped in 915 s); the branch passed it in the E2 run (54 passed, 4 skipped in 1044 s).
  • No new failure or error on the branch. The pre-existing reds are identical on both sides: test_cohere_compass, test_deepseek_vl, test_deepseek_vl_v2, test_openvla, test_config_numeric_validation_5437, test_local_model_loading, test_local_model_paths, test_model, test_norm_teacher_loading, test_quantization_lifecycle_contracts, test_smolvlm_support, test_zdtaichu5_support (network/HF-cache/known config failures), plus tests/kernels/test_intel_cpu_xpu.py (network).
  • tests/models/test_solar_open.py and tests/models/test_solar_open2.py time out (exit 124) on both sides; unchanged.
  • tests/kernels/test_exllamav3_quantize_tiles.py is CUDA-gated and skipped on this host; its only change is removing the retired module_include kwarg.

No save/writer/offload production code changed, so the bytewise save A/B is not applicable; the shard-reuse and reference-offload code paths are untouched (kept, as shown above).

Measured Impact

Not applicable: dead-code deletion plus a fail-closed retirement. The only behaviour change is that a legacy EXL3Config(module_include=...) now loads with a warning but raises at quantize time instead of silently filtering modules; the new tests cover that transition.

Model Support / Module Plan

Not applicable: no new model, alias or definition, and awq_fold_inventory.py --check reports changed: none.

AWQ onboarding safety

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

Logic Flow Documentation

Not applicable: the change deletes unreachable branches rather than replacing a decision mechanism. The one retired decision (module_include) is documented in the Notes and covered by the three module_include tests in tests/test_exllamav3.py; no new Mermaid flow is warranted for deleting dead branches.

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, pack or fusion code changed.

Notes

  • Migration: an old quantize_config.json containing module_include still loads; EXL3Config.__post_init__ logs one warning and keeps the field so the quantize-time guard can reject it. to_dict() stops re-emitting it, so a re-save cleans the checkpoint. Quantizing with module_include raises: EXL3Config.module_include was retired; express the allowlist with dynamic negative rules, e.g. {'-:^(?!model\.layers\.\d+\.mlp\.experts\.).*': {}}. The test test_exllamav3_dynamic_negative_rule_replaces_module_include_allowlist verifies that rule against dynamic_get and resolve_module_config(...).excluded.
  • Kept on purpose: the test-only offload_to_safetensors_reference fixture, _existing_shard_matches (the final save still calls it), LazyTurtle (already gone; docstrings only), and the ds4rt docs pages that describe still-live E1 code.
  • Pre-existing, left alone: docs/safetensors-reference-offload.md still diagrams the offload_to_safetensors_reference function that R5 removed from production. That page also documents live reference-index/export-guard behaviour, so it is not an X1 deletion; fixing it belongs with the R5 docs cleanup.
  • Rebase: final head is based on 0127a0313 (fix(awq): keep a declared fold whose first reader captured nothing #6657). After the rebase the targeted suites were rerun (279 passed, 8 skipped), format/check.sh passed, and the docs/inventory checks were rerun; the E2 table above is from the pre-rebase base because fix(awq): keep a declared fold whose first reader captured nothing #6657 does not overlap this change.
  • No GPU was available on this host (/dev/nvidia* absent), so the CUDA-marked tests were skipped and no GPU A/B was run; the touched default paths are CPU-covered above.

🤖 Generated with Claude Code

Comment thread tests/test_exllamav3.py Resolved
Remove the ds4rt paths that no longer have a caller on main:

- Drop the DS4/GLM `configure_base_replay_store` and
  `create_quantization_layer_output_writer` model hooks and the generic
  `ForwardExecutor` hook dispatch. `CalibrationConfig.spill_path` (G2)
  is the only output-collection path now.
- Drop GLM5's `_prune_glm5_next_replay_frontier`, reachable only from the
  deleted hook.
- Drop the never-written `distributed_quant_device` state read in
  `build_subset_plan`.
- Retire `EXL3Config.module_include`: old checkpoints still load and
  warn once, but quantization now raises with a `dynamic` negative-rule
  example instead of silently quantizing every module; `to_dict()` stops
  emitting it.

The test-only `offload_to_safetensors_reference` fixture, the #3585
shard-reuse probe and LazyTurtle remain because they still have callers
or nothing is left in tree.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Qubitium
Qubitium force-pushed the refactor/ds4rt-x1-dead-plumbing branch from 0728943 to c08da01 Compare December 1, 2026 15:03
@Qubitium
Qubitium marked this pull request as ready for review December 1, 2026 17:39
@Qubitium
Qubitium merged commit e1996a3 into main Dec 1, 2026
6 checks passed
@Qubitium
Qubitium deleted the refactor/ds4rt-x1-dead-plumbing branch December 1, 2026 17:40
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