Skip to content

[NPU] Enable native target and DSpark draft Attention graphs - #545

Merged
jiangkuaixue123 merged 7 commits into
mainfrom
codex/dspark-attention-graph-main
Nov 13, 2026
Merged

jiangkuaixue123 merged 7 commits into
mainfrom
codex/dspark-attention-graph-main

Conversation

@jiaran-king

@jiaran-king jiaran-king commented Nov 5, 2026 •

Copy link
Copy Markdown
Collaborator

Purpose

Enable native decode graphs for Async CAM DeepSeek-V4 target Attention and
DSpark draft Attention. Reuse the vLLM/vLLM-Ascend graph managers and install
AFD metadata at capture/replay boundaries for remote expert calls.

Issue

Related to #499; complements the F-side FULL support merged in #532.

Scope

  • Target native graphs with an eager or native-graph DSpark draft; matching
    target/draft TP and independent F execution settings.
  • Preserve Attention-local FlashComm1/SP and native PD. P uses the upstream
    complete draft model and existing KV transfer; no new PD protocol is added.
  • Accept native FULL/FULL_DECODE_ONLY resolution. Remove graph-specific
    restrictions on compilation mode and model-free speculation; existing
    model-based draft/MTP checks remain. Device qualification uses mode 0.
  • Keep DBO excluded and draft graph dependent on target graph, as native target
    capture owns draft capture. Unequal target/draft TP, native kernels,
    quantization changes and lifecycle work remain outside this PR.

Implementation Notes

  • Stage target metadata after native capture input preparation and before
    replay, preserving real and padded token counts. Send synchronous DP control
    only when a connector has a control plane; Async CAM has none.
  • Scope draft metadata to its own descriptor and query width. Reuse the existing
    physical KV block-size adapter and restore temporary methods/context on
    normal and exceptional exits.
  • Native managers retain ownership of graph buffers, buckets, attention/KV
    updates, sampling and fallback. No new ModelRunner, F executor or
    communication protocol is introduced. Preserve main's fix(npu): keep profile routing decisions inside an opaque op #500 routing fix.
  • Integrate on main e58fdec5876782b9c6a03683416611deea42af92, retaining its
    MegaMoE path and FFN two-stream removal. No F-runner, connector or
    native-operator changes are included in the PR diff.

Test Plan / Test Result

The conflict resolution at fb4095d merges main 26d8151 and preserves
both Async CAM Attention graph validation and the synchronous CAMP2p
Attention-side routing constraints from #503. Focused CPU checks passed
123 cases, with 35 dependency-gated skips. Changed-file pre-commit
hooks and git diff --check passed. NPU results below are prior evidence;
no new device run was performed for this merge.

After the earlier main synchronization at 7fca98e, focused Async CAM connector/session
CPU checks pass 40 cases; 3 graph test modules are skipped because the
host lacks native dependencies. Documentation hooks, local links and diff
hygiene pass. Conflict resolutions retain the Graph capability descriptions
and main's documentation reorganization. Attention graph implementation files
are unchanged.

The earlier 112 passed, 33 dependency-gated skips and Ruff results at
822779f are reused. The merge retains the graph control-plane test fields and
main's attention_step connector context.

Six pinned-runtime feature-validation checks and the earlier metadata,
restoration, signature and device results below are reused pre-merge evidence.
No new NPU experiment was run for conflict resolution. Configuration tests
continue to admit PD/SP/native options and retain the model-based draft
boundary and DBO rejection.

Retained NPU comparisons used the pre-merge main-integrated execution code
(5afe9dd89314a36850cbb19e9a4e40d9706c3b83, with the admission gates removed):

Combination Fixed functional requests Greedy output vs same-config eager Successful target / draft replays per A rank Padded draft replays per A rank
SP / FlashComm1 13 All token-for-token identical 73 / 86 86
Native PD + SP / FlashComm1 10 All token-for-token identical 82 / 83 83

Actual SP flags were checked on both target and draft. PD used
MooncakeHybridConnector with native full-draft P TP4. Cases cover one-token,
127/128/129-token and chunked 513-token prompts, concurrency and request reuse.
PD eager/graph both recorded 405 drafted and 263 accepted tokens. In the SP
comparison, the totals were 475/347 and 465/345 respectively; outputs still
matched exactly, and concurrent scheduling was not fixed between arms.

The pinned native configuration resolver was also executed directly:
requested FULL resolves to FULL_DECODE_ONLY for DSV4's UNIFORM_BATCH
backend. This was a configuration check, not another model experiment.
Compilation mode 3 and model-free speculation admission were checked at the
configuration seam only; their device execution is not qualified here.

One formal measurement per arm used W4A8, A DP1/TP4, F EP4/TP1 FULL, five
speculative tokens, 32 requests, 128 input and 128 output tokens, concurrency 4
and four client warmups. Each arm completed 32/32 requests and 4,096 output
tokens. Functional replay probes were removed before timing; their counters
remained unchanged afterward. No profiling ran during measurement.

Combination Mean TPOT, eager → dual graph Output throughput, eager → dual graph Mean TTFT, eager → dual graph
SP / FlashComm1 38.40 → 14.83 ms 86.89 → 221.53 token/s 412.96 → 254.95 ms
Native PD + SP / FlashComm1 36.15 → 12.22 ms 83.85 → 226.11 token/s 1041.01 → 531.84 ms

Retained earlier non-PD, SP-off evidence: nine finite requests matched the
reference token-for-token, with 51 target and 60 draft replays per A rank.
Its single performance comparison measured TPOT 32.20 → 14.63 ms, throughput
102.62 → 226.70 token/s and TTFT 393.14 → 234.11 ms. That earlier measurement
used 140369b873c34779d0d53a8af82aced3c47484eb on an older main baseline;
it was reused rather than rerun. Do not compare absolute numbers across the
separate deployment experiments or attribute the combined gain to one graph.

