Skip to content

[Feat][DSpark] Add single-card DeepSeek V4.1 draft execution and weight-reuse recipe - #2

Merged
wenxuewuhd merged 6 commits into
wenxuewuhd:dsv41-moe-offload-prfrom
Pan-Boyi:codex/dsv41-singlecard-dspark-hbm
Nov 8, 2026
Merged

wenxuewuhd merged 6 commits into
wenxuewuhd:dsv41-moe-offload-prfrom
Pan-Boyi:codex/dsv41-singlecard-dspark-hbm

Conversation

@Pan-Boyi

@Pan-Boyi Pan-Boyi commented Oct 21, 2026 •

Copy link
Copy Markdown

What this PR does / why we need it?

Enable experimental single-card DeepSeek-V4.1-Flash DSpark with kt CPU expert offload. A 50-line Ascend adapter reuses the upstream forward and checkpoint loader; the three draft layers keep all 128 experts in HBM while the target retains its 100 resident slots and CPU offload.

The remaining shared-path changes select the V4.1 drafter, accept its hidden-state interface, keep target/draft MoE dispatch state separate, and provide backend-correct KV indices with persistent metadata buffers. SparseFlashMla consumes logical positions; the legacy backend retains physical slots. Small CANN initialization compatibility fixes remain in their separate commit.

The PR contains +232/-69 runtime lines, +764/-24 test lines, and +105/-5 documentation lines. The latest update condenses the two documents by 113 lines without changing runtime or test sources.

Base: dsv41-moe-offload-pr at 59ce1e18a4f93c20a872e4450bd14e891c556cb7. vLLM: a9686bc6e6809a49cb3e3c592a337d0721c3619f; CANN 9.2.0-beta.2.

Does this PR introduce any user-facing change?

Yes. method="dspark" uses the target checkpoint's mtp.* weights without a separate checkpoint, adding about 7.39 GiB of draft HBM. The recipe covers single-card text generation, concurrency one, maximum model length 8192, bf16 KV, target graphs [1,2,3,6], and eager draft execution. It retains the default asynchronous scheduler and stream-prefill threshold of 512 tokens. Multi-card and multimodal end-to-end generation remain unverified.

CPU expert weight reuse is an optional separate kt-kernel change. Rebuild it and select its installation through KT_SITE; the existing kernel is sufficient for functional DSpark. Setup and version-specific limits are in examples/kt_moe_offload/README.md and dspark_validation.md.

How was this patch tested?

  • Current runtime revision, prior checks: 59 isolated CPU tests passed using real PyTorch; six model-index-gated tests skipped when the checkpoint index was absent. The harness stubs vLLM/hardware imports. Coverage includes drafter binding/registration, KV insertion, logical/physical indices and persistent buffers, proposer inputs, and expert-placement boundaries.
  • Historical runtime only: 8147c5f passed 280 targeted unit tests, one native A5 shuffled-page attention regression with the incorrect-index negative control, and five generation smoke checks. These results do not validate the simplified adapter revision. Fresh full vLLM/native NPU validation remains pending, so the PR remains Draft. No stable whole-model speedup or complete quality score is claimed.
  • This documentation update: markdownlint, git diff --check, and static K2/K5 launch-argument/JSON checks passed. Runtime/tests are unchanged; no new model or NPU run was performed.
  • Required bash format.sh ci was rerun in an isolated copy. It still fails existing repository lint, formatting, spelling, logger/import checks and missing wget/gitleaks/shellcheck; full CI is not claimed green.

pan-boyi added 3 commits October 21, 2026 11:30
Preserve adjacent RoPE pairs through stack/flatten. Validate and expand MXFP8 scale bytes on CPU during weight loading to avoid the RepeatInterleave and ReduceAny timeouts observed with CANN 9.2.0-beta.2 on Ascend950.

Signed-off-by: pan-boyi <panboyi@huawei.com>
Reuse the upstream V4.1 drafter with Ascend mHC and context-KV operations. Keep all draft experts in HBM, isolate per-layer MoE dispatch, and publish stable deferred attention lengths for real requests.

Add regression tests and an experimental deployment recipe. Document the five generation smoke checks and the unresolved 2/1270 draft acceptance result; no acceleration claim is made.

Signed-off-by: pan-boyi <panboyi@huawei.com>
SparseFlashMla applies the block table to request-relative indices. Passing physical slots mapped draft KV twice and caused near-zero acceptance. Select the index space by backend and preserve legacy shared-KV behavior.

Add shuffled-page unit coverage and an A5 numerical regression with a physical-index negative control. Record the fresh five-case validation: 142 of 600 proposed tokens accepted, with all five positions active.

Signed-off-by: pan-boyi <panboyi@huawei.com>
Link the companion kt-kernel PR and distinguish its target-branch port from the historically validated native build. Update the launch recipe to retain graph sizes three and six and record correctness, acceptance, throughput, and output-equivalence limits.

Signed-off-by: pan-boyi <panboyi@huawei.com>
@Pan-Boyi Pan-Boyi changed the title [Feat][DSpark] Add experimental single-card DeepSeek V4.1 draft execution [Feat][DSpark] Add single-card DeepSeek V4.1 draft execution and weight-reuse recipe Nov 2, 2026
pan-boyi added 2 commits November 2, 2026 18:33
Bind the three upstream hardware calls only during drafter construction and reuse the target RoPE/scatter helpers without a dummy query. Remove redundant binding inspection and post-load expert scanning, restore the base target patch dispatcher, and use the proposer hidden-state interface.

Retain logical KV indices, persistent valid lengths and per-layer MoE state. Add CPU equivalence/interface regressions and distinguish isolated checks from pending native validation.

Signed-off-by: pan-boyi <panboyi@huawei.com>
Keep the launch settings and current validation limits, distinguish historical native results from the simplified adapter, and link the separate CPU kernel instead of repeating its benchmark history. Runtime and test sources are unchanged.

Signed-off-by: pan-boyi <panboyi@huawei.com>
@Pan-Boyi
Pan-Boyi marked this pull request as ready for review November 6, 2026 08:32
@wenxuewuhd
wenxuewuhd merged commit 92d70ad into wenxuewuhd:dsv41-moe-offload-pr Nov 8, 2026
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