Skip to content

[NPU] Add DeepSeek-V4.1 flash AFD role split - #534

Draft
wangyao-i wants to merge 2 commits into
vllm-project:mainfrom
wangyao-i:feat/npu-deepseek-v41-afd
Draft

wangyao-i wants to merge 2 commits into
vllm-project:mainfrom
wangyao-i:feat/npu-deepseek-v41-afd

Conversation

@wangyao-i

@wangyao-i wangyao-i commented Nov 4, 2026 •

Copy link
Copy Markdown

Purpose

Add an Ascend NPU AFD role split for DeepSeek-V4.1 Flash (DeepseekV41ForCausalLM) on pinned vLLM 5df63a7 (0.32.0) and vLLM-Ascend bd42eea0.

Current validated candidate: 42a893ec46454d398388fb13e5b9add125f3494d, rebased onto main 127d8ec.

Scope and implementation

  • Attention retains the native DSA/HC/Engram decoder forward, candidate buffers and shared attention state. Its MoE slot becomes an AFD remote proxy; async CAM keeps routing and shared experts on Attention.
  • FFN constructs native DeepseekV41MoE and exposes routed-expert weights through get_async_cam_layered_weights() to the async runner. Synchronous gate-on-FFN execution retains compute_ffn_output(); the obsolete legacy gate-on-Attention helper is removed.
  • Engram tables stay on Attention. FFN declares has_engram=False and excludes Engram checkpoint tensors. Decoder replay is disabled on Attention.
  • Weight classification accepts an optional model. prefix before excluding vision/aligner/image/MTP tensors; original names passed to the native loader remain unchanged.
  • Register the NPU-only AFD architecture and reject non-NPU model-config resolution.
  • Reuse V4 routing, CAM exchange, shared-expert layout and expert-weight extraction, with the V4.1 already_sequence_parallel forward argument.

Test plan and results

Local checks

  • Focused model/registration tests plus async layered/runtime selection: 99 passed, 1 skipped (vLLM unavailable locally).
  • Ruff check / format check: all seven changed Python files pass.
  • Role-filter coverage is now at tests/unit/model_executor/models/npu/test_deepseek_v41.py. It reads real production constants rather than duplicating them, covers six prefixed non-text regressions, preserves original loader names, and checks rejection of legacy async FFN execution.
  • Architecture rewrite/NPU-only guard coverage is in tests/unit/model_executor/models/test_model_utils.py; package tests exercise the external registration seam.
  • An earlier broader Windows run had an unrelated source-distribution manifest test failure; this is not a claim that the full local unit suite passes.

Ascend server validation — reported for clean head 42a893e

Server validation record, sections 10.4–10.6.

Item Reported configuration/result
Runtime vLLM source build 0.32.0+empty at 5df63a7; Ascend bd42eea0; torch_npu 2.10.0.post7
Hardware / weights A3, real DeepSeek-V4.1-Flash W8A8 checkpoint
Topology Attention 1 die, FFN 12 dies (DP12); async CAM, eager
Unit tests Server report states the full tests/unit suite passed; numeric totals are not provided
Startup / generation Both roles started; temperature-0 smoke returned correct answers for 1+1 and 2+2
Weight classification 143,322 checkpoint names across five ownership configurations: no unclassified-path exceptions

The report identifies a clean checkout without the earlier server-local prefix patch. Exact current executor selection and per-run raw artifacts have not been independently inspected here; the old non-layered launch settings in section 9 are historical.

Reported benchmark values (vllm bench serve, OpenAI chat, random inputs, --ignore-eos, concurrency 4):

Input/output tokens Requests succeeded/failed Output tok/s Mean TPOT Median TTFT
256 / 64 32 / 0 38.14 90.79 ms 366.70 ms
512 / 128 32 / 0 41.24 91.59 ms 536.79 ms

These values are reproduced from the server report. There is no native baseline or repeated-run statistical comparison, so no speedup or performance-regression conclusion is claimed.

