Skip to content

perf(glm52): batch TP4 prefill execution#759

Draft
xiaguan wants to merge 1 commit into
mainfrom
perf/glm52-tp4-prefill
Draft

perf(glm52): batch TP4 prefill execution#759
xiaguan wants to merge 1 commit into
mainfrom
perf/glm52-tp4-prefill

Conversation

@xiaguan

@xiaguan xiaguan commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator

Summary

Speed up the native GLM-5.2 FP8 TP4 prefill-only request path by batching routed-expert work and increasing the outer prefill tile from 32 to 512 rows.

The previous implementation launched the FP8 projection chain separately for every active expert. On a 1K prompt this made prefill roughly 24 seconds and dominated the entire request. This change:

  • packs routed rows once and executes the routed experts through two batched FlashInfer/CUTLASS groupwise FP8 GEMMs per MoE layer;
  • keeps the indexer and sparse-attention subtiles at their validated 32-row shape while dense and MoE projections use a 512-row outer tile;
  • uses NCCL BF16 all-reduce for the large-M prefill path and avoids allocating decode-only LL/VMM buffers in prefill-only mode;
  • reduces the packed routed/shared outputs with one deterministic weighted-reduction kernel;
  • adds a 512-row startup preflight and accounts for the larger workspace in the VRAM budget.

This PR deliberately does not change startup loading. The remaining large performance gap is the padded 512-row MoE execution itself; closing it requires a deployable fused-MoE backend that can consume most or all of the 16K prefill chunk directly.

Performance

Single request, greedy one-token boundary output, concurrency 1, prefix-cache misses, 16K chunking, one 4×GB300 host. Values are mean TTFT.

requested input merged implementation this PR vLLM TP4+EP FP8-KV
1K 24,451 ms 1,843 ms 319 ms
4K 5,310 ms 310 ms
16K 20,138 ms 901 ms

The 1K path is 13.3× faster than the merged implementation. Moving from the validated 256-row point to 512 rows improved TTFT by another 4.9% at 1K, 5.8% at 4K, and 3.5% at 16K. A 1024-row experiment faulted and is not used.

The final 512-row startup preflight passes on all four ranks. Post-build free VRAM is 84.0 GiB per rank with --max-model-len 131136 and --glm52-prefill-chunk-size 16384.

Nsight Systems attributes the remaining request GPU time primarily to FP8 CUTLASS GEMM (65.4%); NCCL is 9.0% and sparse attention is 1.0%. The new weighted reduction is about 0.3% of the request trace. A temporary 256×9-route microbenchmark measured 12.1 µs per launch; Nsight Compute measured 85.3% achieved occupancy. The temporary benchmark was not committed.

Validation

  • cargo build --release -p openinfer-server --features glm52
  • cargo test -p openinfer-glm52 --lib — 78 passed, 17 ignored
  • cargo fmt --all -- --check
  • cargo clippy -p openinfer-kernels --features glm52 --lib -- -D warnings
  • live TP4 startup with the 512-row kernel preflight
  • five 1K requests and three requests each at 4K and 16K
  • git diff --check

Affected-crate strict Clippy still reports existing lints outside this diff in the GLM-5.2 crate (remote match arms, scheduler boolean parameters, and an existing topology match).

Signed-off-by: JinYan Su <751080330@qq.com>
@xiaguan
xiaguan force-pushed the perf/glm52-tp4-prefill branch from c8844dc to fea9271 Compare July 24, 2026 19:59
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