Skip to content

Fix outlines-0.0.35 incompatibility - #291

Merged
merrymercy merged 1 commit into
sgl-project:mainfrom
ZhouGongZaiShi:fix_outlines_incompatibility
Mar 22, 2024
Merged

merrymercy merged 1 commit into
sgl-project:mainfrom
ZhouGongZaiShi:fix_outlines_incompatibility

Conversation

@ZhouGongZaiShi

@ZhouGongZaiShi ZhouGongZaiShi commented Mar 13, 2024 •

Copy link
Copy Markdown
Contributor

@BabyChouSr

Copy link
Copy Markdown
Contributor

Had this issue earlier, but luckily I came across this PR - works for me!

@merrymercy
merrymercy merged commit 7783575 into sgl-project:main Mar 22, 2024
@rlouf

rlouf commented Mar 25, 2024

Copy link
Copy Markdown

Sorry for the inconvenience; we will give you a warning when the internal API changes / open a PR in the future.

timethink pushed a commit to timethink/sglang that referenced this pull request Mar 9, 2025
EdwardXuy pushed a commit to shun8686/sglang that referenced this pull request Apr 8, 2026
Add  Expert parallelism testcases and add assertions.
efschu added a commit to efschu/htsglang that referenced this pull request Jul 30, 2026
…aut via gptq_marlin W4A16; groesste Fork-Luecke compressed-tensors min_capability=100 ohne Marlin-Abzweig; Aufwandsscheiben S1-S4/M1-M3/L; Kreuzachsen: W4A4-Praezisionsmix ueber Raenge, NVFP4A16 als codefreier Ausweg) — Task sgl-project#291
efschu added a commit to efschu/htsglang that referenced this pull request Jul 31, 2026
…esis premise is factually wrong — the sm86 NVFP4 path is NOT a slow 16-bit detour but gptq_marlin with in-kernel E2M1 dequant at 0.93-0.96x the card's own dense bf16 (the 3080s' best lane family); asymmetry is one-sided-up on the 5090 only (W4A4 native fp4 phi0 1.3-2.0 unmeasured; W4A16 is a 5090 PESSIMISATION at 0.38x); compute-tipping thesis ceiling 3.6% of the prefill window vs the 3.18% floor — does not pay; the REAL payoff is the VRAM/decode axis, symmetric: decode modelled -27% (7.43 vs 10.93 ms/token anchor), -7736 MiB, context 1.57x, and all-Linear-NVFP4 (V4) is the first format fitting solo on the 5090 with a real KV pool — deleting the 64-80% collective floor and enabling the weightless lane; checkpoint scissors: V4 is the only good variant and hard-refuses sm86 (min_capability 100, no fallback) -> sgl-project#291-S3 promoted to highest-value; two latent bugs found (ModelOptFp4Config exposes no weight_block_size = uneven-TP coarsening dead, FIFTH alignment-family member; expert-offload installs on NVFP4 MoE with no half, sgl-project#268 guard is an exclusion list) plus fp4_utils auto never selects the fork's sm120a JIT kernel; sgl-project#287 prerequisite named: rank_gemm_scores must widen to per-(rank,family) — cheaper before sgl-project#287 than after; recommendation: phi0 lane microbench XS with stop rule <1.33, VRAM/decode case stands regardless
efschu added a commit to efschu/htsglang that referenced this pull request Jul 31, 2026
…ct#323): S3 PORTED from vLLM per prior-art directive (CT W4A4-NVFP4 scheme without Blackwell floor + marlin nvfp4 path; reciprocal handling matched vLLM exactly; documented divergences: fork per-rank backend resolver, floor 80 not 75; sglang upstream has nothing per API search); #323a modelopt_fp4_uneven_tp_block = lcm(16,32,128) spanning both kernel families (mixed-arch rig resolves different backends per rank), agrees with CT [128,128]; #323b three NVFP4 MoE classes into deny list with scheme= argument, hard error no downgrade; #323c sm120 auto picks fork JIT cutlass gated on arch AND import (sgl-project#304), named degrade; 43 new tests, quant dir 180 green; phi0 microbench + v4 boot proof prepared; flagged: German comments fused_moe_triton/layer.py 131-146
sammysun0711 added a commit to apinge/sglang that referenced this pull request Aug 14, 2026
…ct#291 (#20)

