Skip to content

perf(qwen4): optimize gated residual kernels and PDL - #1323

Draft
tuanzhangCS wants to merge 2 commits into
mainfrom
zt/qwen4_opt
Draft

perf(qwen4): optimize gated residual kernels and PDL#1323
tuanzhangCS wants to merge 2 commits into
mainfrom
zt/qwen4_opt

Conversation

@tuanzhangCS

@tuanzhangCS tuanzhangCS commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Move the Qwen4 gated-residual chain behind GPU-only tokenspeed-kernel APIs. Runtime code now owns parameters and checkpoint mapping only; grouped RMSNorm, mix, and combine implementations live in tokenspeed-kernel.
  • Fuse the down and inject projections, add a low-M persistent Triton path plus a portable Triton path, and keep the Blackwell CuTeDSL composition available for explicit tuning. Dispatch falls back to the deterministic general path when atomic accumulation is disabled.
  • Use stream-private persistent workspaces, preserve reduce-scatter row views, and apply non-power-of-two projection scaling after the projection to avoid checkpoint-weight quantization.
  • Make ServerArgs.disable_pdl the authoritative full-chain PDL switch. The effective hardware-gated state is applied to tokenspeed-kernel, TorchInductor, TRT-LLM, spawned workers, and CuTeDSL compilation cache keys.
  • Remove redundant runtime CPU/CUDA branches, the registered CPU reference backend, and the public mix-epilogue wrapper. Numerical references remain test-only.

Performance

B200, BF16, CUDA Graph, grouped RMSNorm + persistent mix + combine:

Tokens PDL off PDL on Change
1 18.444 us 16.417 us -11.0%
8 18.450 us 16.416 us -11.0%
16 18.446 us 17.073 us -7.4%

The CuTeDSL composition remains opt-in because current measurements favor the one-launch persistent Triton path through 16 tokens and the general path above it.

Test Plan

  • pre-commit run --all-files
  • Hyperconnection GPU numerics, dispatch, CUDA Graph, PDL, and concurrent-stream tests: 33 passed
  • CuTeDSL low-latency BF16 router tests: 29 passed
  • Layernorm tests: 31 passed
  • Kernel registry and selection tests: 237 passed, 108 platform skips
  • Runtime kernel-boundary and PDL-policy tests: 4 passed
  • ServerArgs attention-backend tests: 22 passed

The focused Qwen4 test module is not collectable in the current local environment because its installed tuning dependency does not yet accept the tensor_initializers argument; the changed paths are covered by the focused runtime and kernel suites above.

Signed-off-by: tuanzhangCS <tuan@lightseek.org>
@tuanzhangCS
tuanzhangCS requested review from a team as code owners August 31, 2026 12:03
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Aug 31, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-08-31T12:09:49.489042Z 7d29cf4 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@tuanzhangCS
tuanzhangCS marked this pull request as draft August 31, 2026 12:03
Signed-off-by: tuanzhangCS <tuan@lightseek.org>
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