sgl-project/sglang · error · ImportError

Quant-VideoGen KV-cache quantization requires its optional r

Error message

Quant-VideoGen KV-cache quantization requires its optional runtime dependencies. Install them with: pip install 'sglang[diffusion-qvg]' && pip install --no-deps quant-videogen==0.1.0.

What it means

QVG-packed quantized KV cache lazily imports triton_prq_quantize_tensor/triton_prq_dequantize_tensor from quant_videogen. If that optional package (or its functions module) is absent, this ImportError tells you exactly how to install the extras.

Source

Thrown at python/sglang/multimodal_gen/runtime/layers/kvcache/qvg_packed_cache.py:49

from sglang.multimodal_gen.configs.quantization.qvg_kv import QVGKVQuantArgs
from sglang.multimodal_gen.runtime.layers.kvcache.causal_attention_cache import (
    CausalAttentionKVView,
)
from sglang.multimodal_gen.runtime.utils.logging_utils import init_logger

logger = init_logger(__name__)


@cache
def _qvg_functions():
    try:
        from quant_videogen.functions import (
            triton_prq_dequantize_tensor,
            triton_prq_quantize_tensor,
        )
    except ImportError as e:
        raise ImportError(
            "Quant-VideoGen KV-cache quantization requires its optional "
            "runtime dependencies. Install them with: "
            "pip install 'sglang[diffusion-qvg]' && "
            "pip install --no-deps quant-videogen==0.1.0."
        ) from e
    return triton_prq_quantize_tensor, triton_prq_dequantize_tensor


@dataclass
class _Segment:
    g0: int  # global start token (inclusive)
    g1: int  # global end token (exclusive)
    is_sink: bool  # sink segments are never evicted
    k: torch.Tensor | None = None
    v: torch.Tensor | None = None
    packed_k: dict | None = None
    packed_v: dict | None = None

View on GitHub (pinned to 0132848349)

Solutions

  1. pip install 'sglang[diffusion-qvg]'
  2. pip install --no-deps quant-videogen==0.1.0
  3. Verify with: python -c "from quant_videogen.functions import triton_prq_quantize_tensor"
  4. If you don't need packed KV quant, disable it and use the bf16 packed cache

Example fix

# before: ImportError at runtime
# after
pip install 'sglang[diffusion-qvg]' && pip install --no-deps quant-videogen==0.1.0
Defensive patterns

Strategy: fallback

Validate before calling

try:\n    from quant_videogen.functions import triton_prq_quantize_tensor  # noqa
    qvg_available = True
except ImportError:
    qvg_available = False

Try / catch

try:\n    cache = QVGPackedCausalKVCache(..., quant=True)\nexcept ImportError:\n    cache = PackedCausalKVCache(...)  # bf16 fallback

Prevention

When it happens

Trigger: Constructing or running QVGPackedCausalKVCache with quantization enabled (invokes _pack/_dequant -> _qvg_functions) when `import quant_videogen.functions` fails.

Common situations: Base sglang install without the diffusion-qvg extra; quant-videogen installed with conflicting deps so --no-deps is required; version drift where quant-videogen != 0.1.0 lacks the functions module.

Related errors


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