Repository navigation
Conversation
Extract the existing working fork feature for first maintainer feedback. Preserve carried code and tests; limit validation to lightweight structural checks. See the linked mechanism reference for actual API/call and failure paths.
75b2876 to
713ac84
Compare
Qubitium
left a comment
There was a problem hiding this comment.
Reviewed against current main.
The replay contract is coherent: prepare_dataset refuses concat/sort/batch mutations, _DeepSeekV4MTPPreparedDataset normalizes each replay batch lazily, _DeepSeekV4MTPInputProvider keeps a small LRU instead of expanding the corpus, and run_input_capture validates the required keys and rebuilds target_taps/projected_main from the stored width. The output writer only persists authoritative post-quantization block outputs and discards superseded capture frontiers.
Two things worth calling out explicitly, both now handled:
InputCache.__post_init__mirrorslayer_inputsintosrc_inputswithlist(...). Becauselayer_inputshere is_DeepSeekV4MTPInputView, that call would iterate the view and materialize the whole lazy corpus on construction — exactly what the cache is meant to avoid.build_quantization_input_cachenow passessrc_inputs=[]; MTP replay has no input-embedding stage that consumessrc_inputs, so nothing is lost.test_deepseek_v4_pre_quantize_keeps_packed_target_layer_lazyconstructed the harness withobject.__new__(DeepSeekV4QModel)but never callednn.Module.__init__. The assertion body passed, butmonkeypatchteardown then hitnn.Module.__delattr__and raisedAttributeError: ... has no attribute '_parameters'. Initializing the module fixes the teardown without changing what the test asserts.
Validation: ruff check clean on the touched modules; pytest tests/test_deepseek_v4_support.py tests/test_qwen4_exp_exl3_contracts.py reports 45 passed.
No other blocking issues found.
Summary
Carry the existing V4 floatx/router precision handling, explicit auxiliary traversal, causal target/MTP alignment, bounded prefix runtime, checkpoint mappings, route recovery, vision/native tensor retention, and integrated quantized MTP save behavior.
This is layer 23/36, extracted from an already-used fork for initial maintainer feedback. It depends on #3602. Review only this feature; the cross-fork Files changed view is cumulative because the PR targets upstream
main.Incremental change: 5 files, +5499/−4 lines, including carried tests and the mechanism reference. No merge is automatic. Review value and API shape first; substantial rework can follow that feedback.
Flow and existing-code boundary
flowchart TD S0["DeepSeekV4QModel"] M0_0["DeepSeekV4QModel.prepare_input_capture_layer"] M0_1["DeepSeekV4QModel.save_state_overlay"] M0_2["DeepSeekV4QModel.capture_first_layer_input_kwargs"] S1["DeepSeekV4MTPReplay"] M1_0["DeepSeekV4MTPReplay.__init__"] M1_1["DeepSeekV4MTPReplay.prepare_batch"] S2["DeepSeekV4MTPQuantizationModel"] M2_0["DeepSeekV4MTPQuantizationModel.prepare_input_capture_layer"] M2_1["DeepSeekV4MTPQuantizationModel.prepare_dataset"] E["IndexError, RuntimeError, TypeError, ValueError"] S0 -. "exposes" .-> M0_0 S0 -. "exposes" .-> M0_1 S0 -. "exposes" .-> M0_2 S0 -->|"raises on rejected input/state"| E S1 -. "exposes" .-> M1_0 S1 -. "exposes" .-> M1_1 S1 -->|"raises on rejected input/state"| E S2 -. "exposes" .-> M2_0 S2 -. "exposes" .-> M2_1 S2 -->|"calls where selected"| S1 S2 -->|"raises on rejected input/state"| E style E fill:#fee,stroke:#b22gptqmodel/models/definitions/deepseek_v4.py:9gptqmodel/models/definitions/deepseek_v4.py:1410:DeepSeekV4QModelgptqmodel/models/definitions/deepseek_v4.py:740:DeepSeekV4MTPReplaygptqmodel/models/definitions/deepseek_v4.py:2349:DeepSeekV4MTPQuantizationModelCommitted reference: docs/deepseek-v4-mtp-replay.md, linked from README. Class entry points/calls and rejected-state paths describe code present in this branch, rather than planned integrations.
Validation
Carried test files:
tests/test_deepseek_v4_support.py,tests/test_qwen4_exp_exl3_contracts.pyThis packaging pass checked Python parsing, whitespace, dependency order and balanced Mermaid blocks. The author reports successful prior use of these features. Per the requested resource limit and feedback-first scope, existing model quantization, GPU/ROCm tests, heavyweight CPU workloads and full model benchmarks were not rerun; no new performance or model-accuracy claim is made. Tests accompanying earlier stack layers retain their previously reported results.
Existing model support: upstream already supports this GLM/DeepSeek family. This proposal adds calibration/MTP/recovery capability; it does not add a competing MODEL_MAP registration. Native Transformers blocks and upstream model plans remain the integration basis.