Skip to content

[Kernel][SM70] Optimize DeepSeek V4 PP2 TP4 decode hot paths - #308

Merged
yangzhuxinyzx merged 8 commits into
mainfrom
agent/v100-dsv4-pp2tp4-mxfp4-direct-order-20260826
Aug 28, 2026
Merged

yangzhuxinyzx merged 8 commits into
mainfrom
agent/v100-dsv4-pp2tp4-mxfp4-direct-order-20260826

Conversation

@yangzhuxinyzx

Copy link
Copy Markdown
Contributor

Purpose

Stack the exact PP2 x TP4 DeepSeek V4 Flash decode candidates after the QPN8 audit branch:

  • use 16-head sparse MLA grouping on TP4;
  • fuse Q normalization/RoPE with KV insertion;
  • broadcast the physical B1 MXFP4 W13 input;
  • keep B1 top-6 routes in original order to remove redundant sort/inverse-permutation work;
  • specialize the exact top-k-6 weighted reduction with half2.

All new runtime behavior remains opt-in while matched endpoint and aggregate-quality gates are pending.

Test Plan

  • compile the SM70 CUDA translation unit with CUDA 12.8 and link an SM70-only extension;
  • run the weighted-reduce exactness regression on V100;
  • compare generic, current direct-top6, and direct-order MXFP4 pipelines under CUDA Graph, including route IDs changed after capture;
  • run matched eight-V100 PP2 x TP4 performance and aggregate-quality gates when the shared node is free.

Test Result

  • ruff check passed for changed Python files;
  • CUDA 12.8 source build passed; extension SHA256 3cbf943f2a417c8632368d0890c80bf5e5c446a31a9f0f18c12b9555b49f6fad, SM70 cubins only;
  • test_sm70_single_token_weighted_reduce_matches_moe_unpermute: 1 passed (including new top-k=6, H=4096 case);
  • MXFP4 CUDA Graph pipeline: current direct-top6 54.414 us/layer, direct-order 46.519 us/layer, projected 0.339 ms/token service reduction across 43 layers;
  • W13, clamped SwiGLU, W2, and final output are bitwise equal initially and after dynamic route change;
  • artifact: /data/models/v100-dsv4-0731-pp2tp4-mxfp4-direct-order-screen-20260826-r1/results/full_pipeline.json.

Endpoint and dataset results are intentionally pending.

Signed-off-by: yangzhuxinyzx <153831768+yangzhuxinyzx@users.noreply.github.com>
Signed-off-by: yangzhuxinyzx <153831768+yangzhuxinyzx@users.noreply.github.com>
Signed-off-by: yangzhuxinyzx <153831768+yangzhuxinyzx@users.noreply.github.com>
Signed-off-by: yangzhuxinyzx <153831768+yangzhuxinyzx@users.noreply.github.com>
@yangzhuxinyzx

Copy link
Copy Markdown
Contributor Author

Superseded by merged PR #314. The four hot paths were rebuilt on latest main, source-audited independently, repaired to align Python/C++ default semantics and token bounds, defaulted with explicit rollbacks, and passed focused tests plus whole-repository pre-commit. The optimization stack is merged as 1b1c9fa rather than rejected.

Signed-off-by: yangzhuxinyzx <153831768+yangzhuxinyzx@users.noreply.github.com>
@yangzhuxinyzx yangzhuxinyzx reopened this Aug 26, 2026
@yangzhuxinyzx

Copy link
Copy Markdown
Contributor Author

Post-endpoint quality update: the first direct-order run reached 69.949 token/s but produced incoherent text and is rejected. Root cause is cross-shape state reuse: M2-M8 active-expert compaction overwrites compact_expert_offsets before B1 graph capture, while the direct-order branch assumed fixed one-row offsets. Commit 052312c switches B1 direct-order to immutable slot_expert_offsets and adds a poisoned-workspace regression; the focused CPU tests pass (2 passed). Full-model and GSM8K-64 revalidation remain pending, so this PR stays Draft.

@yangzhuxinyzx

Copy link
Copy Markdown
Contributor Author

Superseded in full by current-main repairs: #314 merged the four audited/defaulted hot paths, and #326 now merged the post-endpoint direct-order offset isolation as b06f54ce. The bad 69.949 token/s run remains recorded as rejected quality evidence; main now uses immutable slot offsets so M2-M8 warmup cannot poison B1 graph capture. This closes the stale stacked branch only after both the optimization and its newly reported bugfix landed.

@1CatAI 1CatAI locked and limited conversation to collaborators Aug 26, 2026
@yangzhuxinyzx
yangzhuxinyzx deleted the agent/v100-dsv4-pp2tp4-mxfp4-direct-order-20260826 branch August 26, 2026 07:55
@yangzhuxinyzx
yangzhuxinyzx restored the agent/v100-dsv4-pp2tp4-mxfp4-direct-order-20260826 branch August 27, 2026 14:35
@1CatAI 1CatAI unlocked this conversation Aug 27, 2026
@yangzhuxinyzx yangzhuxinyzx reopened this Aug 27, 2026
@yangzhuxinyzx

Copy link
Copy Markdown
Contributor Author

公开开发已恢复:本 PR 已取消归档、解锁并重新打开。为避免把旧基线上的问题直接带入最新 main,现统一作为 Draft 审计项;恢复可见性不代表已经批准合并。 该组涉及 SM70/V100 性能或数值路径,需先与当前主线及 #344–#351 去重,再用同条件的聚焦质量和性能证据决定修复后合并。

Signed-off-by: yangzhuxinyzx <153831768+yangzhuxinyzx@users.noreply.github.com>
#314/#326 已包含其安全、默认开启的后续实现;排除旧堆叠实验。

Signed-off-by: yangzhuxinyzx <153831768+yangzhuxinyzx@users.noreply.github.com>
…-20260828-0310

[CI][SM70] Sync #308 to audited latest main
@yangzhuxinyzx
yangzhuxinyzx changed the base branch from agent/v100-dsv4-pp2tp4-qpn8-accuracy-20260826 to main August 27, 2026 19:20
@yangzhuxinyzx
yangzhuxinyzx marked this pull request as ready for review August 28, 2026 03:25
@yangzhuxinyzx

Copy link
Copy Markdown
Contributor Author

审计结论:原始实验路径已由后续安全实现吸收;该分支已通过修复 PR #369 同步到最新 main,最新完整 pre-commit 通过,且锁定提交的源码树与 main 完全一致。按零差异历史归档合并,不改变主线源码。

@yangzhuxinyzx
yangzhuxinyzx merged commit c0d67dc into main Aug 28, 2026
2 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.

1 participant