sgl-project/sglang · error · ValueError

plucker_emb token count {plucker_emb.shape[1]} != latent tok

Error message

plucker_emb token count {plucker_emb.shape[1]} != latent token count {latent_token_count}; expected chunk_plucker shape (B, 48, T, H, W).

What it means

During SANA-WM streaming forward, the Plücker camera embedding produced by plucker_embedder must have exactly as many tokens as the latent. The chunk_plucker input is expected shaped (B, 48, T, H, W) matching the latent's temporal/spatial token grid; if not, the token counts diverge and this ValueError is raised.

Source

Thrown at python/sglang/multimodal_gen/runtime/models/dits/sana_wm.py:598

        weight = self.plucker_embedder.proj.weight
        bias = self.plucker_embedder.proj.bias
        key = (
            "plucker_emb",
            latent_token_count,
            self.patch_size,
            _tensor_cache_key(chunk_plucker),
            _tensor_cache_key(weight),
            None if bias is None else _tensor_cache_key(bias),
        )
        if not torch.is_grad_enabled():
            cached = self._plucker_emb_cache
            if cached is not None and cached[0] == key:
                return cached[2]

        plucker_emb = self.plucker_embedder(chunk_plucker.to(weight.dtype))
        if plucker_emb.shape[1] != latent_token_count:
            raise ValueError(
                f"plucker_emb token count {plucker_emb.shape[1]} != "
                f"latent token count {latent_token_count}; "
                "expected chunk_plucker shape (B, 48, T, H, W)."
            )

        if not torch.is_grad_enabled():
            self._plucker_emb_cache = (key, chunk_plucker, plucker_emb)
        return plucker_emb

    def forward(
        self,
        hidden_states: torch.Tensor,
        encoder_hidden_states: Optional[torch.Tensor] = None,
        timestep: Optional[torch.Tensor] = None,
        encoder_attention_mask: Optional[torch.Tensor] = None,
        camera_conditions: Optional[torch.Tensor] = None,
        chunk_plucker: Optional[torch.Tensor] = None,
        guidance: Optional[torch.Tensor] = None,  # kept for compat

View on GitHub (pinned to 0132848349)

Solutions

  1. Check chunk_plucker.shape == (B, 48, T_latent, H_latent, W_latent) where T/H/W are the latent dims (hidden_states dims divided by patch_size)
  2. Resample/sample camera Plücker rays at the latent grid, not the pixel grid
  3. If using forward_long, slice chunk_plucker to the chunk's global frame range [start_f, end_f)

Example fix

# before
out = model(h, t, ehs, chunk_plucker=plucker_full)
# after
T_lat, H_lat, W_lat = T//p_t, H//p_h, W//p_w
assert plucker_full.shape == (B, 48, T_lat, H_lat, W_lat)
out = model(h, t, ehs, chunk_plucker=plucker_full)
Defensive patterns

Strategy: validation

Validate before calling

T, H, W = h.shape[2]//p_t, h.shape[3]//p_h, h.shape[4]//p_w
assert chunk_plucker.shape == (B, 48, T, H, W), chunk_plucker.shape

Prevention

When it happens

Trigger: Calling forward/forward_long with chunk_plucker whose T/H/W does not match the latent (after patchification) — e.g. wrong spatial resolution, missing frame downsampling, or wrong number of Plücker channels causing the embedder to produce a different token count.

Common situations: Feeding camera rays sampled at pixel resolution instead of latent resolution; mixing checkpoints with different patch_size; passing a full-length plucker tensor to a chunked forward_long call.

Related errors


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