Pinned stack: vLLM 5df63a7203cdb9328d824a27b682e77c7b9928be, vLLM-Ascend
bd42eea01d8312c4df469fabaed45f77a12df4d3, CANN 9.2 and torch-npu
2.10.0.post7 on Ascend 910C/A3. Existing native binaries were reused unchanged.

MegaMoE with A graphs, W8A8 A graphs, other KV connectors/topologies, GPU
execution, DBO and task-level model accuracy are not newly qualified. Successful cleanup of owned processes
is not a new graceful-shutdown qualification.

Docs Impact

Update the existing Attention, model/platform, Async CAM/FFN and DSpark recipe
contracts. Distinguish actual implementation dependencies from device validation
coverage. Experiment scripts, probes, raw logs and private evidence stay outside
the patch.


Essential PR Checklist
  • Purpose is clear and linked to public context.
  • Scope is bounded.
  • Compatibility with the pinned vLLM 0.32 / Ascend pair is considered.
  • No upstream source checkouts are changed.
  • Existing plugin classes and native graph managers are reused.
  • Scoped native hooks are restored, documented and signature-checked.
  • Runtime imports retain NPU boundaries and dependency guards.
  • Executed, reused and unverified validation paths are distinguished.
  • Documentation impact is stated.

Signed-off-by: jiaran-king <jiaranran2@gmail.com>
Signed-off-by: jiaran-king <jiaranran2@gmail.com>
Signed-off-by: jiaran-king <jiaranran2@gmail.com>

Copy link
Copy Markdown
Collaborator

Could you clarify the support plan for combining the new target/draft Attention graphs with PD, SP/FlashComm1, and DBO? For each of these, is the current exclusion due to a known implementation limitation, or is it mainly outside this PR's validation scope? What additional work would be needed to enable support, and are there follow-up issues or PRs tracking it?

Signed-off-by: jiaran-king <jiaranran2@gmail.com>
@jiaran-king

Copy link
Copy Markdown
Collaborator Author

Could you clarify the support plan for combining the new target/draft Attention graphs with PD, SP/FlashComm1, and DBO? For each of these, is the current exclusion due to a known implementation limitation, or is it mainly outside this PR's validation scope? What additional work would be needed to enable support, and are there follow-up issues or PRs tracking it?

Updated the PR:

  • PD/SP: removed the gates after NPU validation. SP (13 requests) and PD+SP (10) matched eager output token-for-token, with target/draft replay and padding confirmed.
  • DBO: remains unsupported with DSpark in the pinned runtime and stays blocked.
  • Removed unnecessary graph-specific restrictions; native validation remains.

Signed-off-by: jiaran-king <jiaranran2@gmail.com>
Signed-off-by: jiaran-king <jiaranran2@gmail.com>
@github-actions github-actions Bot added documentation Improvements or additions to documentation Ascend Ascend NPU platform and related changes labels Nov 10, 2026
Keep Async CAM Attention graph validation from PR #545 and the synchronous CAMP2p Attention-side routing validation from main (#503).

Signed-off-by: Zhou ziheng <jiaranran2@gmail.com>
@jiangkuaixue123

Copy link
Copy Markdown
Collaborator

LGTM

@jiangkuaixue123
jiangkuaixue123 merged commit 6620336 into main Nov 13, 2026
3 checks passed
Pingzii added a commit to Pingzii/afd-plugin that referenced this pull request Nov 14, 2026
…llows

vllm-project#545 lets Async CAM Attention run the FULL graph mode and has the native backend
resolve it to FULL_DECODE_ONLY, so the case that asserted a rejection was stale
in the same way as the sync-gate one. The config stays in the table as a valid
input; it is the expectation that changes.

Signed-off-by: 宋元盟 <songyuanmeng2@huawei.com>
jiangkuaixue123 pushed a commit that referenced this pull request Nov 15, 2026
…ests (#583)

- the proxy test's module-level `torch_npu` stand-in was removed from
`sys.modules` but stayed bound in `deepseek_v4_shared_experts` (it does
`import torch_npu`), so a later import reused the cached module and saw
the stand-in; the import window is bracketed now and the modules bound
to the stand-in are dropped with their parent attributes.
Fixes #581.

Three test repairs around the NPU feature-validation table:

- `[gate-on-attention]` (added before #503): the connector-local
`compute_gate_on_attention` key is a compatibility no-op since #503 --
the common `afd.compute_gate_on_attention` field selects routing
placement -- so the case can no longer raise. The expectation is
deleted; the narrowed validator it once covered is still pinned in
`test_sync_gate_feature_validation_cpu.py` (TP != 1, DBO/ubatching).
- `[async-graph]` (stale since #545): Async CAM Attention accepts FULL
and the native backend resolves it to FULL_DECODE_ONLY, so the config is
valid input. The row stays in the table with `None` as its expectation,
documenting the accepted shape.
- the two connector-contract cases in
`test_sync_gate_feature_validation_cpu.py` ran behind
`pytest.importorskip("vllm")` although nothing at call time needs vLLM;
`_real_extra_info()` now stands in only the modules the import touches,
restores `sys.modules`, and returns the real `CAMP2PExtraInfo`, so the
local run executes the class instead of skipping it (9 passed / 2
skipped -> 11 passed).

Test changes only. Local Windows CPU run: full `tests/unit` 922 passed /
90 skipped / 0 failed; the vLLM-only file still skips here, so the merge
build from #581 remains its verification.

---------

Signed-off-by: 宋元盟 <songyuanmeng2@huawei.com>
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 documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants