{"record":{"id":"e8cc133414d058b7","repo":"sgl-project/sglang","slug":"camera-conditions-must-have-shape-t-20-or-b-t-2","errorCode":null,"errorMessage":"camera_conditions must have shape (T,20) or (B,T,20), got {tuple(camera_conditions.shape)}","messagePattern":"camera_conditions must have shape \\(T,20\\) or \\(B,T,20\\), got (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/sana_wm/base.py","lineNumber":1875,"sourceCode":"            or getattr(arch, \"use_chunk_plucker_input\", False)\n        )\n        if action is not None and (\n            camera_conditions is not None or chunk_plucker is not None\n        ):\n            raise ValueError(\n                \"SANA-WM action cannot be combined with prepacked \"\n                \"camera_conditions/chunk_plucker.\"\n            )\n        if camera_conditions is not None:\n            camera_conditions = (\n                camera_conditions\n                if isinstance(camera_conditions, torch.Tensor)\n                else torch.as_tensor(camera_conditions)\n            ).to(device=device, dtype=camera_compute_dtype)\n            if camera_conditions.dim() == 2:\n                camera_conditions = camera_conditions.unsqueeze(0)\n            if camera_conditions.dim() != 3:\n                raise ValueError(\n                    \"camera_conditions must have shape (T,20) or (B,T,20), \"\n                    f\"got {tuple(camera_conditions.shape)}\"\n                )\n            if camera_conditions.shape[0] == 1 and batch_size > 1:\n                camera_conditions = camera_conditions.expand(batch_size, -1, -1)\n            if camera_conditions.shape[0] != batch_size:\n                raise ValueError(\n                    \"camera_conditions batch dimension must be 1 or match \"\n                    f\"request batch size {batch_size}, got \"\n                    f\"{camera_conditions.shape[0]}.\"\n                )\n            if camera_conditions.shape[-1] != 20:\n                raise ValueError(\n                    \"camera_conditions must have last dimension 20, got \"\n                    f\"{tuple(camera_conditions.shape)}\"\n                )\n            if camera_conditions.shape[1] == T_lat:\n                source = \"prepacked\"","sourceCodeStart":1857,"sourceCodeEnd":1893,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/sana_wm/base.py#L1857-L1893","documentation":"SANA-WM video generation stage validates the camera_conditions tensor in _build_camera_conditioning. After converting to a tensor and unsqueezing a 2-D input, it requires exactly 3 dimensions: (B, T, 20). A 1-D, 4-D, or higher-rank input raises this ValueError.","triggerScenarios":"Passing camera_conditions as a flat vector (e.g. shape (20,)), a 4-D tensor (B, T, F, 20), or any rank other than 2 or 3 to the SANA-WM forward via diffusers_kwargs['camera_conditions']. A shape-(T,20) input is fine; anything else is not.","commonSituations":"Users porting diffusers camera-conditioned pipelines where camera arrays were nested per-frame lists (producing 4-D), or accidentally passing a single frame's 20-vector instead of a sequence.","solutions":["Reshape camera_conditions to (T,20) (single request) or (B,T,20) (batched), e.g. cond.unsqueeze(0) for an unbatched path.","If frames were nested per-key, flatten the last dims so each timestep is one 20-vector.","Print camera_conditions.shape right before calling forward to confirm rank."],"exampleFix":"# before\ncamera_conditions = intrinsics_20  # shape (20,)\n# after\ncamera_conditions = intrinsics_20.unsqueeze(0)  # shape (1,20)","handlingStrategy":"validation","validationCode":"def check_camera_conditions(cc, batch_size):\n    t = cc if isinstance(cc, torch.Tensor) else torch.as_tensor(cc)\n    assert t.dim() in (2, 3), f\"need (T,20) or (B,T,20), got {tuple(t.shape)}\"\n    return t","typeGuard":"def is_valid_camera_conditions(t) -> bool:\n    return isinstance(t, torch.Tensor) and t.dim() in (2,3) and t.shape[-1] == 20","tryCatchPattern":null,"preventionTips":["Always build camera_conditions with an explicit .reshape(-1, 20) before passing.","Log tuple(shape) before forward in new integrations."],"tags":["sglang","sana-wm","camera-conditions","shape-validation","video-generation"],"backgroundTag":"tensor-shape-validation-failed","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}