Skip to content

perf(mtp): optimize Qwen3.5 GDN verification kernel - #1513

Merged
sufubao merged 12 commits into
ModelTC:mainfrom
sufubao:gdn-mtp-kernel-opt
Aug 28, 2026
Merged

perf(mtp): optimize Qwen3.5 GDN verification kernel#1513
sufubao merged 12 commits into
ModelTC:mainfrom
sufubao:gdn-mtp-kernel-opt

Conversation

@sufubao

@sufubao sufubao commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • specialize the recurrent GDN kernel used by fixed-width MTP verification while preserving the variable-length path
  • use LightLLM autotune v1 to select BV, num_warps, and num_stages for each CUDA Graph shape
  • search 60 configurations: BV ∈ {4, 8, 16, 32, 64}, num_warps ∈ {1, 2, 4, 8}, and num_stages ∈ {1, 2, 3}
  • key cached configurations by GDN dimensions, input/state dtype, fixed sequence width, sequence count, and token count
  • protect in-place SSM state during tuning with mutates_args=["initial_state"]
  • avoid request-index materialization, the cu_seqlens int64 cast, and the GDN gate copy in the MTP path
  • trigger CUDA Graph tuning only from layer 0 / microbatch 0 using existing layer metadata
  • restore committed regression tests for the optimized kernel, autotune behavior, gated RMSNorm, and Qwen3Next integration

Final H100 validation after rebase

Final head 0be08549f6fbd7fcf5764792d88e0f3b2184918c is based on the then-current upstream/main@aa7cab9ad12452fb08bfc316461242640b1b976c (PR #1509 merged).

The matched control is upstream/main@e1caab0b. Candidate and control used the same four H100 80GB GPUs, Qwen3.5-27B model files, TP4, MTP3, FP8 (fp8w8a8-pt-sgl), CUDA Graph shapes, launch environment, AIPerf corpus, and fixed streaming ISL=256/OSL=1024. Each point is the median of three recorded runs; all 42 final candidate runs completed with zero request errors.

Concurrency control tok/s final tok/s gain p99 TTFT change p99 ITL change
1 323.10 333.86 +3.33% +1.56% -8.41%
2 632.21 655.13 +3.63% -34.14% -2.57%
4 1112.24 1185.66 +6.60% -35.13% -9.34%
8 2023.47 2200.98 +8.77% -17.54% -14.54%
16 3344.54 3533.89 +5.66% -6.42% -5.08%
32 4882.93 5380.04 +10.18% -17.93% -10.99%
64 6355.42 7021.90 +10.49% -1.61% -10.08%

Geometric-mean output-throughput gain across C1–C64 is +6.92%. The C1 p99 TTFT increase is below the 3% regression gate; all other reported p99 TTFT and ITL comparisons improve. First-run JIT/cache outliers at C1 and C4 occurred in both control and candidate sets and are retained in raw artifacts; medians are used as specified.

Final candidate run IDs on host 10-116-123-171:

  • launch: 260829-005838-2654031-sudo-n-docker-run-d-name-pr1513-final-0be08549-p
  • labeled residual-JIT warmup (excluded): 260829-010139-2664033-home-devsft-aiperf-venv-bin-aiperf-profile-model
  • C1: 260829-010221-2666746-home-devsft-aiperf-venv-bin-aiperf-profile-model
  • C2: 260829-010319-2668254-home-devsft-aiperf-venv-bin-aiperf-profile-model
  • C4: 260829-010359-2669682-home-devsft-aiperf-venv-bin-aiperf-profile-model
  • C8: 260829-010454-2671324-home-devsft-aiperf-venv-bin-aiperf-profile-model
  • C16: 260829-010537-2673354-home-devsft-aiperf-venv-bin-aiperf-profile-model
  • C32: 260829-010626-2676464-home-devsft-aiperf-venv-bin-aiperf-profile-model
  • C64: 260829-010724-2681721-home-devsft-aiperf-venv-bin-aiperf-profile-model
  • log archive / clean shutdown: 260829-010853-2687303-sh-c-sudo-n-docker-logs-pr1513-final-0be08549-p1

Raw results and server logs are retained under /home/devsft/qwen35_goal_20260829/pr1513_aa7_results.

Correctness and autotune evidence

  • final local affected suite: 135 passed
  • final H100 affected CUDA suite: 135 passed
  • fixed-width and dynamic paths match the FLA reference, including output and written in-place SSM state
  • production graph shapes load the keyed H100 cache and all 34 graph batches capture successfully
  • fresh-cache TP4 startup on functional head 1c98ca56 tuned all 34 shapes once per rank and reached ready without traceback or OOM
  • expanded 60-config H200 compile/equivalence sweep passed; the warp dimension is exercised by selected intermediate and large shapes
  • worst recorded production-shape numerical differences versus FLA: output max abs 4.8828125e-4, output min cosine 1.0, state max abs 2.3841858e-7, state min cosine 1.0
  • isolated service black-box comparison: 17 PASS / 2 baseline FAIL / 6 SKIP, with no PR-introduced failure
  • Black, Flake8, repository pre-commit, and git diff --check pass

Established facts are the test, capture, and measured results above. The expected benefit on other models, GPUs, or workload distributions remains a hypothesis and is not claimed here. Every performance command was run through exp -m.

@sufubao
sufubao force-pushed the gdn-mtp-kernel-opt branch 2 times, most recently from 9e8cd17 to 7cdd1c6 Compare August 28, 2026 16:32
@sufubao
sufubao force-pushed the gdn-mtp-kernel-opt branch from 5124935 to 0be0854 Compare August 28, 2026 16:56
@sufubao
sufubao merged commit 3e0d9f7 into ModelTC:main Aug 28, 2026
1 check 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