sgl-project/sglang · error · ValueError
Sparse Video Gen 2 attention does not support causal attenti
Error message
Sparse Video Gen 2 attention does not support causal attention
What it means
SparseVideoGen2AttentionImpl is a bidirectional (non-causal) attention used in video DiT backbones. Its constructor explicitly rejects causal=True because the SVG2 kernel/metadata only supports full (non-causal) attention over tokens.
Source
Thrown at python/sglang/multimodal_gen/runtime/layers/attention/backends/sparse_video_gen_2_attn.py:195
frame_size=frame_size,
cache=cache,
)
class SparseVideoGen2AttentionImpl(AttentionImpl):
def __init__(
self,
num_heads: int,
head_size: int,
causal: bool,
softmax_scale: float,
num_kv_heads: int | None = None,
prefix: str = "",
**extra_impl_args,
) -> None:
if causal:
raise ValueError(
"Sparse Video Gen 2 attention does not support causal attention"
)
if not svg2_available:
raise ImportError(
"Sparse Video Gen 2 attention backend requires svg package to be installed"
"Please install it by following the instructions at "
"https://github.com/svg-project/Sparse-VideoGen"
)
self.prefix = prefix
self.layer_idx = self._get_layer_idx(prefix)
def _get_layer_idx(self, prefix: str) -> int:
parts = prefix.split(".")
if len(parts) < 3:
raise ValueError(
f"Invalid prefix for SparseVideoGen2AttentionImpl: {prefix}"
)
return int(parts[-3])View on GitHub (pinned to 0132848349)
Solutions
- Pass causal=False (or omit the causal flag) when instantiating this backend — video DiT blocks are bidirectional.
- In a shared factory, only select the SVG2 backend for non-causal layers and route causal layers to a flash/fa3-style backend.
- Audit the layer config that forwards the causal flag and correct it for the video backbone.
Example fix
# before impl = SparseVideoGen2AttentionImpl(..., causal=True, ...) # after impl = SparseVideoGen2AttentionImpl(..., causal=False, ...)
Defensive patterns
Strategy: validation
Validate before calling
assert not causal, "SVG2 attention is bidirectional only" impl = SparseVideoGen2AttentionImpl(..., causal=False, ...)
Prevention
- In attention factories, route causal layers away from SVG2 explicitly.
- Keep video-DiT layer configs separate from text LM configs.
- Add a unit test asserting the backend is only created with causal=False.
When it happens
Trigger: Constructing SparseVideoGen2AttentionImpl with causal=True — typically because a generic attention factory passes the model's causal flag through to every backend, or a config copied from a causal LM/text model.
Common situations: Wiring the SVG2 backend into a shared attention-creation path that defaults causal=True for most layers; using a text-model attention config template for a video DiT; misunderstanding that DiT double/single-stream blocks use bidirectional attention.
Related errors
- {selection_error}{component_suffix}
- Attention backend name must be a string
- Invalid attention backend '{backend}'. Available options are
- component_attention_backends must be a dict or a comma-separ
- component_attention_backends must use component=backend entr
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/86c4f4d05d229bff.
Report an issue: GitHub.