{"record":{"id":"711a0ccb27249386","repo":"sgl-project/sglang","slug":"plucker-emb-token-count-plucker-emb-shape-1","errorCode":null,"errorMessage":"plucker_emb token count {plucker_emb.shape[1]} != latent token count {latent_token_count}; expected chunk_plucker shape (B, 48, T, H, W).","messagePattern":"plucker_emb token count (.+?) != latent token count (.+?); expected chunk_plucker shape \\(B, 48, T, H, W\\)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/models/dits/sana_wm.py","lineNumber":598,"sourceCode":"\n        weight = self.plucker_embedder.proj.weight\n        bias = self.plucker_embedder.proj.bias\n        key = (\n            \"plucker_emb\",\n            latent_token_count,\n            self.patch_size,\n            _tensor_cache_key(chunk_plucker),\n            _tensor_cache_key(weight),\n            None if bias is None else _tensor_cache_key(bias),\n        )\n        if not torch.is_grad_enabled():\n            cached = self._plucker_emb_cache\n            if cached is not None and cached[0] == key:\n                return cached[2]\n\n        plucker_emb = self.plucker_embedder(chunk_plucker.to(weight.dtype))\n        if plucker_emb.shape[1] != latent_token_count:\n            raise ValueError(\n                f\"plucker_emb token count {plucker_emb.shape[1]} != \"\n                f\"latent token count {latent_token_count}; \"\n                \"expected chunk_plucker shape (B, 48, T, H, W).\"\n            )\n\n        if not torch.is_grad_enabled():\n            self._plucker_emb_cache = (key, chunk_plucker, plucker_emb)\n        return plucker_emb\n\n    def forward(\n        self,\n        hidden_states: torch.Tensor,\n        encoder_hidden_states: Optional[torch.Tensor] = None,\n        timestep: Optional[torch.Tensor] = None,\n        encoder_attention_mask: Optional[torch.Tensor] = None,\n        camera_conditions: Optional[torch.Tensor] = None,\n        chunk_plucker: Optional[torch.Tensor] = None,\n        guidance: Optional[torch.Tensor] = None,  # kept for compat","sourceCodeStart":580,"sourceCodeEnd":616,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/models/dits/sana_wm.py#L580-L616","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["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)","Resample/sample camera Plücker rays at the latent grid, not the pixel grid","If using forward_long, slice chunk_plucker to the chunk's global frame range [start_f, end_f)"],"exampleFix":"# before\nout = model(h, t, ehs, chunk_plucker=plucker_full)\n# after\nT_lat, H_lat, W_lat = T//p_t, H//p_h, W//p_w\nassert plucker_full.shape == (B, 48, T_lat, H_lat, W_lat)\nout = model(h, t, ehs, chunk_plucker=plucker_full)","handlingStrategy":"validation","validationCode":"T, H, W = h.shape[2]//p_t, h.shape[3]//p_h, h.shape[4]//p_w\nassert chunk_plucker.shape == (B, 48, T, H, W), chunk_plucker.shape","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Compute latent grid dims from patch_size before building Plücker rays","Keep a single helper that returns (latent, plucker) guaranteed shape-aligned"],"tags":["sana-wm","shape-mismatch","camera-embedding","validation"],"backgroundTag":"tensor-shape-mismatch","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}