sgl-project/sglang · critical · RuntimeError

LPLB fused solver unavailable: {_unavailable_reason()}

Error message

LPLB fused solver unavailable: {_unavailable_reason()}

What it means

warmup for the LPLB fused solver tries to lazily initialize the fused backend (tvm_ffi/CUDA module) and raises if that backend could not be imported or compiled. _unavailable_reason() carries the underlying cause (missing wheel, no CUDA, JIT compile failure). It fires before any GPU work, during the warmup that pre-pays the 20-40s JIT cost.

Source

Thrown at python/sglang/kernels/ops/lplb/torch_solver.py:93

    if cap[0] < 9:
        return f"GPU SM {cap[0]}.{cap[1]} < 9.0 (requires Hopper or newer)"
    return (
        "Math-DX cuBLASDx headers not found — install via "
        "`pip install nvidia-mathdx` or set MATHDX_HOME"
    )


def warmup(nc: int, nv: int, num_iters: int = 5, device: str = "cuda") -> None:
    """Pre-JIT-compile the fused kernel for a given (NC, NV) shape.

    Call once per unique shape at solver construction time to hide the
    20-40s JIT compilation cost. Raises if the fused backend is
    unavailable, the shape exceeds the shmem budget, or the kernel
    fails to compile/launch.
    """
    _init_fused_backend()
    if not _FUSED_AVAILABLE:
        raise RuntimeError(f"LPLB fused solver unavailable: {_unavailable_reason()}")
    _FUSED_ASSERT_FITS(nc, nv, gpu="h100")
    _FUSED_WARMUP(nc, nv, num_iters=num_iters, device=device)


def solve_ipm(
    A: torch.Tensor,
    b: torch.Tensor,
    c: torch.Tensor,
    num_iters: int = 5,
) -> torch.Tensor:
    """Barrier-method Interior Point solver for standard-form LP.

    Dispatches to the JIT-compiled CUDA C++ kernel (Hopper+ GPU with
    Math-DX cuBLASDx headers, reachable via ``nvidia-mathdx`` PyPI
    package or ``MATHDX_HOME``). Raises if the fused backend is
    unavailable or the inputs aren't on CUDA in float32.

    Args:

View on GitHub (pinned to 0132848349)

Solutions

  1. Read _unavailable_reason() output and fix the root cause (usually pip install the missing kernels wheel or fix CUDA_HOME/nvcc)
  2. Verify torch.cuda.is_available() and the GPU arch is supported before warmup
  3. Fall back to solve_ipm_torch_reference on machines where the fused backend cannot be provisioned

Example fix

// before
warmup(nc, nv)

// after
try:
    warmup(nc, nv)
except RuntimeError:
    use_fused = False  # route to solve_ipm_torch_reference
Defensive patterns

Strategy: fallback

Validate before calling

from sglang.kernels.ops.lplb.torch_solver import _FUSED_AVAILABLE
if not _FUSED_AVAILABLE:
    plan = 'torch_reference'

Try / catch

try:
    warmup(nc, nv)
except RuntimeError as e:
    if 'unavailable' in str(e):
        fallback_to_reference = True
    else:
        raise

Prevention

When it happens

Trigger: Calling warmup(nc, nv, ...) when the fused extension is not importable in the current environment (missing sglang kernel wheel, no CUDA toolchain for JIT, wrong arch).

Common situations: CPU-only CI machines; a broken/incomplete install of sglang-kernels; CUDA arch mismatch preventing JIT compilation; first use in a container without nvcc.

Related errors


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