GSM8K — bounded server evaluation

  • 194/200 correct (97.00%), concurrency 4, temperature 0, max_tokens=3072.
  • Uses a custom stdlib evaluator on GSM8K test data, with a step-by-step prompt and numeric answer extraction. This is not an official lm-eval-harness/GSM8K-7 result; evaluator equivalence has not been established.
  • The 1,319-question evaluation was interrupted for resource sharing and remains incomplete.
  • No matched native-versus-AFD accuracy baseline was supplied, so individual answer errors are not attributed to or ruled out as AFD effects.

Restrictions and remaining validation

Construction rejects non-NPU execution, multimodal execution without --language-model-only, async CAM without compute_gate_on_attention=true, sequence-parallel MoE without Attention-side gating, EPLB, PP/PCP/DCP sizes other than 1, speculative decoding, LoRA, SWA bounded replay, and Engram with DBO/microbatching.

  • Hardware evidence is limited to single-node A1/F12 W8A8 eager serving. Graph, TP/SP variants, synchronous CAMP2P, W4A8, PD, multi-node and long-duration stability are not qualified by this record.
  • One vector core exception (507035) caused an EngineCore crash during validation. Restart recovered service; its root cause remains undetermined.
  • The server report flags one stale test link in docs/design/module/model_integration.md; it still needs to point to tests/unit/model_executor/models/npu/test_deepseek_v41.py.

Docs impact

docs/design/module/model_integration.md documents role ownership, checkpoint filtering and support restrictions. Its hardware-validation wording predates the latest server report; this PR description and the linked record provide the current bounded results.

@wangyao-i
wangyao-i marked this pull request as draft November 5, 2026 00:22

@jiangkuaixue123 jiangkuaixue123 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.

Found a checkpoint-filtering failure in the text-only role split. Reviewed against pinned vLLM-Ascend bd42eea0; NPU construction and execution were not run.

Comment on lines +117 to +119
_DEFERRED_NAME_PREFIXES
):
return _NO_ROLES

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.

[P1] Normalize the optional model prefix before filtering non-text weights

The pinned Ascend implementation explicitly supports model.image_end in its text-only checkpoint path (see test_v41_text_only_load_skips_checkpoint_vision_weights). This check only drops unprefixed image_*, vision.*, and aligner.* names. For model.image_end, _weight_layer_path() returns None, so the tensor is sent to both AFD roles. Because this adapter subclasses the text LLM directly, it bypasses the native multimodal wrapper's prefix normalization, and the inherited _load_model_weights() reaches params_dict['model.image_end'], raising KeyError since neither role allocates that parameter. Normalize an optional model. prefix for non-text/deferred-weight classification, and cover prefixed checkpoint names as well as the unprefixed ones.

Add an Ascend NPU adapter for DeepSeek-V4.1 flash. The Attention role keeps the native source-shared DSA/HC/Engram forward and only replaces the FFN slot with a parameter-free remote proxy; the FFN role builds the native DeepseekV41MoE and serves it through compute_ffn_output.

Engram tables, candidate-index buffers, shared attention state, and decoder replay stay on Attention, so the FFN role reports has_engram=False and drops every engram checkpoint path. The router shell, CAM exchange, shared-expert layout, and layered FFN extraction reuse the DeepSeek V4 implementation, widened only for the V4.1 already_sequence_parallel argument.

The alias resolves only on Ascend NPU and model-config resolution rejects other device types before model loading.

Signed-off-by: wangyao-i <iwangyao@outlook.com>
Signed-off-by: wangyao-i <iwangyao@outlook.com>
@wangyao-i
wangyao-i force-pushed the feat/npu-deepseek-v41-afd branch from 8de1250 to 42a893e Compare November 6, 2026 04:14
@hsliuustc0106 hsliuustc0106 added enhancement New feature or request Ascend Ascend NPU platform and related changes labels Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ascend Ascend NPU platform and related changes enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants