sgl-project/sglang · error · ImportError
Can't import trtllm_fp8_block_scale_routed_moe from…
Error message
Can't import trtllm_fp8_block_scale_routed_moe from flashinfer. Please check flashinfer version.
What it means
Lazy import of trtllm_fp8_block_scale_routed_moe from flashinfer.fused_moe failed. This routed variant of the TRT-LLM fp8 block-scale MoE kernel likewise requires a recent flashinfer version; older releases don't export it.
Solutions
- Upgrade flashinfer to a version exporting trtllm_fp8_block_scale_routed_moe
- Test the import directly: python -c "from flashinfer.fused_moe import trtllm_fp8_block_scale_routed_moe"
- Reinstall flashinfer matched to your torch/CUDA build if the import fails due to extension loading
- Disable the routed trtllm path or use the triton fallback backend
Example fix
# before pip install flashinfer-python==0.1.* # after pip install -U flashinfer-python python -c "from flashinfer.fused_moe import trtllm_fp8_block_scale_routed_moe"
Defensive patterns
Strategy: fallback
Validate before calling
try:
from flashinfer.fused_moe import trtllm_fp8_block_scale_routed_moe # noqa
HAS_ROUTED = True
except ImportError:
HAS_ROUTED = False
if not HAS_ROUTED:
raise RuntimeError('flashinfer lacks routed trtllm fp8 MoE; upgrade flashinfer') Try / catch
try:
trtllm_fp8_block_scale_routed_moe_out_wrapper(...)
except ImportError as e:
if 'trtllm_fp8_block_scale_routed_moe' in str(e):
disable_routed_path_or_use_triton()
else:
raise Prevention
- Upgrade flashinfer together with sglang upgrades
- Verify new flashinfer symbols in CI before enabling the routed path
When it happens
Trigger: Calling trtllm_fp8_block_scale_routed_moe_out_wrapper (routed path of fused_experts_none_to_flashinfer_trtllm_fp8) on a flashinfer build without the symbol.
Common situations: Same as the non-routed variant: stale flashinfer pin, broken compiled extension import, or a nightly-vs-stable API difference.
Understand the failure class
Background: "X is not installed. Please install it with pip install Y": missing optional dependency errors — ImportError/ValueError raised when a library's optional extra was never installed — this error's family across 22 libraries.
Related errors
- Can't import trtllm_fp8_block_scale_moe from flashinfer…
- aiter is required when SGLANG_USE_AITER is set to True
- CuteDSL masked MoE supports activation 'silu' (gated) or…
- DeepEP is not installed. Please install DeepEP package from…
- DeepEP returned FP8 input while Humming is configured for…
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/900ab15000b0c35e.
Report an issue: GitHub.
Appendix: source
Thrown at python/sglang/srt/layers/moe/flashinfer_trtllm_moe.py:189
n_group: Optional[int],
topk_group: Optional[int],
intermediate_size: int,
local_expert_offset: int,
local_num_experts: int,
routed_scaling_factor: Optional[float],
output: torch.Tensor,
routing_method_type: int = 0,
use_shuffled_weight: bool = False,
weight_layout: int = 0,
enable_pdl: Optional[bool] = None,
tune_max_num_tokens: int = 8192,
fp8_quantization_type: Optional[int] = None,
activation_type: Optional[int] = None,
) -> None:
try:
from flashinfer.fused_moe import trtllm_fp8_block_scale_routed_moe
except ImportError as e:
raise ImportError(
"Can't import trtllm_fp8_block_scale_routed_moe from flashinfer. "
"Please check flashinfer version."
) from e
kwargs = {
"topk_ids": topk_ids,
"routing_bias": routing_bias,
"hidden_states": hidden_states,
"hidden_states_scale": hidden_states_scale,
"gemm1_weights": gemm1_weights,
"gemm1_weights_scale": gemm1_weights_scale,
"gemm1_alpha": gemm1_alpha,
"gemm1_beta": gemm1_beta,
"gemm1_clamp_limit": gemm1_clamp_limit,
"gemm2_weights": gemm2_weights,
"gemm2_weights_scale": gemm2_weights_scale,
"output": output,
"num_experts": num_experts,View on GitHub (pinned to 0132848349)