sgl-project/sglang · error · ValueError
Unsupported topk_mode {topk_mode}
Error message
Unsupported topk_mode {topk_mode} What it means
FlashVDMVolumeDecoding selects a cross-attention processor strategy based on topk_mode: 'mean' uses the standard FlashVDM processor, anything other than 'mean'/'merge' has no implementation, so __init__ rejects it.
Source
Thrown at python/sglang/multimodal_gen/runtime/models/vaes/hunyuan3d_vae.py:806
batch_queries = repeat(queries, "p c -> b p c", b=batch_size)
logits = geo_decoder(
queries=batch_queries.to(latents.dtype), latents=latents
)
batch_logits.append(logits)
grid_logits = torch.cat(batch_logits, dim=1)
next_logits[nidx] = grid_logits[0, ..., 0]
grid_logits = next_logits.unsqueeze(0)
grid_logits[grid_logits == -10000.0] = float("nan")
return grid_logits
class FlashVDMVolumeDecoding:
"""Flash VDM volume decoder with adaptive KV selection."""
def __init__(self, topk_mode="mean"):
if topk_mode not in ["mean", "merge"]:
raise ValueError(f"Unsupported topk_mode {topk_mode}")
if topk_mode == "mean":
self.processor = FlashVDMCrossAttentionProcessor()
else:
self.processor = FlashVDMTopMCrossAttentionProcessor()
@torch.no_grad()
def __call__(
self,
latents: torch.FloatTensor,
geo_decoder: CrossAttentionDecoder,
bounds: Union[Tuple[float], List[float], float] = 1.01,
num_chunks: int = 10000,
mc_level: float = 0.0,
octree_resolution: int = None,
min_resolution: int = 63,
mini_grid_num: int = 4,
enable_pbar: bool = True,View on GitHub (pinned to 0132848349)
Solutions
- Use topk_mode='mean' (FlashVDMCrossAttentionProcessor) or 'merge' (FlashVDMTopMCrossAttentionProcessor)
- Strip/normalize the config string (whitespace, casing) before passing it
- Upgrade if you need an additional mode added in a newer version
Example fix
# before dec = FlashVDMVolumeDecoding(topk_mode="max") # after dec = FlashVDMVolumeDecoding(topk_mode="mean")
Defensive patterns
Strategy: validation
Validate before calling
mode = str(topk_mode).strip().lower()
if mode not in ("mean", "merge"):
mode = "mean"
dec = FlashVDMVolumeDecoding(topk_mode=mode) Type guard
def is_valid_topk_mode(m: str) -> bool:
return str(m).strip().lower() in ("mean", "merge") Prevention
- Normalize config strings (strip/lower) before passing enum-like values
- Keep an enum literal in your config layer instead of free-form strings
When it happens
Trigger: Constructing FlashVDMVolumeDecoding(topk_mode='max'), 'topk', 'sum', or any string other than 'mean'/'merge'; commonly from a config key typed incorrectly or from a newer spec introducing an unimplemented mode.
Common situations: YAML/config typo (e.g. 'mean '** with trailing space, or wrong case 'Mean'); porting settings from another FlashVDM implementation that supports more modes; version lag where the mode exists upstream but not here.
Related errors
- Unsupported mc_algo {mc_algo}, available: {list(SurfaceExtra
- Invalid threshold_type for topk: {threshold_type}. Choose 'q
- Invalid threshold_type: {threshold_type}. Choose 'query_head
- Unsupported scale {scale}. Choose from {list(mapping.keys())
- Either spatial_upsample or temporal_upsample must be True
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/9ff606cd71bf7649.
Report an issue: GitHub.