sgl-project/sglang · error · RuntimeError

SANA-WM Triton GDN backend unavailable: {reason}

Error message

SANA-WM Triton GDN backend unavailable: {reason}

What it means

When gdn_backend='triton' is explicitly forced, any failed precheck for the fused Triton GDN kernel (shape/dtype/CUDA/eval-mode constraints) raises this RuntimeError instead of silently falling back to torch. 'auto' would return None and fall back.

Source

Thrown at python/sglang/multimodal_gen/runtime/models/dits/sana_wm_components.py:2136

        tables = prepare_rope_tables(rotary_emb, N, head_dim, device)
        self._triton_rope_tables_cache = (key, tables)
        return tables

    def _maybe_main_branch_triton_gdn(
        self,
        qkv: torch.Tensor,
        beta: torch.Tensor,
        decay: torch.Tensor,
        HW: Tuple[int, int, int],
        rotary_emb: Optional[torch.Tensor],
    ) -> Optional[torch.Tensor]:
        global _SANA_WM_TRITON_GDN_DISABLED_REASON

        reason = self._triton_gdn_unavailable_reason(qkv, beta, decay, HW)
        if reason is not None:
            if self.gdn_backend == "triton":
                raise RuntimeError(f"SANA-WM Triton GDN backend unavailable: {reason}")
            return None

        try:
            from sglang.kernels.ops.diffusion import (
                fused_bigdn_func,
                fused_qk_inv_rms,
                prepare_rope_tables,
            )

            B, N, _, heads, head_dim = qkv.shape
            T, H_sp, W_sp = HW
            S = H_sp * W_sp
            q_norm_weight, k_norm_weight = self._get_triton_norm_weights()
            norm_eps = float(getattr(self.q_norm, "eps", 1e-5))
            q_inv_rms, k_inv_rms = fused_qk_inv_rms(qkv, eps=norm_eps)
            rope_cos, rope_sin = self._get_triton_rope_tables(
                prepare_rope_tables,
                rotary_emb,

View on GitHub (pinned to 0132848349)

Solutions

  1. Switch to gdn_backend='auto' so unsupported cases fall back to the torch path
  2. Run under torch.no_grad()/eval; ensure tensors are CUDA and dtypes match kernel requirements
  3. If the kernel is truly required, reshape/broadcast inputs to the supported configuration and verify sglang.kernels.ops.diffusion imports

Example fix

# before
block = GDNBlock(dim, update_rule="torch_chunk", gdn_backend="triton")
# after
block = GDNBlock(dim, update_rule="torch_chunk", gdn_backend="auto")
Defensive patterns

Strategy: fallback

Validate before calling

use gdn_backend="auto" so precheck failures fall back to torch instead of raising

Try / catch

try:
    out = block(...)
except RuntimeError as e:
    if "Triton GDN backend unavailable" in str(e):
        block.gdn_backend = "auto"; out = block(...)
    else: raise

Prevention

When it happens

Trigger: Setting gdn_backend='triton' and calling the GDN forward with inputs failing _triton_gdn_unavailable_reason: non-CUDA tensors, grad-enabled mode, unsupported head dims/dtypes, or missing sglang.kernels.ops.diffusion fused ops.

Common situations: Forcing triton under torch.compile or autograd; running on CPU; kernel package built without the diffusion Triton ops; batch/head-dim combination outside the kernel's supported set.

Related errors


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