sgl-project/sglang · error · AttributeError
module {__name__!r} has no attribute {name!r}
Error message
module {__name__!r} has no attribute {name!r} What it means
The diffusion package uses PEP 562 lazy imports: its __getattr__ resolves public names listed in _EXPORTS to their defining submodule on first access. If the requested attribute is not in _EXPORTS at all, it raises a plain AttributeError (module has no attribute), which for `from ... import x` surfaces as ImportError.
Source
Thrown at python/sglang/kernels/ops/diffusion/__init__.py:495
"unmount_lingbot_video_rmsnorm": "sites.lingbot_video_rmsnorm_site",
"mark_sana_video_linear_attention_site": "sites.sana_video_linear_attention_site",
"mount_sana_video_linear_attention": "sites.sana_video_linear_attention_site",
"sana_video_linear_attention_active": "sites.sana_video_linear_attention_site",
"try_sana_video_linear_attention": "sites.sana_video_linear_attention_site",
"unmount_sana_video_linear_attention": "sites.sana_video_linear_attention_site",
"QualityGatedFusion": "sites.quality_gate",
# JIT C++/CUDA extensions (not kernels, not in the registry)
"interpolate": "ext.hunyuan3d_rasterizer",
"rasterize": "ext.hunyuan3d_rasterizer",
"meshVerticeInpaint": "ext.mesh_processor",
}
def __getattr__(name: str) -> Any:
"""Resolve a public symbol to its submodule on first access (PEP 562)."""
module = _EXPORTS.get(name)
if module is None:
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
from importlib import import_module
value = getattr(import_module(f"{__name__}.{module}"), name)
globals()[name] = value # cache; later lookups skip __getattr__ entirely
return value
def __dir__() -> list[str]:
return sorted(set(globals()) | set(_EXPORTS))
__all__ = sorted(_EXPORTS)
View on GitHub (pinned to 0132848349)
Solutions
- Check the package's _EXPORTS mapping (or its __all__) for the exact public name
- Update sglang if the symbol was renamed — consult the module's changelog
- Import the internal helper from its concrete submodule path if you truly need it
Example fix
# before from sglang.kernels.ops.diffusion import fused_bias_sliu # typo # after from sglang.kernels.ops.diffusion import fused_bias_silu
Defensive patterns
Strategy: validation
Validate before calling
from sglang.kernels.ops import diffusion
assert hasattr(diffusion, name), f'{name} not exported; check diffusion._EXPORTS' Type guard
def diffusion_exports(name: str) -> bool:
from sglang.kernels.ops.diffusion import _EXPORTS
return name in _EXPORTS Prevention
- Import public symbols from the package, not private submodules
- After upgrading sglang, grep _EXPORTS for renamed symbols
When it happens
Trigger: Accessing sglang.kernels.ops.diffusion.<name> where <name> is a typo (e.g. `fused_bias_sliu`) or a private/internal symbol never registered in _EXPORTS.
Common situations: IDE autocompletion guessing wrong names, using a symbol renamed between sglang versions, or trying to reach a helper function that was never exported.
Related errors
- module {__name__!r} has no attribute {name!r}
- Unsupported content type ${header.content_type}
- module {__name__!r} has no attribute {name!r}
- unsupported input for Sana fused bias-SiLU
- unsupported input for Sana fused bias-GLU
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/b6f92e12e4462be9.
Report an issue: GitHub.