* [AMD] Fuse shared-expert sigmoid + bf16->fp32 cast into the MoE append kernel (3 kernels -> 1) (sgl-project#28658)

Signed-off-by: TianHao65 <[email protected]>

* [AMD] Port the Triton shared-expert gate fusion from zejunchen-zejun#286

Ports both commits of zejunchen-zejun#286 (cfae48f "Fused kernel
before moe", da7a0d2 "Add shared_expert_topk_fusion"), merged into the
Qwen3.5_v0.5.9 branch of that fork:

  zejunchen-zejun#286
  https://github.com/zejunchen-zejun/sglang/tree/Qwen3.5_v0.5.9

It replaces the in-kernel activation added by 1214860a4, that branch's copy
of upstream sgl-project#28658.

The shared-expert gate now runs as a standalone Triton kernel
(fused_linear_sigmoid_kernel, sigmoid(x @ w^T) on a bias-free (1, H) linear)
and its per-token output is appended to the routed top-k by
_fused_append_shared_experts_gated_kernel. Previously the raw gate logits were
streamed into _fused_append_shared_experts_with_weights_kernel, which applied
sigmoid and the 1/ep_size scale in-register on the fp32 output.

Two deviations from the upstream patch. zejunchen-zejun#286 imports
fused_append_shared_experts_gated from layers/moe/fused_moe_triton/, which does
not exist on this tree; the kernels live under
layers/moe/moe_runner/triton_utils/. The import sits in a try/except
ImportError, so taking it verbatim would silently fall back to the eager
append_shared_to_topk_ref. And it drops the 1/ep_size pre-scale that cancels
the post-experts all_reduce summing the fused shared expert ep_size times; it
is re-folded into _get_shared_expert_weights. No-op at moe_ep_size == 1.

Qwen3.5-397B-A17B-PTPC-FP8, TP=8, 8x MI308X, ROCm 7.2.0.

End-to-end, 8000 in / 500 out, concurrency 1, mean +- spread over repeat
runs:

  metric   | before          -> after           | delta
  ---------+-----------------+------------------+-------
  tok/s    | 112.41 +- 1.67  -> 112.89 +- 4.16  | +0.4%
  TPOT ms  |  8.156 +- 0.121 ->  8.115 +- 0.297 | -0.5%
  TTFT ms  |  377.8 +- 9.7   ->  392.6 +- 15.5  | +3.9%

The gate stores bf16 while topk_weights is fp32, so this port introduces a
shared_weights.to(topk_weights.dtype) conversion in
fused_append_shared_experts_gated. It is removed by the follow-up cherry-pick
of zejunchen-zejun#291.

Numerics: gate max abs error 1.952e-3 against an fp32 linear+sigmoid reference
(bf16 store rounding); append output ids exactly equal and weights
bit-identical to append_shared_to_topk_ref.

Signed-off-by: TianHao65 <[email protected]>

* Remove explicit dtype conversion in shared expert fusion (zejunchen-zejun#291)

Cherry-pick of zejunchen-zejun#291 "Remove explicit dtype conversion in
shared expert fusion", authored by Xiake Sun, merged 2026-07-10 by yixionghuo
as merge commit 3038fa5 into the Qwen3.5_v0.5.9 branch of that fork:

  zejunchen-zejun#291
  https://github.com/zejunchen-zejun/sglang/tree/Qwen3.5_v0.5.9

Built on zejunchen-zejun#290, follows zejunchen-zejun#286.

What it does:

- fused_linear_sigmoid gains an optional out_dtype, defaulting to
  hidden_states.dtype.
- fused_append_shared_experts_gated drops the host-side
  shared_weights.to(topk_weights.dtype).
- _fused_append_shared_experts_gated_kernel promotes the shared gate weight
  in-register via tl.load(...).to(ws.dtype).

Path remap: zejunchen-zejun#291 edits
python/sglang/srt/layers/moe/fused_moe_triton/fused_moe_triton_kernels.py,
which does not exist on this tree; the kernels live under
layers/moe/moe_runner/triton_utils/. Both hunks otherwise applied verbatim at
offset +269 lines. Its other commit, d2cf787 "add fused_topk", is not
carried: this branch already dispatches to aiter.fused_moe.fused_topk under
_use_aiter.

Qwen3.5-397B-A17B-PTPC-FP8, TP=8, 8x MI308X, ROCm 7.2.0.

End-to-end, 8000 in / 500 out, concurrency 1, mean +- spread over repeat
runs, measured against the same baseline as the zejunchen-zejun#286
port:

  metric   | before          -> after           | delta
  ---------+-----------------+------------------+-------
  tok/s    | 112.41 +- 1.67  -> 122.22 +- 2.27  | +8.7%
  TPOT ms  |  8.156 +- 0.121 ->  7.457 +- 0.131 | -8.6%
  TTFT ms  |  377.8 +- 9.7   ->  374.5 +- 13.2  | -0.9%

Kernel effect: the bfloat16tofloat32_copy_kernel_cuda launches that
zejunchen-zejun#286 added, 488 calls / 3236.9us on TP-0 over a 4-prompt
8000-in/10-out profile window, go to zero. A 20-iteration profile of the
append path contains no copy kernel.

Reported on the upstream PR, PTL, ISL 8K / OSL 5, concurrency 1: prefill
41.63us -> 35.14us, decode 17.98us -> 13.64us; gsm8k 0.980 over 200 questions;
QPS 0.95 -> 1.00 at concurrency 10 on ISL 8K / OSL 500.

Verified on device against the eager references: the fused kernel handle
resolves non-None; out_dtype defaults to bf16 and honours an explicit
torch.float32; append output ids are exactly equal and weights bit-identical to
append_shared_to_topk_ref with bf16 shared_weights against fp32 topk_weights,
max diff 0.000e+00. The gate still stores bf16 and no caller passes out_dtype,
so gate error against an fp32 linear+sigmoid reference is unchanged at 1.9e-3.

Signed-off-by: Xiake Sun <[email protected]>
(cherry picked from commit a953003)

Co-authored-by: TianHao65 <[email protected]>
Signed-off-by: TianHao65 <[email protected]>

---------

Signed-off-by: TianHao65 <[email protected]>
Co-authored-by: jacky.cheng <[email protected]>
Co-authored-by: TianHao65 <[email protected]>
Co-authored-by: Xiake Sun <[email protected]>
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