Skip to content

feat(deepseek): carry V4.1 main-input and dSpark replay adapters - #3616

Merged
Qubitium merged 1 commit into
ModelCloud:mainfrom
tpurtell:upstream/36-v41-dspark-replay-20261108
Nov 9, 2026
Merged

Qubitium merged 1 commit into
ModelCloud:mainfrom
tpurtell:upstream/36-v41-dspark-replay-20261108

Conversation

@tpurtell

@tpurtell tpurtell commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Summary

Carry native text input preparation without decoder allocation, grouped teacher-forced draft anchors, shared main-prefix projection, dSpark continuation and explicit joint-ring state.

This is layer 36/36, extracted from an already-used fork for initial maintainer feedback. It depends on #3615. Review only this feature; the cross-fork Files changed view is cumulative because the PR targets upstream main.

Incremental change: 4 files, +180/−0 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["V41DSparkInput"]
    M0_0["V41DSparkInput.__init__"]
    M0_1["V41DSparkInput.forward"]
    M0_2["V41DSparkInput.prepare_joint"]
    S1["V41MainInput"]
    M1_0["V41MainInput.__init__"]
    M1_1["V41MainInput.prepare"]
    E["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
    style E fill:#fee,stroke:#b22
Loading
Before this extraction layer Carried implementation
API absent in the previous stack layer (path/symbol checked) gptqmodel/utils/v41_dspark.py:9: V41DSparkInput
API absent in the previous stack layer (path/symbol checked) gptqmodel/utils/v41_inputs.py:9: V41MainInput

Committed reference: docs/v41-dspark-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: No standalone test file existed in the fork for this helper; retained original implementation and documented the structural checks.

This 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.

V4.1 remains an explicit native calibration/replay API and is not added to MODEL_MAP. The source requires its native/reference implementation; upstream inventory documentation alone does not provide that runtime.

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.
@Qubitium
Qubitium force-pushed the upstream/36-v41-dspark-replay-20261108 branch from 2e2e3e4 to 0153028 Compare November 9, 2026 10:02

@Qubitium Qubitium left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed against current main.

The input adapters are bounded and keep tokenizer/sampling policy out of the source layer:

  • V41MainInput owns only the token embedding, small hash/rotary state, and mapped PLE handles. prepare requires nonempty integer [batch, sequence] ids, expands the embedding to the hc_mult stream shape, sets the stream-zero pre flag, builds main/compress rotary state and position ids, and copies hidden/rotary/PLE rows to owned CPU storage before returning the replay batch. close() closes every mapped table.
  • V41DSparkInput.forward projects the target-layer history through main_norm(main_proj(...)) and embeds the known token followed by noise; prepare_joint requires one source prompt, sorted distinct in-range anchors, and a shared target prefix, and returns a shared main_x prefix with one draft block per anchor. prepare slices future main features away before projection and substitutes the corpus next token for the main model's sampled token, leaving later draft positions as noise.
  • Both return V41ReplayBatch with owned CPU tensors, so downstream capture/checkpoint code never retains GPU state from these adapters.

Validation: no in-tree tests for this layer, so I exercised the shape contracts directly — prepare(position=3) yields hidden [1,4,2,8] and main_x [1,4,8]; prepare_joint(positions=[2,4]) yields hidden [2,4,2,8] with the shared main_x [1,5,8]. Modules import cleanly; cleanup was one dict(...) literal.

No blocking issues found.

@Qubitium
Qubitium marked this pull request as ready for review November 9, 2026 10:02
@Qubitium
Qubitium merged commit 275901a into ModelCloud:main Nov 9, 2026
Qubitium added a commit that referenced this pull request Nov 29, 2026
…ers (#6408)

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]>
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.

2 participants