Skip to content

Add: compose DeepSeek V4 HCA decode TP output - #938

Merged
zhangqi-chen merged 1 commit into
hw-native-sys:mainfrom
wangqin1723-max:feat/compose-deepseek-v4-hca-decode-tp4-output
Aug 17, 2026
Merged

zhangqi-chen merged 1 commit into
hw-native-sys:mainfrom
wangqin1723-max:feat/compose-deepseek-v4-hca-decode-tp4-output

Conversation

@wangqin1723-max

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

Copy link
Copy Markdown
Collaborator
  • Chain rank-local HCA 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_hca.py,
    reuse the shared output projection, and validate dynamic caches,
    compressed slots, inverse RoPE, and inactive capacity tails.

@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Added a complete DeepSeek-V4 HCA decode output path for context parallelism. The module includes distributed JIT kernels, deterministic fixtures, a PyTorch golden model, active-row and sentinel-tail comparison, and a configurable CLI runner.

Changes

HCA output context parallelism

Layer / File(s) Summary
Fixtures and validation contracts
models/deepseek_v4_flash_dspark/decode_hca_output_cp.py
Defines fixture constants, dimension checks, deterministic tensor specifications, cache data, projection data, and poisoned output buffers.
Distributed HCA output execution
models/deepseek_v4_flash_dspark/decode_hca_output_cp.py
Adds device and host JIT paths for sparse HCA attention, attention all-to-all, sharded output projection, and reduce-scatter across physical SP ranks.
Golden comparison and test execution
models/deepseek_v4_flash_dspark/decode_hca_output_cp.py
Adds the PyTorch golden model, valid-row comparison, inactive-tail preservation checks, and CLI support for capacity cases and compilation options.

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

Sequence Diagram(s)

sequenceDiagram
  participant CLI as CLI test runner
  participant Launcher as l3_decode_hca_output_cp
  participant Kernel as decode_hca_output_cp
  participant Runtime as Distributed runtime
  participant Golden as golden_decode_hca_output_cp
  CLI->>Launcher: Run selected fixture
  Launcher->>Runtime: Allocate communication windows and signals
  Launcher->>Kernel: Execute across SP ranks
  Kernel->>Runtime: Exchange attention data and reduce-scatter output
  CLI->>Golden: Compute reference output
  CLI->>Golden: Compare active rows and sentinel tail
Loading

Possibly related PRs

Suggested labels: enhancement

Poem

A rabbit hops through sparse-head light,
While tensors gather rank by rank.
RoPE turns back, projections land,
Tails stay poisoned, neat and dank.
The golden check says, “All is right!”

🚥 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 main change: composing DeepSeek V4 HCA decode output for tensor parallelism.
Description check ✅ Passed The description directly explains the tensor-parallel HCA output composition and its validation coverage.

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@models/deepseek_v4_flash_dspark/decode_hca_output_cp.py`:
- Around line 60-78: Add an import-time ValueError guard alongside the existing
fixture validation checks to ensure CMP_TOPK is greater than
max(FIXTURE_CMP_SLOTS). Use a descriptive message explaining that the fixture
compressed slots exceed the configured top-k capacity, before any fixture
execution or golden validation occurs.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 9b40ae86-e5d6-4e12-b2fc-3a575a215b1c

📥 Commits

Reviewing files that changed from the base of the PR and between 6eb3b0f and 70d61b9.

📒 Files selected for processing (1)
  • models/deepseek_v4_flash_dspark/decode_hca_output_cp.py

Comment thread models/deepseek_v4_flash_dspark/decode_hca_output.py Outdated
@wangqin1723-max
wangqin1723-max force-pushed the feat/compose-deepseek-v4-hca-decode-tp4-output branch from 70d61b9 to 279be3f Compare August 12, 2026 02:39
@wangqin1723-max
wangqin1723-max force-pushed the feat/compose-deepseek-v4-hca-decode-tp4-output branch from 279be3f to 90464b6 Compare August 12, 2026 03:27
@wangqin1723-max
wangqin1723-max force-pushed the feat/compose-deepseek-v4-hca-decode-tp4-output branch 4 times, most recently from ebf199e to 6d3b0a4 Compare August 14, 2026 02:52
- Chain rank-local HCA 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_hca.py`,
  reuse the shared output projection, and validate dynamic caches,
  compressed slots, inverse RoPE, and inactive capacity tails.
@wangqin1723-max
wangqin1723-max force-pushed the feat/compose-deepseek-v4-hca-decode-tp4-output branch from 6d3b0a4 to e3c2397 Compare August 14, 2026 06:47
@wangqin1723-max wangqin1723-max changed the title Add: compose DeepSeek V4 HCA decode TP4 output Add: compose DeepSeek V4 HCA decode TP output Aug 14, 2026
@zhangqi-chen
zhangqi-chen merged commit 50e3792 into hw-native-sys:main Aug 17, 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