sgl-project/sglang · error · ValueError

SANA-WM camera_conditions must be sampled at latent frames:

Error message

SANA-WM camera_conditions must be sampled at latent frames: got {camera_conditions.shape[1]} frames, expected T={T}.

What it means

The camera conditioning (intrinsics/extrinsics for UCPE) must have exactly T entries, one per latent frame, where T = T_raw // patch_size_t. Pixel-frame or wrong-frame-count camera parameters fail this check.

Source

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

            encoder_attention_mask = encoder_attention_mask[0]
        y = encoder_hidden_states
        if y.dim() == 3:
            y = y.unsqueeze(1)
        y = self.y_embedder(y).squeeze(1)  # (B, L, D)
        if y.shape[0] != B:
            y = y.expand(B, -1, -1).contiguous()
        if self.y_norm:
            y = self.attention_y_norm(y)
        if encoder_attention_mask is not None and encoder_attention_mask.shape[0] != B:
            encoder_attention_mask = encoder_attention_mask.expand(B, -1).contiguous()

        freqs = self._get_freqs(T, H, W, x.device)

        # Camera conditioning: UCPE prope_fns + Plücker
        prope_fns = None
        if camera_conditions is not None:
            if camera_conditions.shape[1] != T:
                raise ValueError(
                    "SANA-WM camera_conditions must be sampled at latent "
                    f"frames: got {camera_conditions.shape[1]} frames, "
                    f"expected T={T}."
                )
            prope_fns = self._get_ucpe_apply_fns(
                camera_conditions,
                HW=(T, H, W),
                freqs=freqs,
            )

        # Plücker post-attn embedding (shared across all blocks)
        plucker_emb = None
        needs_plucker_emb = (
            chunk_plucker is not None
            and self.plucker_embedder is not None
            and (self.use_chunk_plucker_post_attn or self.use_chunk_plucker_input)
        )
        if needs_plucker_emb:

View on GitHub (pinned to 0132848349)

Solutions

  1. Resample camera_conditions to one entry per latent frame: index every p_t-th frame
  2. Verify hidden_states.shape[2] // patch_size[0] equals camera_conditions.shape[1]
  3. Check the model config's patch_size_t matches your camera sampling assumption

Example fix

# before
cam = cameras  # (B, T_raw, ...)
out = model(h, t, ehs, camera_conditions=cam)
# after
p_t = model.patch_size[0]
cam = cameras[:, ::p_t]  # (B, T, ...)
assert cam.shape[1] == h.shape[2] // p_t
out = model(h, t, ehs, camera_conditions=cam)
Defensive patterns

Strategy: validation

Validate before calling

T = h.shape[2] // model.patch_size[0]
if camera_conditions is not None:
    assert camera_conditions.shape[1] == T, (camera_conditions.shape, T)

Prevention

When it happens

Trigger: Passing camera_conditions with shape[1] != T — e.g. cameras sampled at every pixel frame (T_raw) instead of temporal-patch-downsampled latent frames, or a single camera for a multi-frame latent.

Common situations: Reusing dataset camera trajectories at video frame rate; mismatch between video temporal patch size (e.g. 1x vs 2x compression) and camera sampling rate.

Related errors


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