sgl-project/sglang · error · ValueError

CuteDSL masked MoE supports activation 'silu' (gated) or 're

Error message

CuteDSL masked MoE supports activation 'silu' (gated) or 'relu2' (non-gated), got {activation!r}.

What it means

flashinfer_cutedsl_moe_masked only supports activation='silu' (gated MoE, w1 has 2*n rows) or 'relu2' (non-gated, single n-row projection). Any other activation string is rejected before building the GEMM shapes.

Source

Thrown at python/sglang/srt/layers/moe/flashinfer_cutedsl_moe.py:112

        assert (
            input_global_scale.dtype == torch.float32
        ), f"input_global_scale must be float32, got {input_global_scale.dtype}"
        assert input_global_scale.shape == (
            num_experts,
        ), f"input_global_scale must be (l,), got {input_global_scale.shape}"

        a_q, a_q_sf = scaled_fp4_grouped_quantize(
            hidden_states[0],
            masked_m,
            input_global_scale,
        )

    if activation == "silu":
        gated = True
    elif activation == "relu2":
        gated = False
    else:
        raise ValueError(
            f"CuteDSL masked MoE supports activation 'silu' (gated) or "
            f"'relu2' (non-gated), got {activation!r}."
        )
    # Gated (silu_and_mul) GEMM1 emits [gate, up] so w1 has 2*n rows; non-gated
    # relu2 emits a single projection of n rows.
    gemm1_out_dim = 2 * n if gated else n
    assert (
        w1.shape[-2] == gemm1_out_dim
    ), f"w1 last-2 dim must be {gemm1_out_dim} (gated={gated}), got {w1.shape}"
    assert (
        w1.shape[-1] * 2 == k
    ), f"w1 last dim * 2 must equal k, got {w1.shape[-1]} vs k={k}"
    assert w2.shape[-2:] == (
        k,
        n // 2,
    ), f"w2 shape mismatch, got {w2.shape[-2:]}, expected {(k, n//2)}"
    assert w1_alpha.shape == (
        num_experts,

View on GitHub (pinned to 0132848349)

Solutions

  1. Map your model's activation to 'silu' or 'relu2' if semantically equivalent; otherwise route the model to a different MoE backend (e.g. triton fused MoE)
  2. Check for a typo: pass the exact strings 'silu' or 'relu2'
  3. If the model genuinely needs gelu, add support in the wrapper or disable the cutedsl path for that model

Example fix

// before
flashinfer_cutedsl_moe_masked(..., activation='gelu_sigmoid')
// after
flashinfer_cutedsl_moe_masked(..., activation='silu')  # if model uses SiLU-gating
# or route model to triton backend for unsupported activations
Defensive patterns

Strategy: validation

Validate before calling

if activation not in ('silu', 'relu2'):
    raise ValueError(f'model activation {activation!r} unsupported by cutedsl MoE; use triton backend')

Type guard

def cutedsl_supported_activation(a: str) -> bool:
    return a in ('silu', 'relu2')

Prevention

When it happens

Trigger: Passing activation='gelu', 'gelu_sigmoid' (GeGLU), 'silu_and_mul', or any string other than the two supported ones; typically propagated from a model config's hidden_act field.

Common situations: Wiring a new model whose config.hidden_act is e.g. gelu_new into the FlashInfer CuteDSL MoE path without an activation translation layer.

Related errors


AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28). Data as JSON: /api/errors/b0a8d954b5d90517. Report an issue: GitHub.