sgl-project/sglang · error · ValueError
camera trajectory must have shape (F, 4, 4); got
Error message
camera trajectory must have shape (F, 4, 4); got {c2w.shape} What it means
camera trajectory c2w must be an (F, 4, 4) array of camera-to-world matrices. Fix the trajectory shape.
Solutions
- Export the trajectory as np.stack(c2w_list, axis=0) with each element 4x4
- If you have a single pose, tile it: np.repeat(pose[None], F, axis=0)
- Verify with arr.shape == (F,4,4) before saving
Example fix
# before np.save(path, pose) # (4,) # after np.save(path, np.repeat(np.eye(4)[None], num_frames, axis=0)) # (F,4,4)
Defensive patterns
Strategy: validation
Validate before calling
arr = np.load(path)
assert arr.ndim == 3 and arr.shape[1:] == (4, 4), f'{path}: {arr.shape}' Type guard
def is_trajectory(a) -> bool:
import numpy as np
return a.ndim == 3 and a.shape[1:] == (4, 4) Prevention
- Validate .npy shape right after np.load in data prep scripts
- Save trajectories with np.stack(poses, axis=0)
When it happens
Trigger: Calling sana_wm_load_camera on an .npy containing a single (4,4) matrix (ndim=2), a (F,3,3) array, or arbitrary arrays. Called from _prepare_static_camera.
Common situations: Saved OpenCV-style w2c matrices instead of c2w; saved a single pose instead of a trajectory; exported (F,4,4) as nested lists that collapsed; wrong file passed as camera path.
Understand the failure class
Background: Tensor shape mismatch errors ("must have shape", "expected shape ... got ..."): when tensor dimensions disagree with what an op or layer was told to expect — this error's family across 6 libraries.
Related errors
- unsupported intrinsics shape
- action output dimensions must be non-zero, got
- action output must have shape [H, D] or [B, H, D], got
- camera_conditions must have shape (T,20) or (B,T,20), got
- chunk_plucker must have shape (48,T,H,W) or (B,48,T,H,W)…
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/fb03df00697cd93d.
Report an issue: GitHub.
Appendix: source
Thrown at python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/sana_wm/base.py:227
if "s" in held:
move -= forward * translation_speed
if "d" in held:
move += right * translation_speed
if "a" in held:
move -= right * translation_speed
current = np.eye(4, dtype=np.float64)
current[:3, :3] = rotation
current[:3, 3] = translation + move
poses.append(current.copy())
return np.stack(poses, axis=0).astype(np.float32)
def sana_wm_load_camera(path: Path) -> np.ndarray:
c2w = np.load(path).astype(np.float32)
if c2w.ndim != 3 or c2w.shape[1:] != (4, 4):
raise ValueError(
f"camera trajectory must have shape (F, 4, 4); got {c2w.shape}"
)
return c2w
def sana_wm_load_intrinsics(path: Path, num_frames: int) -> np.ndarray:
arr = np.load(path).astype(np.float32)
if arr.shape == (4,):
return np.broadcast_to(arr, (num_frames, 4)).copy()
if arr.shape == (3, 3):
vec = np.array([arr[0, 0], arr[1, 1], arr[0, 2], arr[1, 2]], dtype=np.float32)
return np.broadcast_to(vec, (num_frames, 4)).copy()
if arr.ndim == 3 and arr.shape[1:] == (3, 3) and arr.shape[0] >= num_frames:
arr = arr[:num_frames]
return np.stack(
[arr[:, 0, 0], arr[:, 1, 1], arr[:, 0, 2], arr[:, 1, 2]], axis=1
)
raise ValueError(View on GitHub (pinned to 0132848349)