{"record":{"id":"e1902f2598be61fd","repo":"sgl-project/sglang","slug":"unsupported-intrinsics-shape-arr-shape-expected","errorCode":null,"errorMessage":"unsupported intrinsics shape {arr.shape}; expected (4,), (3,3), or (F,3,3)","messagePattern":"unsupported intrinsics shape (.+?); expected \\(4,\\), \\(3,3\\), or \\(F,3,3\\)","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":245,"sourceCode":"        raise ValueError(\n            f\"camera trajectory must have shape (F, 4, 4); got {c2w.shape}\"\n        )\n    return c2w\n\n\ndef sana_wm_load_intrinsics(path: Path, num_frames: int) -> np.ndarray:\n    arr = np.load(path).astype(np.float32)\n    if arr.shape == (4,):\n        return np.broadcast_to(arr, (num_frames, 4)).copy()\n    if arr.shape == (3, 3):\n        vec = np.array([arr[0, 0], arr[1, 1], arr[0, 2], arr[1, 2]], dtype=np.float32)\n        return np.broadcast_to(vec, (num_frames, 4)).copy()\n    if arr.ndim == 3 and arr.shape[1:] == (3, 3) and arr.shape[0] >= num_frames:\n        arr = arr[:num_frames]\n        return np.stack(\n            [arr[:, 0, 0], arr[:, 1, 1], arr[:, 0, 2], arr[:, 1, 2]], axis=1\n        )\n    raise ValueError(\n        f\"unsupported intrinsics shape {arr.shape}; expected (4,), (3,3), or (F,3,3)\"\n    )\n\n\ndef snap_sana_wm_num_frames(\n    num_frames: int, stride: int = 8, upper_bound: int | None = None\n) -> int:\n    if num_frames < 1:\n        return 1\n    if (num_frames - 1) % stride == 0:\n        return min(num_frames, upper_bound) if upper_bound is not None else num_frames\n\n    floor_candidate = num_frames - ((num_frames - 1) % stride)\n    ceil_candidate = floor_candidate + stride\n    snapped = (\n        floor_candidate\n        if num_frames - floor_candidate < ceil_candidate - num_frames\n        else ceil_candidate","sourceCodeStart":227,"sourceCodeEnd":263,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/sana_wm/base.py#L227-L263","documentation":"Raised by sana_wm_load_intrinsics when the loaded array is not shape (4,), (3,3), or (F,3,3) with F >= num_frames. The function converts fx, fy, cx, cy vectors or 3x3 matrices into a (num_frames, 4) array.","triggerScenarios":"Passing intrinsics arrays of shape (2,), (4,4), (F,4) with F<num_frames, or (F,3,3) with fewer frames than num_frames. Called from _prepare_intrinsics.","commonSituations":"Saving a 4x4 extrinsics matrix as intrinsics by mistake; a per-frame intrinsics file shorter than the requested frame count; saving (3,4) projection matrices.","solutions":["Save intrinsics as a flat [fx, fy, cx, cy] array, or a single 3x3 K matrix","Ensure per-frame (F,3,3) files have at least num_frames entries","Double-check you're pointing at the intrinsics file, not the camera pose file"],"exampleFix":"# before\nnp.save(path, K4x4)  # (4,4)\n# after\nnp.save(path, np.array([fx, fy, cx, cy]))  # (4,)","handlingStrategy":"validation","validationCode":"arr = np.load(path)\nassert arr.shape in [(4,), (3,3)] or (arr.ndim == 3 and arr.shape[1:] == (3,3) and arr.shape[0] >= num_frames)","typeGuard":"def intrinsics_ok(a, num_frames: int) -> bool:\n    return a.shape in ((4,), (3, 3)) or (a.ndim == 3 and a.shape[1:] == (3, 3) and a.shape[0] >= num_frames)","tryCatchPattern":null,"preventionTips":["Save intrinsics as [fx, fy, cx, cy]","Keep per-frame intrinsics files at least as long as num_frames"],"tags":["numpy","intrinsics","shape-validation","sana-wm"],"backgroundTag":"tensor-shape-mismatch","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}