Skip to content

[LoRA] BF16 support + EP cuda-graph crash fix for experimental_sgl_trtllm MoE-LoRA - #28953

Merged
Fridge003 merged 3 commits into
sgl-project:mainfrom
jybsuper:bf16-lora
Jun 25, 2026
Merged

Fridge003 merged 3 commits into
sgl-project:mainfrom
jybsuper:bf16-lora

Conversation

@jybsuper

@jybsuper jybsuper commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator

Summary

Two changes on the experimental_sgl_trtllm MoE-LoRA fast path:

  1. BF16 support for the path (previously FP8 / NVFP4 only), plus experts_shared_outer LoRA.
  2. Stability fixes that make the path correct under expert parallelism (EP) + CUDA graph:
    • NVFP4 (Kimi-K2.5): fix an illegal-memory-access that crashed batched serving under CUDA graph with the two-stream overlap enabled.
    • BF16: two follow-up correctness fixes (routing arg parity + CUDA-graph allocation safety).

Testing

Hardware: 2 nodes × 8× GB300 (TP8 / EP8, MNNVL), flashinfer 0.6.12.

Kimi-K2.5-NVFP4 — the crash fix

--moe-runner-backend experimental_sgl_trtllm, two-stream overlap on, CUDA graph on, rank-16 adapter.

  • Before: batched bench_one_batch_server crashes with an illegal memory access (TMA descriptor init) during prefill.
  • After: no crash; greedy generation coherent across diverse prompts (adapter behavior preserved). Validated bs1 prefill (the minimal repro) through bs128.
  • End-to-end overall throughput at input = output = 2048, vs the no-LoRA flashinfer_trtllm baseline:
batch LoRA (tok/s) base (tok/s) % of base
16 2519 3244 78%
32 4513 5294 85%
64 7353 8266 89%
128 11628 13076 89%

(decode-only ratio rises 79% → 96% with batch as the two-stream overlap amortizes.)

Qwen3.5-35B-A3B (BF16) — the BF16 path

Experimental path, CUDA graph + two-stream on:

  • --max-loras-per-batch 2 and 4 with distinct adapters in a single batch: all outputs coherent, no cross-adapter contamination.

CI States

Latest PR Test (Base): ✅ Run #28084700492
Latest PR Test (Extra): ❌ Run #28084700296

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@jybsuper

Copy link
Copy Markdown
Collaborator Author

/rerun-failed-ci

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@jybsuper
jybsuper force-pushed the bf16-lora branch 3 times, most recently from 42b636a to 889f7a7 Compare June 23, 2026 18:18
yushengsu-thu and others added 3 commits June 24, 2026 01:11
…ora expert_outer_shared

Squashed from yushengsu-thu#4

Adds BF16 base-model support to the experimental_sgl_trtllm MoE-LoRA fast path
(previously FP8/NVFP4-only; a bf16 checkpoint crashed at launch with
"experimental_sgl_trtllm LoRA currently requires FP8 block quant").

Follows the FP4 decomposed-pipeline strategy with the two NvFP4 quant stages
removed, so it is bf16 end-to-end and needs zero new device kernels (reuses
moe::dev::permute / activation / finalize and the trtllm-gen Gemm2 bf16 cubins
the plain bf16 path already uses):

  routing -> permute (bf16 gather) -> gate_up raw Gemm2 grouped GEMM
  (Bf16xBf16->Bf16, K=hidden, N=2*inter) -> activation (de-interleave + SwiGLU,
  adds gate_up_lora_delta pre-SwiGLU, bf16 out, no quant) -> down Gemm2 ->
  finalize.

Includes the two-stream decode overlap (O1-bf16): gate_up LoRA delta on the
shared side stream concurrent with routing/permute/gate_up GEMM, joining via
lora_ready_event before the activation kernel; down-LoRA stays serial. Also
routes the shared_outer (TML) adapter through the fused merged-align path and
two prefill-routing micro-opts (opt3/opt5). FP8/FP4 paths are additive-only.
- NVFP4: guard permutedIdx == -1 in moe::dev::permute permuteKernel. Under EP the
  router emits -1 for (token, k) slots whose expert is not on this rank; the
  unguarded gather write indexes the output buffer with a negative offset and OOBs
  at prefill scale (illegal memory access). moe::dev::finalize already skips -1.
  Fixes Kimi-K2.5-NVFP4 + experimental_sgl_trtllm LoRA under cuda-graph with the
  two-stream overlap enabled.
- BF16: pass /*expertIds=*/nullptr to the routing runner so the bf16 LoRA routing
  call matches the FP4 path's argument list.
- BF16: hoist the gate_up LoRA side-chain allocations onto the main stream
  (pre-warm the routing cache + pre-allocate the shrink intermediate) so the
  two-stream side-stream block performs no allocation during cuda-graph capture,
  matching the fp8/fp4 fix.
Revert the two out-of-package edits introduced for bf16 support and relocate the
needed logic into trtllm_lora_temp, so the experimental_sgl_trtllm MoE-LoRA work
touches only jit_kernel/trtllm_lora_temp and srt/lora/trtllm_lora_temp.

- base_backend.py: reverted to upstream. init_cuda_graph_moe_buffers needed expert
  dims from the bf16 quant-info, which names weights gemm1/gemm2_weights (4-D
  BlockMajorK) instead of FP8/FP4's w13/w2_weight (3-D). Instead of branching there,
  lora_layer.py now exposes 3-D w13_weight/w2_weight views on the bf16 quant-info,
  so the upstream `E, N, _ = w13_weight.shape` dim-extraction works unchanged.

- layers.py: reverted to upstream. Dropped the opt3 lean-info caching (a minor
  eager-prefill perf trim); the experimental-backend num_experts logic it wrapped
  is already upstream. Removed the now-unused SGLANG_OPT_LORA_LEAN_INFO env.
@Fridge003
Fridge003 merged commit 9fd6d0e into sgl-project:main Jun 25, 2026
385 of 431 checks passed
@yushengsu-thu yushengsu-thu mentioned this pull request Jul 27, 2026
29 tasks
Chronostasys pushed a commit to MindLab-Research/sglang that referenced this pull request Aug 24, 2026
…tllm MoE-LoRA (sgl-project#28953)

Co-authored-by: Yusheng Su <yushengsu.thu@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants