Skip to content

Add: compose DeepSeek V4 SWA decode TP output - #937

Merged
zhangqi-chen merged 2 commits into
hw-native-sys:mainfrom
wangqin1723-max:feat/compose-deepseek-v4-swa-decode-tp4-output
Aug 14, 2026
Merged

zhangqi-chen merged 2 commits into
hw-native-sys:mainfrom
wangqin1723-max:feat/compose-deepseek-v4-swa-decode-tp4-output

Conversation

@wangqin1723-max

@wangqin1723-max wangqin1723-max commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator
  • Chain rank-local SWA heads through TP token/head exchange, sharded
    output projection, and dependency-ordered FP32 reduce-scatter.
  • Select TP-derived shapes from --tp 1/2/4 at import time and default
    standalone and CI execution to TP2.
  • Consolidate the TP output path and fixtures into decode_swa.py, reuse
    the shared output projection, and validate max and subcapacity layouts
    with exact inactive-tail checks.

@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown

Review Change Stack

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 9da02348-be59-4fd9-901f-c3c2758f35e1

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Added a DeepSeek-V4 SWA decode output pipeline with distributed attention, sharded output projection, reduce-scatter, deterministic fixtures, PyTorch golden validation, poisoned-tail checks, and a CLI for compilation and test execution.

Changes

SWA decode output pipeline

Layer / File(s) Summary
Distributed SWA decode kernel
models/deepseek_v4_flash_dspark/decode_swa_output_cp.py
Adds decode_swa_output_cp and l3_decode_swa_output_cp. The pipeline validates dynamic shapes, performs sparse attention, all-to-all reshaping, sharded O projection, and reduce-scatter.
Fixtures and golden validation
models/deepseek_v4_flash_dspark/decode_swa_output_cp.py
Adds deterministic tensor specifications, golden_decode_swa_output_cp, and build_o_local_compare. Validation covers valid rows and poisoned inactive-capacity rows.
Compilation and test harness
models/deepseek_v4_flash_dspark/decode_swa_output_cp.py
Adds CLI options for device selection, maximum and subcapacity cases, compilation modes, pass dumps, distributed compilation, and golden comparison.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant CLI
  participant l3_decode_swa_output_cp
  participant decode_swa_output_cp
  participant DistributedCollectives
  CLI->>l3_decode_swa_output_cp: Launch distributed decode
  l3_decode_swa_output_cp->>decode_swa_output_cp: Invoke device kernel
  decode_swa_output_cp->>DistributedCollectives: Exchange attention outputs
  decode_swa_output_cp->>DistributedCollectives: Reduce-scatter projected output
  decode_swa_output_cp-->>CLI: Return o_local
Loading

Possibly related PRs

Poem

A rabbit hops through SWA’s flow,
With scattered sums in rows below.
Attention aligns, projections gleam,
Golden checks guard every stream.
“No poisoned tail shall pass,” I cheer—
A clean decode arrives here! 🐇

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly identifies the addition of the DeepSeek V4 SWA decode TP output composition, which matches the main change.
Description check ✅ Passed The description accurately summarizes TP exchange, sharded projection, reduce-scatter, shape selection, and validation changes.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@wangqin1723-max
wangqin1723-max force-pushed the feat/compose-deepseek-v4-swa-decode-tp4-output branch 3 times, most recently from eb9e73a to 41038c0 Compare August 13, 2026 03:51
in this path (model.py:478-479 selects base rope_theta when compress_ratio==0).
Companion files: attention_csa_draft.py (ratio=4)
attention_hca_draft.py (ratio=128)."""
# ci: devices=4

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.

ci devices =2

Comment on lines +779 to +784
parser.add_argument(
"--mode",
choices=("all", "tp1", "tp4"),
default=None,
help="execution mode; defaults to TP1 for an explicit single device and all paths otherwise",
)

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.

use --tp 1/2/4,like style in moe/lmhead

@wangqin1723-max wangqin1723-max changed the title Add: compose DeepSeek V4 SWA decode TP4 output Add: compose DeepSeek V4 SWA decode TP output Aug 13, 2026
- Chain rank-local SWA heads through TP token/head exchange, sharded output projection, and FP32 reduce-scatter
- Consolidate TP1 and TP4 paths behind explicit modes while isolating their runtimes in combined CI execution
- Reuse the shared output projection and validate max and subcapacity token layouts
- Specialize TP-derived shapes from --tp 1/2/4 before importing kernels
- Default to TP2 so the two-card CI runs the distributed output path
- Validate max and subcapacity layouts through one TP-generic fixture
@wangqin1723-max
wangqin1723-max force-pushed the feat/compose-deepseek-v4-swa-decode-tp4-output branch from 81fe974 to 4d7a6d1 Compare August 13, 2026 09:41
@zhangqi-chen
zhangqi-chen merged commit 6f92537 into hw-native-sys:main Aug 14, 2026
11 checks passed
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