Skip to content

Reuse AITER GDN prefill metadata - #18

Merged
sammysun0711 merged 2 commits into
apinge:qwen3_5_v0.5.15_dflashfrom
IzacharyI:reuse_metadata
Aug 13, 2026
Merged

sammysun0711 merged 2 commits into
apinge:qwen3_5_v0.5.15_dflashfrom
IzacharyI:reuse_metadata

Conversation

@IzacharyI

@IzacharyI IzacharyI commented Aug 11, 2026 •

Copy link
Copy Markdown
Collaborator

Motivation

AITER GDN prefill supports reusable batch metadata, but SGLang previously rebuilt the same scheduling metadata inside every GDN layer.

This PR builds the metadata once per eligible prefill forward and reuses it across all GDN layers, eliminating repeated device-to-host synchronization and metadata copies.

Modifications

  • Build reusable AITER GDN prefill metadata once per forward.
  • Pass seq_lens_cpu and the metadata through the GDN backend and AITER kernel dispatcher.
  • Reuse the metadata in both fused and low-level AITER prefill paths.
  • Restrict the optimized path to single-sequence, non-padded, non-speculative prefill.
  • Preserve the legacy path when the AITER metadata API is unavailable or the batch is ineligible.
  • Add unit tests for metadata construction and propagation.

Accuracy Tests

  • Full GDN AITER backend unit suite:

    28 passed

  • AITER legacy and reusable-metadata paths produced matching output and final state:

    • rtol=1e-3
    • atol=2e-3

No model-level task accuracy regression is expected because this change only reuses scheduling metadata without changing kernel math.

Speed Tests and Profiling

Configuration:

  • Model: Qwen3.5-397B-A17B-PTPC
  • Tensor parallelism: TP8
  • Input length: 8000
  • Output length: 1
  • Concurrency: 32

Profiling results:

  • CatArrayBatchedCopy_contig: 4 -> 0
  • D2H copies before GDN cumsum: 4 -> 0
  • First-layer cumsum/recompute/chunk-h gaps: reduced to at most 0.001 us across all TP ranks with a warm allocator
  • Measured input throughput: 25,463 tokens/s

Checklist

Review and Merge Process

  1. Ping Merge Oncalls to start the process. See the PR Merge Process.
  2. Get approvals from CODEOWNERS and other reviewers.
  3. Trigger CI tests with comments or contact authorized users to do so.
    • Common commands include /tag-and-rerun-ci, /tag-run-ci-label, /rerun-failed-ci
  4. After green CI and required approvals, ask Merge Oncalls or people with Write permission to merge the PR.

@apinge
apinge requested review from apinge and sammysun0711 and a lite review from Copilot August 12, 2026 00:25

Copilot AI 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.

Pull request overview

This PR optimizes the HIP/AITER GDN prefill path by building reusable prefill scheduling metadata once per eligible forward pass and reusing it across all GDN layers, reducing repeated synchronization and metadata reconstruction overhead.

Changes:

  • Add reusable AITER GDN prefill metadata construction in GDNAttnBackend and thread it through the extend path.
  • Update AiterGDNKernel.extend() to forward seq_lens_cpu / prefill_metadata to AITER prefill entry points.
  • Add unit tests to validate metadata construction and propagation into the AITER prefill call.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
test/registered/attention/test_gdn_aiter_backend.py Adds unit coverage for reusable prefill metadata construction and verifies propagation into the AITER prefill call.
python/sglang/srt/layers/attention/linear/kernels/gdn_aiter.py Threads optional reusable prefill metadata through the high-level and low-level AITER prefill execution paths.
python/sglang/srt/layers/attention/linear/gdn_backend.py Builds reusable AITER prefill metadata once per eligible extend forward and passes it (plus seq_lens_cpu) into kernel dispatch.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@apinge

apinge commented Aug 12, 2026 •

Copy link
Copy Markdown
Owner

This PR is related to aiter ROCm/aiter#4694

@apinge

apinge commented Aug 12, 2026 •

Copy link
Copy Markdown
Owner

I profiled with the aiter PR.

 python3 benchmark/gsm8k/bench_sglang.py    --port 7080       --tokenizer-path /models/Qwen/Qwen3.5-397B-A17B-PTPC-FP8  --max-new-tokens 4096
100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 200/200 [01:09<00:00,  2.87it/s]
Accuracy: 0.975
Invalid: 0.000
Latency: 69.777 s
Output throughput: 504.062 token/s

Before

image

After

image

@sammysun0711
sammysun0711 merged commit d9d0d4d into apinge:qwen3_5_v0.5.15_dflash Aug 13, 2026
12 of 17 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.

4 participants