diff --git a/.gitattributes b/.gitattributes index c01890c341e53e6f48bcf1122601ad67c1b16b17..d5a13684a5d5eaed330e0197a17ae806654df9b8 100644 --- a/.gitattributes +++ b/.gitattributes @@ -51,3 +51,12 @@ image/blobs/sha256/fed26da465205879ddefd477dede4d90fccc48b762849d028c45f589ea4bf media/demo_sample.png filter=lfs diff=lfs merge=lfs -text media/demo_tt.gif filter=lfs diff=lfs merge=lfs -text media/demo_tt.mp4 filter=lfs diff=lfs merge=lfs -text +image/blobs/sha256/4a09a953b77760f9bc21e019efd2b7c955acbb3da411924422eb1dc152d42cb5 filter=lfs diff=lfs merge=lfs -text +image/blobs/sha256/5e8d5690a24c1c2dd08c724768ff8dfb3cde06d235dc412ea25b99c03cecb0e9 filter=lfs diff=lfs merge=lfs -text +image/blobs/sha256/62b690ec2bb305674142733157a0c3f23492989a04d9029dc5edfdcad69fb6bf filter=lfs diff=lfs merge=lfs -text +image/blobs/sha256/6abcb58795a986f2819b59f5e6137beb717bbfb72085ac0cf67d65ffec4394f8 filter=lfs diff=lfs merge=lfs -text +image/blobs/sha256/7091da5027cb5b595a8e3a28218802237b707ac6788462fa784b679a64498a2c filter=lfs diff=lfs merge=lfs -text +image/blobs/sha256/730e5c49f8c863df41fa025f30d1f6b326c7612e58826ce4b3040e91ee6ab6e8 filter=lfs diff=lfs merge=lfs -text +image/blobs/sha256/a25af6f70d283cd4531f41b6e80960e4f4f58169c01983ce52ce353c76a302fb filter=lfs diff=lfs merge=lfs -text +image/blobs/sha256/c1775688fd5d80d39eead952ffb71947d7c9372f0afab378cd209c7790aeddd9 filter=lfs diff=lfs merge=lfs -text +image/blobs/sha256/dd4a48658276f0dc5d844c924df0ea916711b0afda94aa06db2a9463b6010cdb filter=lfs diff=lfs merge=lfs -text diff --git a/PYTHON.md b/PYTHON.md index cad91a5ee810aa54198dc3b8431e9631b82b6e0b..0d317262b5efc9d0c2d10bed3ca4d1d91d41ee2a 100644 --- a/PYTHON.md +++ b/PYTHON.md @@ -50,6 +50,7 @@ bucket and clip length, so the first call is as fast as the next. Every setting | `fov` | `DEPTHPRO2_FOV` | true | load the focal-length (FOV) estimator `apple/DepthPro2-focal` | | `engine` | `DEPTHPRO2_ENGINE` | `enc=mk,dec=mk,fov=mk` | per stage `mk` (persistent megakernel) or `ttnn` (its tt-nn fallback), e.g. `"dec=ttnn"` (stages not named keep the default) or one kind for all | | `precision` | `DEPTHPRO2_PRECISION` | the device module's default | `bf16`, or `bfp8` where the device module offers it | +| `enc_precision` | `DEPTHPRO2_ENC_PRECISION` | `high` | encoder megakernel numerics: `high` (the megakernel's per-size defaults: on L, fp32 LayerNorm output into the QKV / FC1 matmuls and hi / lo prefix keys) or `fast` (the plain bfloat16 encoder everywhere, which changes L only; `high` costs L 5-18 % more encoder time); S, B, H+ and the focal-length estimator run the same either way. It sets `DEPTHPRO2_MK_ENC_OPTS` for the process before the programs are built (one setting per process) | | `weights_dir`, `fov_weights_dir` | `DEPTHPRO2_WEIGHTS_DIR`, `DEPTHPRO2_FOV_WEIGHTS_DIR` | the Hub snapshots at the pinned commits | local snapshots (a directory with `model.safetensors`, or a parent of `DepthPro2-/`, `DepthPro2-focal/`), used offline | | `revision`, `fov_revision` | | the pins | other commits of the size / focal repo | | `device_id`, `dispatch`, `num_command_queues` | `TT_DEVICE_ID`, `DEPTHPRO2_DISPATCH`, `DEPTHPRO2_NUM_CQS` | 0, `eth`, 1 | the chip; `dispatch="worker"` is an A/B opt-in (11x10 grid) | diff --git a/README.md b/README.md index 797bb32c546286dbede959b08577f957949fb9bf..5caf0f75c254ea2039ea38dbb807b55f1dcc3470 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,6 @@ tags: - p150 - tt-dit-server - tt-model-cache -- tt-model-catalog - tt-model-container license: other license_name: apple-amlr @@ -117,8 +116,8 @@ Response of `/predict` for the sample image as served on the p150 (depth data el "device_size": [480, 640], "resized": false, "focallength_px": 490.04, "focal_source": "fov", "fov_deg": [[65.85, 52.19]], "depth": {"format": "npy", "dtype": "float16", "shape": [480, 640], "data": "...", "units": "m"}, - "stats_m": {"pixels": 307200, "infinite_pixels": 32165, "min": 1.43, "p05": 1.68, "median": 6.97, - "p95": 29.5, "max": 28666.4}, + "stats_m": {"pixels": 307200, "infinite_pixels": 32160, "min": 1.43, "p05": 1.68, "median": 6.96, + "p95": 29.6, "max": 44182.7}, "timing_ms": {"decode": "...", "preprocess": "...", "device": "...", "fov": "...", "postprocess": "...", "encode": "...", "total": "..."}} ``` @@ -157,6 +156,7 @@ it. | video modes | `DEPTHPRO2_VIDEO_MODES` | `buffered`, `unbuffered`, both, or `auto` | `auto`: both when the key-value caches fit 4 GiB of device memory | | unbuffered streams open at once | `DEPTHPRO2_KV_STREAMS` | 1 to 8 (one cache per bucket each) | 1 | | device engines | `DEPTHPRO2_ENGINE` | per stage `mk` (megakernel) or `ttnn` (tt-nn operations), e.g. `dec=ttnn`; stages not named keep the default | `enc=mk,dec=mk,fov=mk` | +| encoder precision | `DEPTHPRO2_ENC_PRECISION` | `high`: on L, float32 LayerNorm output into the attention and MLP input matmuls and two-part (hi / lo) prefix keys; `fast`: the plain bfloat16 encoder on L too (`high` costs L 5-18 % more encoder time); S, B, H+ and the focal-length estimator run the same either way | `high` | Every bucket adds device programs and their start-up time; any clip length up to the window runs on the window's program. The unbuffered key-value caches take device memory per bucket and stream (window 16): @@ -196,11 +196,11 @@ parentheses: | eval | S | B | L | H+ | frames | | --- | --- | --- | --- | --- | --- | | Inverse depth PCC, a 480 x 640 image | 0.999996 | 0.999997 | 0.999999 | 0.999999 | 1 | -| Depth AbsRel, a 480 x 640 image | 0.0035 (0.0039) | 0.0025 (0.0021) | 0.0016 (0.0035) | 0.0024 (0.0016) | 1 | -| Inverse depth PCC / depth AbsRel, a 4-frame 240 x 320 clip (frames attending each other) | 0.999998 / 0.0062 (0.0055) | 0.999998 / 0.0037 (0.0032) | 0.999999 / 0.0024 (0.0042) | 0.999998 / 0.0019 (0.0020) | 4 | -| Inverse depth PCC / depth AbsRel, a 375 x 500 image (padded to 384 x 512) | 0.99961 / 0.0179 (0.0133) | 0.99992 / 0.0094 (0.0079) | 0.9952 [1] / 0.0035 (0.0052) | 0.99993 / 0.0057 (0.0050) | 1 | +| Depth AbsRel, a 480 x 640 image | 0.0035 (0.0039) | 0.0025 (0.0021) | 0.0014 (0.0035) | 0.0024 (0.0016) | 1 | +| Inverse depth PCC / depth AbsRel, a 4-frame 240 x 320 clip (frames attending each other) | 0.999998 / 0.0062 (0.0055) | 0.999998 / 0.0037 (0.0032) | 0.999999 / 0.0018 (0.0042) | 0.999998 / 0.0019 (0.0020) | 4 | +| Inverse depth PCC / depth AbsRel, a 375 x 500 image (padded to 384 x 512) | 0.99961 / 0.0179 (0.0133) | 0.99992 / 0.0094 (0.0079) | 0.9913 [1] / 0.0049 (0.0052) | 0.99993 / 0.0057 (0.0050) | 1 | | Focal length error: 480 x 640 image / 4-frame clip / 375 x 500 image | 0.05 % / 0.16 % / 1.0 % (0.12 % / 0.13 % / 1.45 %) | same estimator | same estimator | same estimator | 6 | -| Inverse depth PCC, every frame of a 16-frame 480 x 640 clip, a 5-frame clip and a 20-frame buffered video (lowest frame, vs this package's float32 CPU reference) | 0.99998 | 0.999996 | 0.999996 | 0.999998 | 41 | +| Inverse depth PCC, every frame of a 16-frame 480 x 640 clip, a 5-frame clip and a 20-frame buffered video (lowest frame, vs this package's float32 CPU reference) | 0.99998 | 0.999996 | 0.999997 | 0.999998 | 41 | | Unbuffered video, every frame (key-value cache; 6 frames of 480 x 640, vs this package's float32 CPU reference) | 0.999988 | 0.999995 | 0.999997 | 0.999998 | 6 | AbsRel is the mean relative depth error over the pixels within 100 times the nearest distance, with Apple's @@ -208,33 +208,35 @@ focal length. Apple's float32 output exists for every case except the 375 x 500 compared with this package's float32 CPU reference (equal to Apple's float32 code to a relative error of 1e-5, this image included); the numbers in parentheses are Apple's own code run in bfloat16 on the same inputs. The focal-length estimator is shared by every size. [1] L's prediction for this image is nearly flat (its inverse -depth varies by about 6 % across the image, against 33-42 % for the other sizes), so its PCC is low (0.995 here, -against 0.9995 for Apple's own bfloat16 run), but its depth AbsRel (0.0035) is within Apple's own bfloat16 AbsRel +depth varies by about 6 % across the image, against 33-42 % for the other sizes), so its PCC is low (0.991 here, +against 0.9995 for Apple's own bfloat16 run), but its depth AbsRel (0.0049) is within Apple's own bfloat16 AbsRel (0.0052). -Determinism: the encoder and focal-estimator megakernels gave bit-identical outputs over 10 launches and 1000 -trace replays at each of 10 shapes (480 x 640 with 1, 4 and 16 frames, 736 x 1280, the focal-estimator trunk), -with no hang; the decoder megakernel over 22 launches and 1000 trace replays at each of 15 configurations (every +Determinism: the encoder megakernel gave bit-identical outputs over 1000 trace replays (after 10 to 21 launches) +at each soaked configuration (S at 480 x 640 with 1 and 16 frames, B with 1, L with 1, 4 and 16, H+ with 1 and 4 +and at 736 x 1280), as did the focal-estimator trunk, with no hang; the decoder megakernel over 22 launches and 1000 trace replays at each of 15 configurations (every size at 640 x 480 with 1 and 16 frames; 480 x 640 with 16 frames for S, L and H+, with 4 frames for B and H+, with 1 frame for H+; 736 x 1280 for L), with no hang, and over 500 trace replays at each of 20 (every size at 480 x 640 with 1, 4 and 16 frames, 736 x 1280 and 1088 x 1920). | speed (batch 1, warm) | input | S | B | L | H+ | | --- | --- | --- | --- | --- | --- | -| Device time, encoder megakernel: 1 frame / 16-frame clip | 480 x 640 | 4.2 / 158 ms | 8.7 / 325 ms | 22.0 / 865 ms | 42.3 / 1934 ms | +| Device time, encoder megakernel: 1 frame / 16-frame clip | 480 x 640 | 4.2 / 158 ms | 8.2 / 325 ms | 23.2 / 947 ms | 42.2 / 1933 ms | | Device time, decoder megakernel: 1 frame / 16 frames | 480 x 640 | 1.5 / 11.3 ms | 3.3 / 22.3 ms | 8.1 / 62.2 ms | 8.3 / 63.8 ms | | Device time, focal-estimator megakernel: 1 / 4 frames | 480 x 640 | 5.7 / 18.3 ms | same | same | same | -| Device time per image (encoder + decoder) | 480 x 640 | 5.7 ms | 12.0 ms | 30.2 ms | 50.6 ms | -| Device time per 16-frame clip (frames/s) | 16 x 480 x 640 | 170 ms (94) | 347 ms (46) | 928 ms (17.2) | 2.00 s (8.0) | -| Served `POST /predict`, server `timing_ms.total` (focal estimated) | the sample, 640 x 480 JPEG | 39 ms | 44 ms | 64 ms | 84 ms | -| Served `POST /predict`, client round trip on loopback | the sample | 58 ms | 63 ms | 82 ms | 102 ms | -| Served `POST /predict_video`, one 16-frame clip, client round trip | 16 frames of 480 x 640 | 1.63 s | 1.72 s | 2.31 s | 3.44 s | -| Served `POST /predict_video`, a 5-frame clip (runs on the 16-frame program), client round trip | 5 frames of 480 x 640 | 0.75 s | 0.83 s | 1.15 s | 1.66 s | -| Served `POST /predict_video`, buffered video of 20 frames (two 16-frame clips), client round trip | 20 frames of 480 x 640 | 2.34 s | 2.66 s | 3.72 s | 5.77 s | -| Served unbuffered stream, one frame per request (tt-nn encoder step, decoder megakernel, 16-frame cache), client round trip | 480 x 640 frames | 86-107 ms | 117-134 ms | 201-233 ms | 305-339 ms | -| Server start-up in the container (compile and capture every program): a restart with the kernel cache of an earlier start / the first start (empty kernel cache) | default configuration | 31 s / 190 s | 34 s / 190 s | 43 s / 189 s | 60 s / 247 s | - -Device times: traced replays back to back on one p150 (each megakernel from its release benchmark). Served rows: +| Device time per image (encoder + decoder) | 480 x 640 | 5.7 ms | 11.5 ms | 31.4 ms | 51.8 ms | +| Device time per 16-frame clip (frames/s) | 16 x 480 x 640 | 170 ms (94) | 347 ms (46) | 1.01 s (15.9) | 2.00 s (8.0) | +| Served `POST /predict`, server `timing_ms.total` (focal estimated) | the sample, 640 x 480 JPEG | 40 ms | 44 ms | 67 ms | 84 ms | +| Served `POST /predict`, client round trip on loopback | the sample | 57 ms | 62 ms | 85 ms | 102 ms | +| Served `POST /predict_video`, one 16-frame clip, client round trip | 16 frames of 480 x 640 | 1.63 s | 1.69 s | 2.32 s | 3.34 s | +| Served `POST /predict_video`, a 5-frame clip (runs on the 16-frame program), client round trip | 5 frames of 480 x 640 | 0.73 s | 0.78 s | 1.12 s | 1.65 s | +| Served `POST /predict_video`, buffered video of 20 frames (two 16-frame clips), client round trip | 20 frames of 480 x 640 | 2.26 s | 2.53 s | 3.89 s | 5.73 s | +| Served unbuffered stream, one frame per request (tt-nn encoder step, decoder megakernel, 16-frame cache), client round trip | 480 x 640 frames | 87-101 ms | 115-130 ms | 200-228 ms | 305-347 ms | +| Server start-up in the container (compile and capture every program): a restart with the kernel cache of an earlier start / the first start (empty kernel cache) | default configuration | 20 s / 169 s | 27 s / 172 s | 38 s / 186 s | 58 s / 211 s | + +Device times: traced replays back to back on one p150, 20 per configuration, with the default encoder precision +`high` (the decoder rows from the decoder megakernel's release benchmark; per image and per clip: encoder and +decoder replayed together). Served rows: requests to the HTTP server of this package with its default configuration (buckets 480 x 640 and 640 x 480, window 16, unbuffered video on) on the same p150 in an 8-vCPU AMD EPYC-Rome host (`code/scripts/device_server_smoke.py`: 10 requests of the sample, one of each video request; the video requests @@ -255,15 +257,17 @@ compiles the device kernels into the container's kernel cache, which `tt serve` aspect ratio far from every bucket is stretched, and a small image upscaled to a larger bucket changes the focal-length estimate). Configure your camera's native resolution as a bucket (`DEPTHPRO2_RESOLUTIONS`) for the most faithful results. -- Accuracy outside the gate images: of 16 held-out cases (four inputs at every size, scored against Apple's - float32 output with the same gates), 14 pass. Both misses are on one 480 x 640 photo (Apple's `images.jpg`). - L sees that scene as nearly flat (its inverse depth varies by about 15 % across the image) and reaches an - inverse-depth PCC of 0.998, below the 0.999 gate, where Apple's own bfloat16 run reaches 0.9993; its depth - AbsRel (0.0060) is 1.1 times Apple's bfloat16 error, within the 2x target. S's depth AbsRel on that photo is - 0.027, 2.05 times Apple's bfloat16 error (0.0133), just over the 2x target. Near-flat scenes (for PCC) and S's - depth error on sensitive scenes are the weakest points of this port. The all-tt-nn engine - (`DEPTHPRO2_ENGINE=ttnn`) gives S a lower depth error on that photo (0.022, 1.7 times Apple's bfloat16 error) - at about 2.8 times the device time per image. +- Accuracy outside the gate images: on an independent held-out set (10 inputs: outdoor, indoor, portrait, + telephoto and near-flat images plus a 4- and an 8-frame clip; 40 cases over the four sizes, scored against + Apple's float32 output with the same gates), 38 of 40 pass (S 10, B 9, L 10, H+ 9). The two misses: B on a + sky-and-water landscape, depth AbsRel 0.013 against a budget of 0.010 (Apple's own bfloat16: 0.004), a uniform + 1.5 % depth scale offset; H+ on a 4-frame close-up clip, inverse-depth PCC 0.993 against 0.999, where Apple's own + bfloat16 run reaches only 0.995 (its depth AbsRel, 0.014, is lower than that run's 0.017). The closest passes + are S on the 8-frame clip (AbsRel 0.024 within 0.026) and L on a bright-background beach portrait (0.025 + within 0.035; Apple's bfloat16 0.018). On four further inputs, used to + tune L's encoder precision and so not held out, L reaches an inverse-depth PCC of 0.99957 on Apple's + `images.jpg` at 480 x 640, while S's depth AbsRel on that photo is 0.027, 2.05 times Apple's own bfloat16 error + (0.0133), just over the 2x target. - The resolution buckets and the video window are fixed when the server starts. A clip shorter than the window runs on the window's device program and takes as long as a full window. - Buffered video returns a frame only once its clip is predicted, so it lags the input by up to a window; @@ -335,6 +339,6 @@ The exact sources the image was built from — `code/` in this repo is byte-iden | component | built from | | --- | --- | | tt-metal | [`44d66500520fda9f2c7060c0f6b41ec48f7ab37e`](https://github.com/tenstorrent/tt-metal/commit/44d66500520fda9f2c7060c0f6b41ec48f7ab37e) *(dirty tree — the image includes uncommitted changes)* | -| `code/` digest | `bc0132ce79669bfc` (sha256, first 16 hex digits) | -| built | 2026-11-29T15:31:26+00:00 by tt-model 0.1.0 | +| `code/` digest | `a2e9acdc6e000466` (sha256, first 16 hex digits) | +| built | 2026-11-30T01:25:57+00:00 by tt-model 0.1.0 | diff --git a/SERVING.md b/SERVING.md index 6f00564ce796f0018f21d68013250eead4d2e052..21e71f3fd10b2636611196a7a5667e90a729bf53 100644 --- a/SERVING.md +++ b/SERVING.md @@ -86,6 +86,7 @@ profile it serves: tt-model fetches every weights pointer of a package. The cont | `DEPTHPRO2_FOV` | 1 | load and warm the focal-length estimator | | `DEPTHPRO2_ENGINE` | `enc=mk,dec=mk,fov=mk` | per stage `mk` (persistent megakernel) / `ttnn` (its tt-nn fallback, e.g. `dec=ttnn`); stages not named keep the default | | `DEPTHPRO2_PRECISION` | device module default | `bf16` / `bfp8` (if the device module offers it) | +| `DEPTHPRO2_ENC_PRECISION` | `high` | encoder megakernel numerics: `high` (the megakernel's per-size defaults: on L, fp32 LayerNorm output into the QKV / FC1 matmuls and hi / lo prefix keys) or `fast` (the plain bfloat16 encoder everywhere, which changes L only; `high` costs L 5-18 % more encoder time); S, B, H+ and the focal-length estimator run the same either way | | `DEPTHPRO2_DISPATCH`, `_NUM_CQS`, `_TRACE_REGION`, `_L1_SMALL` | `eth`, 1, sized from the configuration, 32 KB | device open (the trace region is estimated from the measured trace sizes of every bucket, clip length, FOV shape and KV step program unless `_TRACE_REGION` is set) | | `DEPTHPRO2_WEIGHTS_DIR`, `_FOV_WEIGHTS_DIR` | the HF cache at the pinned commits | local snapshots (offline) | | `DEPTHPRO2_MAX_BODY_MB`, `_MAX_FRAMES`, `_MAX_STREAMS`, `_STREAM_TTL_S`, `_TORCH_THREADS` | 256, 64, 4, 300, 4 | server limits | diff --git a/build_info.json b/build_info.json index 4f82a11422398c9843970e0991e6913b0003e5c4..7ac8800bb11c66ad75e04ff2af25e77b29bc9e20 100644 --- a/build_info.json +++ b/build_info.json @@ -1,13 +1,13 @@ { "schema": "ttaw-build-info/1", "bundle": "depthpro2", - "recorded_at": "2026-11-29T15:32:06Z", + "recorded_at": "2026-11-30T01:26:24Z", "image": { - "tag": "tt-model/depthpro2:7d4a5a78b320", - "digest": "sha256:7d4a5a78b320ccf9ed7016c84749884f55b0006c74138e412a411da88e96c90d", - "built_at": "2026-11-29T15:31:26+00:00", - "code_sha256": "bc0132ce79669bfc545af9782cb4e5f8fe2a8edb0d9acb2f749485c4fd0fc5c3", - "size_bytes": 4201980118, + "tag": "tt-model/depthpro2:33f737b5c906", + "digest": "sha256:33f737b5c90656461fe9bd146cb79535e86801e8ae6ff472fba02d98d642d96d", + "built_at": "2026-11-30T01:25:57+00:00", + "code_sha256": "a2e9acdc6e000466e400aea5a0c51398ac83036bb1ea2d46a0ae13065dfcac3b", + "size_bytes": 4202182421, "layers": 23 }, "base_images": { diff --git a/code/PYTHON.md b/code/PYTHON.md index cad91a5ee810aa54198dc3b8431e9631b82b6e0b..0d317262b5efc9d0c2d10bed3ca4d1d91d41ee2a 100644 --- a/code/PYTHON.md +++ b/code/PYTHON.md @@ -50,6 +50,7 @@ bucket and clip length, so the first call is as fast as the next. Every setting | `fov` | `DEPTHPRO2_FOV` | true | load the focal-length (FOV) estimator `apple/DepthPro2-focal` | | `engine` | `DEPTHPRO2_ENGINE` | `enc=mk,dec=mk,fov=mk` | per stage `mk` (persistent megakernel) or `ttnn` (its tt-nn fallback), e.g. `"dec=ttnn"` (stages not named keep the default) or one kind for all | | `precision` | `DEPTHPRO2_PRECISION` | the device module's default | `bf16`, or `bfp8` where the device module offers it | +| `enc_precision` | `DEPTHPRO2_ENC_PRECISION` | `high` | encoder megakernel numerics: `high` (the megakernel's per-size defaults: on L, fp32 LayerNorm output into the QKV / FC1 matmuls and hi / lo prefix keys) or `fast` (the plain bfloat16 encoder everywhere, which changes L only; `high` costs L 5-18 % more encoder time); S, B, H+ and the focal-length estimator run the same either way. It sets `DEPTHPRO2_MK_ENC_OPTS` for the process before the programs are built (one setting per process) | | `weights_dir`, `fov_weights_dir` | `DEPTHPRO2_WEIGHTS_DIR`, `DEPTHPRO2_FOV_WEIGHTS_DIR` | the Hub snapshots at the pinned commits | local snapshots (a directory with `model.safetensors`, or a parent of `DepthPro2-/`, `DepthPro2-focal/`), used offline | | `revision`, `fov_revision` | | the pins | other commits of the size / focal repo | | `device_id`, `dispatch`, `num_command_queues` | `TT_DEVICE_ID`, `DEPTHPRO2_DISPATCH`, `DEPTHPRO2_NUM_CQS` | 0, `eth`, 1 | the chip; `dispatch="worker"` is an A/B opt-in (11x10 grid) | diff --git a/code/tt_depthpro2/__init__.py b/code/tt_depthpro2/__init__.py index ffa4200aa0607860f20607b10d7b7e77caa16423..64d061545e4dda298132e5152e6634a30928397c 100644 --- a/code/tt_depthpro2/__init__.py +++ b/code/tt_depthpro2/__init__.py @@ -16,7 +16,7 @@ they are not part of this package. Apple Machine Learning Research Model is lice Learning Research Model License Agreement. """ -__version__ = "0.1.0" +__version__ = "0.2.0" __all__ = ["DepthPro2", "DepthOutput", "VideoSession", "load_sample", "InputError", "open_device", "close_device", "__version__"] diff --git a/code/tt_depthpro2/api.py b/code/tt_depthpro2/api.py index 0fa2af815165633cc2b02f6cce51dec2e489fd91..e4febdedecc7fee0497e6d4ab7e5c4625969d31c 100644 --- a/code/tt_depthpro2/api.py +++ b/code/tt_depthpro2/api.py @@ -236,7 +236,8 @@ class DepthPro2: @classmethod def from_pretrained(cls, size: Optional[str] = None, *, resolutions: Any = None, window: Any = None, overlap: Any = None, fov: Any = None, engine: Any = None, video_modes: Any = None, - clip_lengths: Any = None, precision: Any = None, kv_streams: Any = None, device: Any = None, + clip_lengths: Any = None, precision: Any = None, kv_streams: Any = None, + enc_precision: Any = None, device: Any = None, device_id: Optional[int] = None, dispatch: Optional[str] = None, num_command_queues: Optional[int] = None, weights_dir: Optional[str] = None, fov_weights_dir: Optional[str] = None, revision: Optional[str] = None, @@ -254,7 +255,10 @@ class DepthPro2: (default: both when the caches fit ``config.KV_BUDGET_BYTES``). ``kv_streams``: unbuffered streams open at once (default 1, ``$DEPTHPRO2_KV_STREAMS``). ``fov``: load the focal-length estimator (default True). ``engine``: per-stage ``mk`` / ``ttnn`` (``"enc=mk,dec=ttnn"``). - ``precision``: ``bf16`` / ``bfp8`` if the device module offers it. Each default comes from the matching + ``precision``: ``bf16`` / ``bfp8`` if the device module offers it. ``enc_precision``: ``high`` (default) or + ``fast`` (the encoder megakernel's plain bf16 numerics everywhere, which changes L only; sets + ``DEPTHPRO2_MK_ENC_OPTS`` for this process before + the programs are built). Each default comes from the matching ``DEPTHPRO2_*`` variable (``config.resolve_config``); a bad value raises ``ValueError``. ``weights_dir`` / ``fov_weights_dir`` (or ``$DEPTHPRO2_WEIGHTS_DIR`` / ``$DEPTHPRO2_FOV_WEIGHTS_DIR``): @@ -270,7 +274,7 @@ class DepthPro2: size = C.PROFILES[size.strip().lower()] cfg = C.resolve_config(size, resolutions=resolutions, window=window, overlap=overlap, video_modes=video_modes, clip_lengths=clip_lengths, fov=fov, engine=engine, - precision=precision, kv_streams=kv_streams) + precision=precision, kv_streams=kv_streams, enc_precision=enc_precision) self = cls.__new__(cls) self._lock = threading.RLock() self._closed = False @@ -317,6 +321,13 @@ class DepthPro2: if device is not None: self.device_info = dict(_device.describe_device(device, device_id), backend=backend) t1 = time.perf_counter() + if backend == "tt": # the encoder megakernel reads its options when a program is built + opts = C.mk_enc_options(cfg.enc_precision, os.environ.get(C.MK_ENC_OPTS_ENV)) + if opts: + os.environ[C.MK_ENC_OPTS_ENV] = opts + else: + os.environ.pop(C.MK_ENC_OPTS_ENV, None) + self.mk_enc_opts = os.environ.get(C.MK_ENC_OPTS_ENV, "") if backend == "tt" else None self._build_engine(sw, fw, engine_factory) del sw, fw self.warmup_ms["build"] = (time.perf_counter() - t1) * 1e3 @@ -719,7 +730,8 @@ class DepthPro2: "valid_frames": bool(getattr(eng, "valid_frames", False)), "video_modes": list(cfg.video_modes), "video_modes_reason": getattr(self, "video_modes_reason", None), "kv_streams": cfg.kv_streams, "kv_cache": self.kv_cache_plan() if "unbuffered" in cfg.video_modes - else None, "fov": cfg.fov, "env": cfg.as_env(), + else None, "fov": cfg.fov, "enc_precision": cfg.enc_precision, + "mk_enc_opts": getattr(self, "mk_enc_opts", None), "env": cfg.as_env(), }, "trace_region_bytes": (self.device_info or {}).get("trace_region_size"), "supports_unbuffered": self.supports_unbuffered if eng is not None else False, diff --git a/code/tt_depthpro2/config.py b/code/tt_depthpro2/config.py index 58f486b91f89a7303f1f0fcc702bd436f4a112c2..275f342d12fccfef1a1664209144d99710075eb1 100644 --- a/code/tt_depthpro2/config.py +++ b/code/tt_depthpro2/config.py @@ -20,6 +20,10 @@ arguments first, then from the environment (``DEPTHPRO2_*``), then the defaults: | engine | ``DEPTHPRO2_ENGINE`` | ``enc=mk,dec=mk,fov=mk`` | per stage ``mk`` (persistent megakernel) or ``ttnn`` (the tt-nn | | | | | fallback, e.g. ``dec=ttnn``); stages not named keep the default | | precision | ``DEPTHPRO2_PRECISION`` | the device module's default | ``bf16`` or ``bfp8`` (only if the device module offers it) | +| encoder precision | ``DEPTHPRO2_ENC_PRECISION`` | ``high`` | encoder megakernel numerics: ``high`` (the megakernel's | +| | | | per-size defaults: on L, fp32 LayerNorm output into QKV / FC1 and hi / lo prefix keys) or ``fast`` (the | +| | | | plain bf16 encoder everywhere; only L changes, ``high`` costs L 5-18 % more encoder time); S, B, H+ and | +| | | | the focal-length trunk run the same either way | A *bucket* is a native input size ``(H, W)``; the device program runs at the padded size ``(ceil32(H), ceil32(W))`` (replicate padding, exactly like the official code). A request of exactly a bucket's size runs natively; any other @@ -39,7 +43,8 @@ __all__ = [ "VIDEO_MODES", "DEFAULT_VIDEO_MODES", "DEFAULT_ENGINE", "KV_BUDGET_BYTES", "KV_STREAMS_RANGE", "ENGINE_STAGES", "ENGINE_KINDS", "PRECISIONS", "BUCKET_SIDE", "INPUT_MULTIPLE", "DepthConfig", "resolve_config", "normalize_size", "parse_resolutions", "parse_engine", "parse_video_modes", "parse_clip_lengths", "padded_hw", "choose_bucket", "weights_pin", "parse_auxiliary_weights", - "LICENSE_NOTICE", "WEIGHTS_LICENSE", + "LICENSE_NOTICE", "WEIGHTS_LICENSE", "ENC_PRECISIONS", "DEFAULT_ENC_PRECISION", "MK_ENC_OPTS_ENV", + "MK_ENC_FAST_OPTS", "mk_enc_options", ] MODEL_NAME = "depthpro2" @@ -98,6 +103,15 @@ DEFAULT_VIDEO_MODES = ("buffered", "unbuffered") # with "auto" (the default): u #: up to 2.2 GB (H+), the compiled programs' activations up to ~1.3 GB at 1080p T=16) KV_BUDGET_BYTES = 4 << 30 KV_STREAMS_RANGE = (1, 8) +#: encoder megakernel numerics (``DEPTHPRO2_ENC_PRECISION``): ``high`` keeps the megakernel's per-size defaults +#: (L: fp32 LayerNorm output as the QKV / FC1 operand, prefix / register keys in hi / lo; every other size and the +#: focal-length trunk: bf16); ``fast`` turns those off everywhere (the v1 encoder), which changes L only. +ENC_PRECISIONS = ("high", "fast") +DEFAULT_ENC_PRECISION = "high" +#: the encoder megakernel's option variable, and the options ``fast`` sets in it (``high`` removes these two keys so +#: the per-size defaults apply; other keys are kept) +MK_ENC_OPTS_ENV = "DEPTHPRO2_MK_ENC_OPTS" +MK_ENC_FAST_OPTS = (("inx32", "0"), ("klo", "0")) ENGINE_STAGES = ("enc", "dec", "fov") ENGINE_KINDS = ("mk", "ttnn") @@ -278,6 +292,7 @@ class DepthConfig: fov: bool = True engine: Optional[Dict[str, str]] = field(default_factory=lambda: dict(DEFAULT_ENGINE)) precision: Optional[str] = None + enc_precision: str = DEFAULT_ENC_PRECISION @property def device_buckets(self) -> List[Tuple[int, int]]: @@ -300,13 +315,14 @@ class DepthConfig: env["ENGINE"] = ",".join(f"{k}={v}" for k, v in self.engine.items()) if self.precision: env["PRECISION"] = self.precision + env["ENC_PRECISION"] = self.enc_precision return {f"{ENV_PREFIX}_{k}": v for k, v in env.items()} def resolve_config(size: Any = None, *, resolutions: Any = None, window: Any = None, overlap: Any = None, video_modes: Any = None, clip_lengths: Any = None, fov: Any = None, engine: Any = None, - kv_streams: Any = None, - precision: Any = None, env: Optional[Mapping[str, str]] = None) -> DepthConfig: + kv_streams: Any = None, precision: Any = None, enc_precision: Any = None, + env: Optional[Mapping[str, str]] = None) -> DepthConfig: """Explicit values > ``DEPTHPRO2_*`` environment > defaults. Raises ``ValueError`` naming the setting (and the environment variable it came from) for anything out of range, so a bad value refuses to start.""" env = os.environ if env is None else env @@ -352,9 +368,27 @@ def resolve_config(size: Any = None, *, resolutions: Any = None, window: Any = N prec = str(v).strip().lower() if prec not in PRECISIONS: raise ValueError(f"{src}={v!r}: one of {list(PRECISIONS)}") + v, src = pick(enc_precision, "ENC_PRECISION") + encp = DEFAULT_ENC_PRECISION if v is None else str(v).strip().lower() + if encp not in ENC_PRECISIONS: + raise ValueError(f"{src}={v!r}: one of {list(ENC_PRECISIONS)}") return DepthConfig(size=sz, resolutions=res, window=win, overlap=ov, video_modes=modes, video_modes_auto=auto, kv_streams=kvs, clip_lengths=clips, - fov=fv, engine=eng, precision=prec) + fov=fv, engine=eng, precision=prec, enc_precision=encp) + + +def mk_enc_options(enc_precision: str, current: Optional[str] = None) -> str: + """The ``DEPTHPRO2_MK_ENC_OPTS`` value that gives ``enc_precision`` (``high`` / ``fast``): ``current`` (the + variable's present value) without its ``inx32`` / ``klo`` keys, plus :data:`MK_ENC_FAST_OPTS` for ``fast``. Set + before any encoder megakernel is built (it reads the variable when a program is built).""" + if enc_precision not in ENC_PRECISIONS: + raise ValueError(f"enc_precision={enc_precision!r}: one of {list(ENC_PRECISIONS)}") + names = {k for k, _ in MK_ENC_FAST_OPTS} + keep = [kv.strip() for kv in (current or "").split(",") + if "=" in kv and kv.split("=", 1)[0].strip() not in names] + if enc_precision == "fast": + keep += [f"{k}={v}" for k, v in MK_ENC_FAST_OPTS] + return ",".join(keep) def choose_bucket(height: int, width: int, buckets: Sequence[Tuple[int, int]]) -> Tuple[Tuple[int, int], bool]: diff --git a/code/tt_depthpro2/server/app.py b/code/tt_depthpro2/server/app.py index c9c5e9f1f073652af50f91ad5d47f73eced48b26..26f92fbf6d289455d6a9ef8a3a1baa1d5d698dc3 100644 --- a/code/tt_depthpro2/server/app.py +++ b/code/tt_depthpro2/server/app.py @@ -34,7 +34,7 @@ video streams and the model under the lock (SIGTERM, tt-model's 120 s grace) and this module has no side effects (no ttnn, no torch, no device). Environment (read at start; ``config.py`` has the model settings): ``DEPTHPRO2_SIZE``, ``_RESOLUTIONS``, ``_WINDOW``, -``_OVERLAP``, ``_VIDEO_MODES`` (``auto``), ``_KV_STREAMS``, ``_CLIP_LENGTHS``, ``_FOV``, ``_ENGINE``, ``_PRECISION``; ``DEPTHPRO2_WEIGHTS_DIR`` / +``_OVERLAP``, ``_VIDEO_MODES`` (``auto``), ``_KV_STREAMS``, ``_CLIP_LENGTHS``, ``_FOV``, ``_ENGINE``, ``_PRECISION``, ``_ENC_PRECISION``; ``DEPTHPRO2_WEIGHTS_DIR`` / ``_FOV_WEIGHTS_DIR`` (local snapshots, offline); ``TT_AUXILIARY_WEIGHTS`` (tt-model: ``repo@rev,...``, the size repos' commits) and ``TT_MODEL_WEIGHTS_REVISION`` / ``TT_WEIGHTS_REVISION`` (the focal repo's commit), default the pinned commits; ``DEPTHPRO2_DISPATCH`` (``eth`` | ``worker``), ``_NUM_CQS``, ``_TRACE_REGION``, ``_L1_SMALL``; @@ -169,7 +169,7 @@ def default_model_factory(cfg: ServerConfig): return DepthPro2.from_pretrained( m.size, resolutions=m.resolutions, window=m.window, overlap=m.overlap, fov=m.fov, engine=m.engine, video_modes="auto" if m.video_modes_auto else m.video_modes, clip_lengths=m.clip_lengths, - precision=m.precision, kv_streams=m.kv_streams, device_id=cfg.device_id, + precision=m.precision, kv_streams=m.kv_streams, enc_precision=m.enc_precision, device_id=cfg.device_id, dispatch=cfg.dispatch, num_command_queues=cfg.num_command_queues, weights_dir=cfg.weights_dir, fov_weights_dir=cfg.fov_weights_dir, revision=cfg.revision, fov_revision=cfg.fov_revision, backend=cfg.backend, warmup=True) diff --git a/code/tt_depthpro2/server/smoke_test.py b/code/tt_depthpro2/server/smoke_test.py index c8ae89944c18ce0fd7c87dd01c54469bdc997a6a..3a4ba5b265417fe87fff5cc0a8a4a67c17e8cca6 100644 --- a/code/tt_depthpro2/server/smoke_test.py +++ b/code/tt_depthpro2/server/smoke_test.py @@ -163,6 +163,9 @@ def check_info(info: Dict[str, Any], pins: Optional[Dict[str, Any]]) -> List[str eng = env.get(f"{ENV_PREFIX}_ENGINE") if eng is not None and info.get("engine") != C.parse_engine(eng): fails.append(f"/info engine {info.get('engine')} != pinned {ENV_PREFIX}_ENGINE={eng}") + encp = env.get(f"{ENV_PREFIX}_ENC_PRECISION") + if encp and cfgd.get("enc_precision") != encp.strip().lower(): + fails.append(f"/info enc_precision {cfgd.get('enc_precision')!r} != pinned {ENV_PREFIX}_ENC_PRECISION={encp}") for key, name in (("window", "WINDOW"), ("overlap", "OVERLAP")): v = env.get(f"{ENV_PREFIX}_{name}") if v and str(cfgd.get(key)) != v.strip(): diff --git a/code/tt_depthpro2/tests/baseline_helpers.py b/code/tt_depthpro2/tests/baseline_helpers.py index 3f397834bd45297bc57f37f1543c8d299bb17cd9..d3b5d237e0b0babad07407ea6c4e6626e6a6c025 100644 --- a/code/tt_depthpro2/tests/baseline_helpers.py +++ b/code/tt_depthpro2/tests/baseline_helpers.py @@ -1,32 +1,79 @@ # SPDX-License-Identifier: Apache-2.0 -"""Helpers for the ttnn-baseline device tests and benchmarks (paths, goldens, metrics, device open).""" +"""Helpers for the ttnn-baseline device tests and benchmarks (paths, goldens, metrics, device open). + +Paths (no machine-specific defaults): + +* ``ROOT``: ``$TT_MODELS_ROOT``, else the nearest ancestor directory of this package that holds ``assets/depthpro2/`` + (the workspace the bundle sits in), else ``code/`` (the package's parent). Goldens, reference outputs and logs of the + device scripts live under it. +* weights: ``$DEPTHPRO2_WEIGHTS`` (else ``$DEPTHPRO2_TEST_WEIGHTS`` / ``$DEPTHPRO2_WEIGHTS_DIR``), a parent of + ``DepthPro2-/``; without one, each repo's Hugging Face cache snapshot at the package's pinned commit + (``config.WEIGHTS``; cache only, nothing is downloaded). +* ``GOLDEN``: ``$DEPTHPRO2_GOLDEN``, else ``ROOT/assets/depthpro2/golden``. +""" from __future__ import annotations import json import math import os +import sys +from pathlib import Path from typing import Dict, Optional, Tuple import torch -ROOT = os.environ.get("TT_MODELS_ROOT", "/home/ubuntu/experiments/tt-models") -WEIGHTS = os.environ.get("DEPTHPRO2_WEIGHTS", "/mnt/chang/models/apple") +_CODE = Path(__file__).resolve().parents[2] # code/ (the package's parent) + + +def _find_root() -> str: + env = os.environ.get("TT_MODELS_ROOT") + if env: + return env + for p in _CODE.parents: + if (p / "assets" / "depthpro2").is_dir(): + return str(p) + return str(_CODE) + + +ROOT = _find_root() +#: a parent of DepthPro2-/ and DepthPro2-focal/, or None: the Hugging Face cache at the pinned commits +WEIGHTS: Optional[str] = (os.environ.get("DEPTHPRO2_WEIGHTS") or os.environ.get("DEPTHPRO2_TEST_WEIGHTS") + or os.environ.get("DEPTHPRO2_WEIGHTS_DIR") or None) GOLDEN = os.environ.get("DEPTHPRO2_GOLDEN", os.path.join(ROOT, "assets/depthpro2/golden")) SIZE_DIRS = {"S": "DepthPro2-S", "B": "DepthPro2-B", "L": "DepthPro2-L", "H": "DepthPro2-H"} FOV_DIR = "DepthPro2-focal" + +def _weights_dir(key: str) -> str: + """The directory holding ``model.safetensors`` of a size (``"S"``..``"H"``) or of the focal estimator.""" + if WEIGHTS: + return os.path.join(WEIGHTS, FOV_DIR if key == "focal" else SIZE_DIRS[key]) + try: + from tt_depthpro2 import config as C + except ImportError: # imported as a top-level module (tests/ on sys.path) + sys.path.insert(0, str(_CODE)) + from tt_depthpro2 import config as C + from huggingface_hub import snapshot_download + + repo, pin = C.weights_pin(key) + try: + return snapshot_download(repo, revision=pin, local_files_only=True, allow_patterns=list(C.ALLOW_PATTERNS)) + except Exception as e: # noqa: BLE001 -- not in the cache + raise FileNotFoundError(f"{repo}@{pin} is not in the Hugging Face cache; set DEPTHPRO2_WEIGHTS to a parent " + f"of {FOV_DIR if key == 'focal' else SIZE_DIRS[key]}/ ({e})") from None + # device-open parameters the ttnn baseline needs (conv2d halo / config buffers; traces of every compiled shape) L1_SMALL_SIZE = 32768 TRACE_REGION_SIZE = int(os.environ.get("DEPTHPRO2_TRACE_REGION", str(256 << 20))) def size_dir(size: str) -> str: - return os.path.join(WEIGHTS, SIZE_DIRS[size]) + return _weights_dir(size) def fov_dir() -> str: - return os.path.join(WEIGHTS, FOV_DIR) + return _weights_dir("focal") BASELINE_REF = os.path.join(ROOT, "assets/depthpro2/baseline_ref") # tests/make_baseline_refs.py (reference outputs) diff --git a/code/tt_depthpro2/tests/mk_enc_ab.py b/code/tt_depthpro2/tests/mk_enc_ab.py new file mode 100644 index 0000000000000000000000000000000000000000..9edc7bd623cca60ed179002be78a092d03e683ab --- /dev/null +++ b/code/tt_depthpro2/tests/mk_enc_ab.py @@ -0,0 +1,81 @@ +# SPDX-License-Identifier: Apache-2.0 +"""A/B of two DEPTHPRO2_MK_ENC_OPTS settings on the same patches: traced time of each, taps bitwise / PCC between +them and vs the golden taps (when the case has them). Weights / goldens: DEPTHPRO2_TEST_WEIGHTS / DEPTHPRO2_GOLDEN. + + bin/devrun -t 1200 -- python -u /tests/mk_enc_ab.py --size S --case img_vga --a inx32=0 --b inx32=1 +""" + +from __future__ import annotations + +import argparse +import os +import sys +import time + +import torch + +sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..", ".."))) + +from tt_depthpro2.reference import model as R # noqa: E402 +from tt_depthpro2.tests import mk_enc_ref as H # noqa: E402 +from tt_depthpro2.tt.mk_enc import arena as A # noqa: E402 +from tt_depthpro2.tt.mk_enc.program import MkEnc, MkEncWeights # noqa: E402 + + +def main(): + ap = argparse.ArgumentParser() + ap.add_argument("--size", default="S") + ap.add_argument("--case", default="img_vga") + ap.add_argument("--a", default="") + ap.add_argument("--b", default="") + ap.add_argument("--reps", type=int, default=5) + ap.add_argument("--resize", type=int, nargs=3, default=None, help="H W T: resized / repeated frames + noise") + args = ap.parse_args() + import ttnn + + g = H.load_case(args.case, args.size) + x = R.pad_to_multiple(g["x_norm"].float()) + if args.resize: + hh, ww, tt = args.resize + x = torch.nn.functional.interpolate(x[:1], size=(hh, ww), mode="bilinear", align_corners=False) + x = x.repeat(tt, 1, 1, 1) + 0.1 * torch.randn(tt, 3, hh, ww, generator=torch.Generator().manual_seed(0)) + T, _, hp, wp = x.shape + dev = ttnn.open_device(device_id=0, dispatch_core_config=ttnn.DispatchCoreConfig(ttnn.DispatchCoreType.ETH), + trace_region_size=16 << 20) + try: + wts = MkEncWeights(dev, H.load_weights(args.size), args.size, "depth") + patches = ttnn.from_torch(A.patchify(x).to(torch.bfloat16).reshape(1, 1, -1, 768), dtype=ttnn.bfloat16, + layout=ttnn.TILE_LAYOUT, device=dev, memory_config=ttnn.DRAM_MEMORY_CONFIG) + res = {} + for tag, opts in (("A", args.a), ("B", args.b)): + os.environ["DEPTHPRO2_MK_ENC_OPTS"] = opts + mk = MkEnc(dev, wts, args.size, T, hp // 16, wp // 16) + mk.run(patches) + ttnn.synchronize_device(dev) + raw = [ttnn.to_torch(t).clone() for t in mk.taps] + tid = ttnn.begin_trace_capture(dev, cq_id=0) + mk.run(patches) + ttnn.end_trace_capture(dev, tid, cq_id=0) + ttnn.execute_trace(dev, tid, cq_id=0, blocking=True) + t0 = time.perf_counter() + for _ in range(args.reps): + ttnn.execute_trace(dev, tid, cq_id=0, blocking=False) + ttnn.synchronize_device(dev) + ms = 1e3 * (time.perf_counter() - t0) / args.reps + same = all(torch.equal(a, ttnn.to_torch(t)) for a, t in zip(raw, mk.taps)) + ttnn.release_trace(dev, tid) + res[tag] = raw + msg = f"{tag} [{opts or 'default'}] {mk.geo.summary()}: {ms:.3f} ms, replay bitexact {same}" + if "tap0" in g and not args.resize: + d = [r.float().reshape(T, mk.geo.Np, -1)[:, :mk.geo.N] for r in raw] + msg += " | vs golden rel " + " ".join(f"{H.rel_err(d[i], g[f'tap{i}'].float()):.3e}" for i in range(4)) + print(msg, flush=True) + del mk + pc = [H.pcc(a.float(), b.float()) for a, b in zip(res["A"], res["B"])] + print(f"A vs B taps pcc {[round(p, 7) for p in pc]}", flush=True) + finally: + ttnn.close_device(dev) + + +if __name__ == "__main__": + main() diff --git a/code/tt_depthpro2/tests/mk_enc_bench.py b/code/tt_depthpro2/tests/mk_enc_bench.py index 27952f72f97bfabcd0652570e6cb68cc7a103f89..93a675e5ee8f51d6c1ae2366a0375056939eef42 100644 --- a/code/tt_depthpro2/tests/mk_enc_bench.py +++ b/code/tt_depthpro2/tests/mk_enc_bench.py @@ -24,7 +24,6 @@ from tt_depthpro2.tests import mk_enc_ref as H # noqa: E402 from tt_depthpro2.tt.mk_enc import arena as A # noqa: E402 from tt_depthpro2.tt.mk_enc.program import MkEnc, MkEncWeights # noqa: E402 -LOG = "/home/ubuntu/experiments/tt-models/logs/depthpro2/mk_enc/bench.jsonl" def frames(hp: int, wp: int, T: int) -> torch.Tensor: @@ -82,8 +81,7 @@ def main(): "first_run_s": first, "finite": fin, "replays_bitexact": same, "geometry": mk.geo.summary(), "time": time.strftime("%Y-%m-%d %H:%M:%S")} print(json.dumps(rec), flush=True) - with open(LOG, "a") as f: - f.write(json.dumps(rec) + "\n") + H.append_log("bench.jsonl", rec) del mk, patches, raw gc.collect() del wts diff --git a/code/tt_depthpro2/tests/mk_enc_e2e.py b/code/tt_depthpro2/tests/mk_enc_e2e.py index 7dcb56465c6b6d3dd4be222e86825974c2de5da9..2159ae585db0364bb001b368e0dc92d54fdd5f35 100644 --- a/code/tt_depthpro2/tests/mk_enc_e2e.py +++ b/code/tt_depthpro2/tests/mk_enc_e2e.py @@ -20,9 +20,9 @@ sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..", from tt_depthpro2.reference import model as ref # noqa: E402 from tt_depthpro2.tests import baseline_helpers as BH # noqa: E402 +from tt_depthpro2.tests import mk_enc_ref as H # noqa: E402 CASES = ("img_vga", "clip4_240x320", "img_375x500_pad") -LOG = "/home/ubuntu/experiments/tt-models/logs/depthpro2/mk_enc/e2e.jsonl" def main(): @@ -76,8 +76,7 @@ def main(): "budget": budget, "budget_from": why, "repeat_bitexact": bool(torch.equal(inv, inv2)), "call_ms": call_ms, "passed": ok, "time": time.strftime("%Y-%m-%d %H:%M:%S")} print(json.dumps(rec), flush=True) - with open(LOG, "a") as f: - f.write(json.dumps(rec) + "\n") + H.append_log("e2e.jsonl", rec) m.close() finally: ttnn.close_device(dev) diff --git a/code/tt_depthpro2/tests/mk_enc_heldout.py b/code/tt_depthpro2/tests/mk_enc_heldout.py new file mode 100644 index 0000000000000000000000000000000000000000..5b8070d8c16f8d2f8f6fcec7ac1df72428c8492c --- /dev/null +++ b/code/tt_depthpro2/tests/mk_enc_heldout.py @@ -0,0 +1,110 @@ +# SPDX-License-Identifier: Apache-2.0 +"""Held-out check of the device engines through DepthPro2Device (default enc=mk, dec=mk, fov=mk) against Apple's +float32 outputs, with the SPEC section 5 metric and gates: PCC >= 0.999 (0.99 when the reference's valid cv < 0.15), +AbsRel_valid <= max(2 x Apple's bf16 AbsRel, 0.01), f_px within max(1 %, 2 x Apple's bf16 f_px error). + +Inputs: ``$DEPTHPRO2_HELDOUT/____fp32.safetensors`` (``input_u8``, ``inverse_depth``, ``focallength_px``; +the verifier's golden_heldout.py) and, when present, ``..__bf16.safetensors`` (Apple's own bf16 run: the budget). +Weights: ``DEPTHPRO2_TEST_WEIGHTS`` (parent of DepthPro2-/ and DepthPro2-focal/). + + bin/devrun -t 1800 -- python -u bundles/depthpro2/code/tt_depthpro2/tests/mk_enc_heldout.py --sizes S,B,L,H +""" + +from __future__ import annotations + +import argparse +import json +import os +import sys +import time + +import torch + +sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..", ".."))) + +from tt_depthpro2.reference import model as ref # noqa: E402 +from tt_depthpro2.tests import mk_enc_ref as H # noqa: E402 + +CASES = ("ho_images_vga", "ho_kropa_vga", "ho_example_portrait", "ho_clip4_vga") + + +def metrics(inv: torch.Tensor, r: torch.Tensor) -> dict: + a, b = inv.double().flatten(), r.double().flatten() + p = torch.corrcoef(torch.stack([a, b]))[0, 1].item() + m = b >= 0.01 * b.max() + ad, bd = 1 / a[m].clamp_min(1e-9), 1 / b[m] + v = b[m] + return {"pcc": p, "absrel_valid": ((ad - bd).abs() / bd).mean().item(), "cv": (v.std() / v.mean()).item()} + + +def main(): + ap = argparse.ArgumentParser() + ap.add_argument("--sizes", default="S,B,L,H") + ap.add_argument("--cases", default=",".join(CASES)) + ap.add_argument("--engine", default="enc=mk,dec=mk,fov=mk") + ap.add_argument("--tag", default="") + args = ap.parse_args() + root = os.environ.get("DEPTHPRO2_HELDOUT") + if not root or not os.path.isdir(root): + raise SystemExit("set DEPTHPRO2_HELDOUT to the directory of ____fp32.safetensors") + import ttnn + from safetensors.torch import load_file + from tt_depthpro2.tt.model import DepthPro2Device + + dev = ttnn.open_device(device_id=0, dispatch_core_config=ttnn.DispatchCoreConfig(ttnn.DispatchCoreType.ETH), + l1_small_size=32768, trace_region_size=256 << 20) + fw = H.load_weights("fov") + allok = True + try: + for size in args.sizes.split(","): + items = [] + for c in args.cases.split(","): + p = os.path.join(root, f"{c}__{size}__fp32.safetensors") + if not os.path.exists(p): + continue + g = load_file(p) + pb = os.path.join(root, f"{c}__{size}__bf16.safetensors") + items.append((c, g, load_file(pb) if os.path.exists(pb) else None)) + if not items: + continue + buckets = sorted({tuple(g["input_u8"].shape[-3:-1]) for _, g, _ in items}) + frames = sorted({int(g["input_u8"].shape[0]) if g["input_u8"].ndim == 4 else 1 for _, g, _ in items}) + m = DepthPro2Device(dev, size, H.load_weights(size), fw, buckets=buckets, max_frames=max(frames), + frames=tuple(frames), engine=args.engine) + for c, g, gb in items: + u8 = g["input_u8"].numpy() + x = ref.preprocess(u8) + T, _, h, w = x.shape + inv = m.inverse_depth(ref.pad_to_multiple(x))[:, :h, :w] + inv2 = m.inverse_depth(ref.pad_to_multiple(x))[:, :h, :w] + r = g["inverse_depth"].reshape(T, h, w) + met = metrics(inv, r) + y = ref.fov_resize(x) + deg = ref.fov_logits_to_deg(m.fov_logits(y), (h, w), tuple(y.shape[-2:])) + f = float(ref.median_focal_length_px(deg, h, w)) + f_rel = abs(f / float(g["focallength_px"].reshape(-1)[0]) - 1) + bf_abs, bf_f = None, None + if gb is not None: + bf_abs = metrics(gb["inverse_depth"].reshape(T, h, w), r)["absrel_valid"] + bf_f = abs(float(gb["focallength_px"].reshape(-1)[0]) / float(g["focallength_px"].reshape(-1)[0]) - 1) + pcc_gate = 0.99 if met["cv"] < 0.15 else 0.999 + budget = max(2 * bf_abs, 0.01) if bf_abs is not None else 0.01 + f_budget = max(0.01, 2 * bf_f) if bf_f is not None else 0.01 + ok = (met["pcc"] >= pcc_gate and met["absrel_valid"] <= budget and f_rel <= f_budget + and bool(torch.equal(inv, inv2)) and bool(torch.isfinite(inv).all())) + allok = allok and ok + rec = {"tag": args.tag, "size": size, "case": c, "engine": args.engine, "pcc": met["pcc"], + "pcc_gate": pcc_gate, "cv": met["cv"], "absrel": met["absrel_valid"], "budget": budget, + "apple_bf16_absrel": bf_abs, "f_rel": f_rel, "f_budget": f_budget, + "repeat_bitexact": bool(torch.equal(inv, inv2)), "passed": ok, + "time": time.strftime("%Y-%m-%d %H:%M:%S")} + print(json.dumps(rec), flush=True) + H.append_log("heldout.jsonl", rec) + m.close() + finally: + ttnn.close_device(dev) + print("ALL PASS" if allok else "SOME FAILED", flush=True) + + +if __name__ == "__main__": + main() diff --git a/code/tt_depthpro2/tests/mk_enc_ref.py b/code/tt_depthpro2/tests/mk_enc_ref.py index 9c4554f331d5d11e34d48fddf927f34c2e946c4b..80e41141f6c4e223d3d67e639a9a6db34fefe7ab 100644 --- a/code/tt_depthpro2/tests/mk_enc_ref.py +++ b/code/tt_depthpro2/tests/mk_enc_ref.py @@ -13,14 +13,38 @@ import torch.nn.functional as F from tt_depthpro2.reference import model as R -ROOT = "/home/ubuntu/experiments/tt-models" -GOLDEN = os.path.join(ROOT, "assets/depthpro2/golden") -WEIGHTS = "/mnt/chang/models/apple/DepthPro2-{}/model.safetensors" +_CODE = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) # code/ (the package's parent) +#: parent of DepthPro2-/ and DepthPro2-focal/ (serve-pkg's host_helpers names; else code/weights) +WEIGHTS_ROOT = (os.environ.get("DEPTHPRO2_TEST_WEIGHTS") or os.environ.get("DEPTHPRO2_WEIGHTS_DIR") + or os.path.join(_CODE, "weights")) +#: Apple's float32 goldens __.safetensors (else code/golden) +GOLDEN = os.environ.get("DEPTHPRO2_GOLDEN") or os.path.join(_CODE, "golden") +#: optional: the clean-room float32 reference outputs of make_baseline_refs.py (cases without an official golden) +BASELINE_REF = os.environ.get("DEPTHPRO2_BASELINE_REF", "") +#: optional: where the dev scripts append their jsonl records (unset: print only) +LOG_DIR = os.environ.get("DEPTHPRO2_MK_ENC_LOGDIR", "") P = R.NUM_PREFIX +def weights_path(size: str) -> str: + return os.path.join(WEIGHTS_ROOT, f"DepthPro2-{'focal' if size == 'fov' else size}", "model.safetensors") + + def load_weights(size: str) -> Dict[str, torch.Tensor]: - return R.load_safetensors(WEIGHTS.format("focal" if size == "fov" else size)) + p = weights_path(size) + if not os.path.isfile(p): + raise FileNotFoundError(f"{p} not found: set DEPTHPRO2_TEST_WEIGHTS to the parent of DepthPro2-/") + return R.load_safetensors(p) + + +def append_log(name: str, rec: dict) -> None: + """Append ``rec`` to ``$DEPTHPRO2_MK_ENC_LOGDIR/`` (no-op when the variable is unset).""" + if LOG_DIR: + import json + + os.makedirs(LOG_DIR, exist_ok=True) + with open(os.path.join(LOG_DIR, name), "a") as f: + f.write(json.dumps(rec) + "\n") def load_case(case: str, size: str) -> Dict[str, torch.Tensor]: @@ -28,8 +52,10 @@ def load_case(case: str, size: str) -> Dict[str, torch.Tensor]: from safetensors.torch import load_file p = os.path.join(GOLDEN, f"{case}__{size}.safetensors") + if not os.path.exists(p) and BASELINE_REF: + p = os.path.join(BASELINE_REF, f"{case}__{size}.safetensors") if not os.path.exists(p): - p = os.path.join(ROOT, "assets/depthpro2/baseline_ref", f"{case}__{size}.safetensors") + raise FileNotFoundError(f"no golden {case}__{size}: set DEPTHPRO2_GOLDEN (or DEPTHPRO2_BASELINE_REF)") return load_file(p) diff --git a/code/tt_depthpro2/tests/mk_enc_soak.py b/code/tt_depthpro2/tests/mk_enc_soak.py index 8ae60c4c6533ff20d1d16d6c937c75bc85ae589b..0b84ca12d5450ef34fc8213c8d2e078133073779 100644 --- a/code/tt_depthpro2/tests/mk_enc_soak.py +++ b/code/tt_depthpro2/tests/mk_enc_soak.py @@ -23,7 +23,6 @@ from tt_depthpro2.tests import mk_enc_ref as H # noqa: E402 from tt_depthpro2.tt.mk_enc import arena as A # noqa: E402 from tt_depthpro2.tt.mk_enc.program import MkEnc, MkEncWeights # noqa: E402 -LOG = "/home/ubuntu/experiments/tt-models/logs/depthpro2/mk_enc/soak.jsonl" def main(): @@ -98,8 +97,7 @@ def main(): finally: rec["end"] = time.strftime("%Y-%m-%d %H:%M:%S") print("REC " + json.dumps(rec), flush=True) - with open(LOG, "a") as f: - f.write(json.dumps(rec) + "\n") + H.append_log("soak.jsonl", rec) ttnn.close_device(dev) diff --git a/code/tt_depthpro2/tests/mk_enc_sweep.py b/code/tt_depthpro2/tests/mk_enc_sweep.py index fe8bc4e93e83c118eede8681fb500b91aa74258f..00c8a6dce35440cebe770caf1db2b8ac2ca9b2e5 100644 --- a/code/tt_depthpro2/tests/mk_enc_sweep.py +++ b/code/tt_depthpro2/tests/mk_enc_sweep.py @@ -26,15 +26,15 @@ from tt_depthpro2.tt import StageShape # noqa: E402 from tt_depthpro2.tt.mk_enc import arena as A # noqa: E402 from tt_depthpro2.tt.mk_enc.program import MkEnc, MkEncWeights # noqa: E402 -ROOT = "/home/ubuntu/experiments/tt-models" -LOG = os.path.join(ROOT, "logs/depthpro2/mk_enc/sweep.jsonl") +#: optional: directory with the ttnn baseline's bench.jsonl / bench_r2.jsonl (traced ENC times to compare with) +BASELINE_BENCH = os.environ.get("DEPTHPRO2_BASELINE_BENCH", "") def baseline_ms(size, hp, wp, T): best = None for f in ("bench.jsonl", "bench_r2.jsonl"): - p = os.path.join(ROOT, "logs/depthpro2/baseline", f) - if not os.path.exists(p): + p = os.path.join(BASELINE_BENCH, f) + if not BASELINE_BENCH or not os.path.exists(p): continue for line in open(p): d = json.loads(line) @@ -154,8 +154,7 @@ def main(): finally: rec["time"] = time.strftime("%Y-%m-%d %H:%M:%S") print("REC " + json.dumps(rec), flush=True) - with open(LOG, "a") as f: - f.write(json.dumps(rec) + "\n") + H.append_log("sweep.jsonl", rec) gc.collect() ttnn.close_device(dev) diff --git a/code/tt_depthpro2/tests/mk_fov_check.py b/code/tt_depthpro2/tests/mk_fov_check.py index e2f49fcac82868d736f605ee36d75c978f725aad..99126eab7cb7dbb0adb6cc015620a413f3262b95 100644 --- a/code/tt_depthpro2/tests/mk_fov_check.py +++ b/code/tt_depthpro2/tests/mk_fov_check.py @@ -24,7 +24,6 @@ from tt_depthpro2.tt import StageShape # noqa: E402 from tt_depthpro2.tt.mk_enc import arena as A # noqa: E402 CASES = ("img_vga", "img_384x512", "clip4_240x320", "img_375x500_pad") -LOG = "/home/ubuntu/experiments/tt-models/logs/depthpro2/mk_enc/fov.jsonl" def trace_ms(dev, fn, reps=5): @@ -108,8 +107,7 @@ def main(): ok = ok and rec["passed"] rec["time"] = time.strftime("%Y-%m-%d %H:%M:%S") print(json.dumps(rec), flush=True) - with open(LOG, "a") as fh: - fh.write(json.dumps(rec) + "\n") + H.append_log("fov.jsonl", rec) del em, fp if args.bench_t4: g, _ = BH.load_golden("img_vga", "S") diff --git a/code/tt_depthpro2/tests/test_device_mk_enc.py b/code/tt_depthpro2/tests/test_device_mk_enc.py index f2d1300090079e602914d1916883185f655e9cb9..08d8a4c5e8a7ff5a3bb1245ab5e21769083592e3 100644 --- a/code/tt_depthpro2/tests/test_device_mk_enc.py +++ b/code/tt_depthpro2/tests/test_device_mk_enc.py @@ -19,6 +19,9 @@ from tt_depthpro2.reference import model as R from tt_depthpro2.tests import mk_enc_ref as H ttnn = pytest.importorskip("ttnn") +if not os.path.isfile(H.weights_path("S")) or not os.path.isdir(H.GOLDEN): + pytest.skip("DepthPro2 weights / goldens not found: set DEPTHPRO2_TEST_WEIGHTS (parent of DepthPro2-/) and " + "DEPTHPRO2_GOLDEN (Apple's float32 goldens)", allow_module_level=True) #: minimum tap PCC vs the float32 golden (bf16 weights / activations; the official bf16 run drifts similarly) TAP_PCC = float(os.environ.get("MK_ENC_TAP_PCC", "0.995")) diff --git a/code/tt_depthpro2/tests/test_host_api.py b/code/tt_depthpro2/tests/test_host_api.py index cf1f5151d41d87e6b9cd37c1b608000dc0821435..e8951cab9c0affe18774502bd3edd0ae83d58cd3 100644 --- a/code/tt_depthpro2/tests/test_host_api.py +++ b/code/tt_depthpro2/tests/test_host_api.py @@ -258,6 +258,44 @@ def test_engine_arguments(): fov_weights_dir=str(WEIGHTS_ROOT)) +class EnvRecorder(Recorder): + """Records ``DEPTHPRO2_MK_ENC_OPTS`` as the engine is built.""" + + opts = None + + def __init__(self, device, size, size_weights, fov_weights, buckets, max_frames, engine=None, frames=None): + import os + + EnvRecorder.opts = os.environ.get(C.MK_ENC_OPTS_ENV) + super().__init__(device, size, size_weights, fov_weights, buckets, max_frames, engine, frames) + + +def test_enc_precision_maps_to_mk_enc_options(monkeypatch): + need_weights("S") + from tt_depthpro2 import api as A + + monkeypatch.setattr(A._device, "describe_device", lambda device, device_id=None: {"dispatch": "test"}) + monkeypatch.setenv(C.MK_ENC_OPTS_ENV, "exp=1,inx32=1") # an A/B knob of the megakernel: kept; inx32 / klo set + for prec, want in (("fast", "exp=1,inx32=0,klo=0"), ("high", "exp=1")): + m = DepthPro2.from_pretrained("S", resolutions="qvga", window=2, enc_precision=prec, backend="tt", + device=object(), engine_factory=EnvRecorder, weights_dir=str(WEIGHTS_ROOT), + fov_weights_dir=str(WEIGHTS_ROOT), warmup=False) + try: + cfg = m.info["configuration"] + assert EnvRecorder.opts == want and cfg["mk_enc_opts"] == want, (prec, EnvRecorder.opts) + assert cfg["enc_precision"] == prec and cfg["env"]["DEPTHPRO2_ENC_PRECISION"] == prec + finally: + m.close() + # the CPU backend leaves the variable alone + m = DepthPro2.from_pretrained("S", resolutions="qvga", window=2, enc_precision="fast", backend="cpu", + engine_factory=EnvRecorder, weights_dir=str(WEIGHTS_ROOT), + fov_weights_dir=str(WEIGHTS_ROOT), warmup=False) + try: + assert EnvRecorder.opts == "exp=1" and m.info["configuration"]["mk_enc_opts"] is None + finally: + m.close() + + def test_warmup_and_no_fov(): need_weights("S", fov=False) with new_cpu_model("S", resolutions="qvga", window=2, overlap=0, fov=False, warmup=True) as m: diff --git a/code/tt_depthpro2/tests/test_host_config.py b/code/tt_depthpro2/tests/test_host_config.py index 9edf3b3390ab09099f1176a695d80b206e805e71..a8e3740d47bbda9f98fe18b956a7046c84a122f4 100644 --- a/code/tt_depthpro2/tests/test_host_config.py +++ b/code/tt_depthpro2/tests/test_host_config.py @@ -149,3 +149,21 @@ def test_server_load_config_refuses(over): with pytest.raises(RuntimeError): load_config(_server_env(**over)) + + +def test_enc_precision_setting_and_mk_enc_options(): + assert C.DEFAULT_ENC_PRECISION == "high" and C.resolve_config(env={}).enc_precision == "high" + assert C.resolve_config(env={"DEPTHPRO2_ENC_PRECISION": " Fast "}).enc_precision == "fast" + assert C.resolve_config(enc_precision="fast", env={"DEPTHPRO2_ENC_PRECISION": "high"}).enc_precision == "fast" + with pytest.raises(ValueError, match="DEPTHPRO2_ENC_PRECISION"): + C.resolve_config(env={"DEPTHPRO2_ENC_PRECISION": "medium"}) + with pytest.raises(ValueError, match="enc_precision"): + C.resolve_config(enc_precision="bf16", env={}) + assert C.resolve_config(env={}).as_env()["DEPTHPRO2_ENC_PRECISION"] == "high" + # fast = the encoder megakernel's v1 options; high drops them (per-size defaults); other keys are kept + assert C.mk_enc_options("fast") == "inx32=0,klo=0" + assert C.mk_enc_options("fast", "exp=1, inx32=1,klo=2") == "exp=1,inx32=0,klo=0" + assert C.mk_enc_options("high", "inx32=0,klo=0,ring_first=1") == "ring_first=1" + assert C.mk_enc_options("high") == "" and C.mk_enc_options("high", "") == "" + with pytest.raises(ValueError): + C.mk_enc_options("medium") diff --git a/code/tt_depthpro2/tests/test_host_server.py b/code/tt_depthpro2/tests/test_host_server.py index 2330f414646d330907319c005f7d9abe0cefe43c..ae2e2b85d31221a143fca13f70c2574c6b6bb920 100644 --- a/code/tt_depthpro2/tests/test_host_server.py +++ b/code/tt_depthpro2/tests/test_host_server.py @@ -110,6 +110,9 @@ def test_routes_health_info(client): assert "Research Model License" in info["license"]["notice"] cfg = client.get("/config").json() assert cfg["configuration"]["window"] == 2 and cfg["limits"]["max_streams"] == 1 + # the encoder precision is reported (default high; the CPU backend sets no megakernel options) + assert info["configuration"]["enc_precision"] == cfg["configuration"]["enc_precision"] == "high" + assert cfg["configuration"]["env"]["DEPTHPRO2_ENC_PRECISION"] == "high" assert client.get("/v1/models").json()["data"][0]["id"] == "apple/DepthPro2-S" @@ -290,6 +293,9 @@ def test_startup_refuses_a_bad_configuration(monkeypatch): with pytest.raises(RuntimeError, match="DEPTHPRO2_WINDOW"): with client_with(monkeypatch, DEPTHPRO2_WINDOW="99"): pass + with pytest.raises(RuntimeError, match="DEPTHPRO2_ENC_PRECISION"): + server.load_config({"DEPTHPRO2_ENC_PRECISION": "medium"}) + assert server.load_config({"DEPTHPRO2_ENC_PRECISION": "fast"}).model.enc_precision == "fast" assert server.app.state.dp2.error is None # restored by client_with diff --git a/code/tt_depthpro2/tt/mk_enc/geometry.py b/code/tt_depthpro2/tt/mk_enc/geometry.py index f4a0a6d45493b70e071c98168a99adf7d28ebc78..6a0c5ca1f92edd13225e376c99bebc45aed0a99d 100644 --- a/code/tt_depthpro2/tt/mk_enc/geometry.py +++ b/code/tt_depthpro2/tt/mk_enc/geometry.py @@ -52,6 +52,12 @@ SIZE_CFG = { } #: default slots per row and wave (L1 budget, MK_LOG 1.3) RB_DEFAULT = {"S": 4, "B": 2, "L": 2, "H": 2} +#: LN-gather precision (round 10): fp32 x tiles (tf32 operand of QKV / FC1) instead of bf16(x). v1.1: L only (the +#: fresh held-out set: S and the FOV trunk regressed on multi-frame clips with it, MK_LOG round 11); every other size +#: and the FOV trunk keep v1 numerics. DEPTHPRO2_MK_ENC_OPTS inx32= / klo= override. +INX32_DEFAULT = {"S": False, "B": False, "L": True, "H": False} +#: keys in hi / lo (round 10): 0 off, 1 the special (prefix / pool) key tile of each segment, 2 every key +KLO_DEFAULT = {"S": 0, "B": 0, "L": 1, "H": 0} #: blocks whose attention logits reach |s| > 1e3 on the goldens (S blk 0: 2.2e6, B 0: 2.1e5, L 1: 1.2e4, H 0 / 1: #: 1.9e4 / 1.1e4, FOV trunk 0: 2.6e6; every other block < 700): they use the two-step (fp32-accurate) row max GIANT = {"S": (0,), "B": (0,), "L": (1,), "H": (0, 1), "fov": (0,)} @@ -106,6 +112,9 @@ class Geometry: giant_all: bool = False # two-step row max in every block alias_st: bool = True # the attention state FIFO (fp32) is a view of CB_INX's memory (bf16 LN gather) fc1p_ok: bool = True # allow the pipelined FC1 epilogue (rb == 2, GELU) + inx32: Optional[bool] = None # LN-gather x tiles in fp32 (tf32 operand of QKV / FC1); None: per size (round 10) + klo: Optional[int] = None # keys in hi / lo: 0 off, 1 special key tiles, 2 every key; None: per size (round 10) + ring_first: bool = False # L1 budget: shrink the weight ring before the K / V chunk derived: Dict = field(default_factory=dict) def __post_init__(self): @@ -134,6 +143,10 @@ class Geometry: self.NC = self.gx * self.gy if self.rb == 0: self.rb = RB_DEFAULT[self.size] + if self.inx32 is None: # the FOV trunk keeps v1 numerics whatever its size key + self.inx32 = False if self.mode == "fov" else INX32_DEFAULT[self.size] + if self.klo is None: + self.klo = 0 if self.mode == "fov" else KLO_DEFAULT[self.size] if self.rb not in (1, 2, 4): raise ValueError(f"rb={self.rb}") self.W = -(-self.Mt // (self.R * self.rb)) @@ -253,8 +266,8 @@ class Geometry: f = lambda i, n, u: (((i, "fp32", u),), n * T32) # noqa: E731 return [ b(CB_W, self.ring * PAGE_TILES), - ] + ([(((CB_INX, "bf16", False), (CB_ST, "fp32", True)), self.inx_bytes)] if self.alias_st else [ - (((CB_INX, "bf16", False),), self.rb * self.DT * T16), + ] + ([(((CB_INX, self.fix, False), (CB_ST, "fp32", True)), self.inx_bytes)] if self.alias_st else [ + (((CB_INX, self.fix, False),), self.rb * self.DT * self.tix), f(CB_ST, (self.qb + 1) * 4, True), ]) + [ (((CB_INF, "bf16", False), (CB_KV, "bf16", False)), self.inf_tiles * T16), @@ -262,8 +275,8 @@ class Geometry: f(CB_X, 2 * rb * nxm, True), f(CB_SUMS, 4 * rb, False), f(CB_STO, 1, False), - b(CB_OUTX, nxm * rb), - b(CB_EXT, rb), + (((CB_OUTX, self.fix, False),), nxm * rb * self.tix), + (((CB_EXT, self.fix, False),), rb * self.tix), f(CB_RSTD, rb, True), (((CB_RAW, "fp32", True), (CB_S32, "fp32", True), (CB_S32F, "fp32", False), (CB_AP, "fp32", False)), max(8, self.kc) * T32), @@ -282,6 +295,7 @@ class Geometry: f(CB_MFN, 3, True), f(CB_MF1, 1, True), b(CB_SC, 6), # mu / rstd / std hi + lo: every value is a bf16 (hi = bf16(v), lo = bf16(v - hi)) + ] + ([b(CB_OUTLO, 2 * rb)] if self.klo else []) + [ b(CB_AO, self.qb * 2), (((CB_SYNC, "raw", False),), SYNC_BYTES), b(CB_TOK, 1), @@ -290,7 +304,17 @@ class Geometry: @property def inf_tiles(self) -> int: """CB_INF tiles (the wave gathers' capacity), rounded up to whole K / V chunks (4 KC tiles)""" - return -(-self.inf_cap // (4 * self.kc)) * (4 * self.kc) + return -(-self.inf_cap // self.cht) * self.cht + + @property + def cht(self) -> int: + """tiles of one K / V chunk: [K 2 kc | V 2 kc | K lo]""" + return 4 * self.kc + (2 * self.kc if self.klo == 2 else 2 if self.klo == 1 else 0) + + @property + def klo_rows(self) -> int: + """row tiles of the k-lo staging""" + return self.Mt if self.klo == 2 else self.T + 1 @property def inf_cap(self) -> int: @@ -298,11 +322,20 @@ class Geometry: @property def inx_bytes(self) -> int: - """CB_INX bytes: the LN gather (rb * DT bf16) or the attention state FIFO ((qb + 1) * 4 fp32 tiles), whole - 16 KB states""" - need = max(self.rb * self.DT * T16, (self.qb + 1) * 4 * T32) + """CB_INX bytes: the LN gather (rb * DT tiles, fp32 with inx32 else bf16) or the attention state FIFO + ((qb + 1) * 4 fp32 tiles), whole 16 KB states""" + need = max(self.rb * self.DT * self.tix, (self.qb + 1) * 4 * T32) return -(-need // (4 * T32)) * (4 * T32) + @property + def fix(self) -> str: + return "fp32" if self.inx32 else "bf16" + + @property + def tix(self) -> int: + """bytes of one LN-gather tile (CB_INX / CB_OUTX / CB_EXT)""" + return T32 if self.inx32 else T16 + def cb_bytes(self) -> int: return sum(n for _, n in self.cb_table()) @@ -310,6 +343,14 @@ class Geometry: """shrink, in order: the K / V chunk (32 -> 16 key tiles), the weight ring (10 -> 6 pages), the chunk again (16 -> 8), then the q tiles per attention job""" steps = 0 + if self.ring_first and self.cb_bytes() > L1_BUDGET: # keep the largest K / V chunk, the ring as large as fits + kc0, ring0 = self.kc, self.ring + for kc in (kc0, kc0 // 2, kc0 // 4): + for ring in range(ring0, 5, -2): + self.kc, self.ring = kc, ring + if self.cb_bytes() <= L1_BUDGET: + return + self.kc, self.ring = kc0, ring0 while self.cb_bytes() > L1_BUDGET: if self.kc > 16: self.kc //= 2 @@ -345,7 +386,9 @@ class Geometry: "ME_TAP0": self.taps[0], "ME_TAP1": self.taps[1], "ME_TAP2": self.taps[2], "ME_TAP3": self.taps[3], "ME_NXM": self.NXM, "ME_NHM": self.NHM, "ME_NFM": self.NFM, "ME_G": self.G, "ME_FB": self.FB, "ME_FC1P": int(self.fc1p), "ME_PROBE": int(self.probe), "ME_PROF": int(self.prof), "ME_RING": self.ring, "ME_NC": self.NC, "ME_INF": self.inf_cap, "ME_INFT": self.inf_tiles, - "ME_INXT": (self.inx_bytes if self.alias_st else self.rb * self.DT * T16) // T16, + "ME_INXT": (self.inx_bytes if self.alias_st else self.rb * self.DT * self.tix) // self.tix, + "ME_INX32": int(bool(self.inx32)), + "ME_KLO": int(self.klo), "ME_ABI_HOST": ME_ABI, # noqa: F821 (parsed from me_defs.hpp) } return [(k, str(v)) for k, v in d.items()] diff --git a/code/tt_depthpro2/tt/mk_enc/kernels/me_brisc.cpp b/code/tt_depthpro2/tt/mk_enc/kernels/me_brisc.cpp index 6eeafcdad44cad040712a5b82433a9c97ba6f591..f2163265dc5aa0aea6735fad017d7d988cad1143 100644 --- a/code/tt_depthpro2/tt/mk_enc/kernels/me_brisc.cpp +++ b/code/tt_depthpro2/tt/mk_enc/kernels/me_brisc.cpp @@ -241,7 +241,7 @@ ME_NOINL void ln_gather() { cb_wait_front(CB_STO, 1); cb_wait_front(CB_OUTX, NXM * RB); row_data(get_read_ptr(CB_STO), cb_base(CB_STAT) + me.x * T32, T32, true); - row_data(get_read_ptr(CB_OUTX), cb_base(CB_INX) + me.n0 * RB * T16, me.nx * RB * T16, true); + row_data(get_read_ptr(CB_OUTX), cb_base(CB_INX) + me.n0 * RB * TIX, me.nx * RB * TIX, true); row_flag(W_IX + me.x, SRC_IX, gen_ix); cb_pop_front(CB_STO, 1); cb_pop_front(CB_OUTX, NXM * RB); @@ -330,16 +330,28 @@ void qkv_dm(uint32_t l) { for (uint32_t jh = 0; jh < me.nh; ++jh) { const uint32_t u = me.h0 + jh, ty = unit_type(u), h = unit_head(u); const uint32_t addr = ca(ty == 0 ? K_Q : ty == 1 ? K_K : K_V); + const bool lo = ty == 1 && klo_wave(l, me.kd); cb_wait_front(CB_OUT, 2 * RB); - const uint32_t a = get_read_ptr(CB_OUT); + if (lo) { + cb_wait_front(CB_OUTLO, 2 * RB); + } + const uint32_t a = get_read_ptr(CB_OUT), alo = lo ? get_read_ptr(CB_OUTLO) : 0; for (uint32_t s = 0; s < RB; ++s) { if ((qkv_mask(l, me.kd[s]) >> ty) & 1u) { wr16(addr, me.ri[s] * DT + 2 * h, a + (2 * s) * T16); wr16(addr, me.ri[s] * DT + 2 * h + 1, a + (2 * s + 1) * T16); + if (lo && (KLO == 2 || me.kd[s] != KD_PATCH)) { + const uint32_t r = klo_row(me.ri[s]); + wr16(ca(K_KLO), r * DT + 2 * h, alo + (2 * s) * T16); + wr16(ca(K_KLO), r * DT + 2 * h + 1, alo + (2 * s + 1) * T16); + } } } noc_async_writes_flushed(); cb_pop_front(CB_OUT, 2 * RB); + if (lo) { + cb_pop_front(CB_OUTLO, 2 * RB); + } } } @@ -373,8 +385,8 @@ void wave_end_dm(bool store) { uint32_t kv_count = 0; // K / V chunks of this column so far (identical on its cores) void kv_chunk(const Item& it, uint32_t p0, uint32_t nk) { - cb_reserve_back(CB_KV, 4 * KC); - const uint32_t ak = get_write_ptr(CB_KV), av = ak + 2 * KC * T16; + cb_reserve_back(CB_KV, CHT); + const uint32_t ak = get_write_ptr(CB_KV), av = ak + 2 * KC * T16, al = av + 2 * KC * T16; if (me.role & R_KVR) { const uint32_t ka = ca(K_K), va = ca(K_V); for (uint32_t j = 0; j < nk; ++j) { @@ -383,6 +395,11 @@ void kv_chunk(const Item& it, uint32_t p0, uint32_t nk) { rd16(ka, key * DT + 2 * it.h + 1, ak + (2 * j + 1) * T16); rd16(va, key * DT + 2 * it.h, av + (2 * j) * T16); rd16(va, key * DT + 2 * it.h + 1, av + (2 * j + 1) * T16); + if (KLO == 2 || (KLO == 1 && p0 + j == 0)) { + const uint32_t r = klo_row(key), o = KLO == 2 ? 2 * j : 0; + rd16(ca(K_KLO), r * DT + 2 * it.h, al + o * T16); + rd16(ca(K_KLO), r * DT + 2 * it.h + 1, al + (o + 1) * T16); + } } for (uint32_t y = 0; y + 1 < R; ++y) { wait_ge(W_KCRED + y, kv_count + 1); @@ -392,6 +409,11 @@ void kv_chunk(const Item& it, uint32_t p0, uint32_t nk) { const uint32_t kx = rt(A_KRX), y0 = rt(A_KY0), y1 = rt(A_KY1); noc_async_write_multicast(ak, mcast_addr(kx, y0, kx, y1, ak), 2 * nk * T16, R - 1, true); noc_async_write_multicast(av, mcast_addr(kx, y0, kx, y1, av), 2 * nk * T16, R - 1, true); + if (KLO == 2) { + noc_async_write_multicast(al, mcast_addr(kx, y0, kx, y1, al), 2 * nk * T16, R - 1, true); + } else if (KLO == 1 && p0 == 0) { + noc_async_write_multicast(al, mcast_addr(kx, y0, kx, y1, al), 2 * T16, R - 1, true); + } const uint32_t srcw = sync_addr(W_KSRC); *reinterpret_cast(srcw) = kv_count + 1; noc_semaphore_set_multicast(srcw, mcast_addr(kx, y0, kx, y1, sync_addr(W_KV)), R - 1); @@ -402,7 +424,7 @@ void kv_chunk(const Item& it, uint32_t p0, uint32_t nk) { wait_ge(W_KV, kv_count + 1); } ++kv_count; - cb_push_back(CB_KV, 4 * KC); + cb_push_back(CB_KV, CHT); } void att_reads(const Item& it) { diff --git a/code/tt_depthpro2/tt/mk_enc/kernels/me_defs.hpp b/code/tt_depthpro2/tt/mk_enc/kernels/me_defs.hpp index 048c71c1f91686b06c65c58a4652e575a1cc09b3..8433e6dd5aa9c25f5edc14d1e2ef961f162d95b7 100644 --- a/code/tt_depthpro2/tt/mk_enc/kernels/me_defs.hpp +++ b/code/tt_depthpro2/tt/mk_enc/kernels/me_defs.hpp @@ -12,7 +12,7 @@ namespace mex { // tiles. geometry.py passes the value it parsed at import as ME_ABI_HOST: kernel sources edited under a running // process (serve-pkg smoke 2026-11-28 22:10: T > 1 programs read a common arg the old host did not pass) fail to // compile instead of computing garbage. -constexpr uint32_t ME_ABI = 3; +constexpr uint32_t ME_ABI = 4; #if defined(ME_ABI_HOST) static_assert(ME_ABI == ME_ABI_HOST, "mk_enc: kernel sources differ from the host code this process imported (edited " "after import): restart the process"); @@ -60,6 +60,8 @@ constexpr uint32_t CB_S32 = 33; // fp32 score region (attention; shares CB_RAW // read by copy (UnpackToDestFp32); views CB_S32F / CB_AP; P overwrites S in place. // Every view pushes / pops exactly KC tiles per use, so all stay at the region base. constexpr uint32_t CB_MF1 = 34; // fp32 [1] first-step row max m1, broadcast (UnpackToDestFp32) +constexpr uint32_t CB_OUTLO = 36; // bf16 [2 RB] k - bf16(k) of a k unit (ME_KLO waves with a special key tile; its own CB so + // that CB_OUT keeps fixed 2 RB-tile pushes: out-of-order packs never straddle its end) constexpr uint32_t CB_SC = 35; // fp32 [6] LN statistics of the slots in columns s: mu, rstd, std, each hi / lo (FPU operand) // ---------------------------------------------------------------- constants (CB_CONST bf16 tile index) @@ -188,7 +190,9 @@ constexpr uint32_t K_ARENA0 = 27; // 27 .. 27 + L - 1: block arenas constexpr uint32_t K_PROBE = 59; // fp32 [N_PROBE * 32, 32] TILE debug probes constexpr uint32_t K_PROF = 60; // uint32 [NC, PROF_WORDS] ROW_MAJOR time stamps (ME_PROF builds) constexpr uint32_t K_VF = 61; // uint32 [32, 32] TILE: element 0 = valid frames n, element 1 = fp32 bits of 1 / n -constexpr uint32_t N_COMMON_ARGS = 62; +constexpr uint32_t K_KLO = 62; // bf16 k - bf16(k) staging (ME_KLO): 1: rows of the special key tiles (frame prefix + // tiles t < T at row tile t, the pool tile at row tile T); 2: every row tile (as K_K) +constexpr uint32_t N_COMMON_ARGS = 63; // ---------------------------------------------------------------- compile-time args constexpr uint32_t CT_ACC0 = 0; // TensorAccessorArgs (DRAM interleaved; page size given per use) diff --git a/code/tt_depthpro2/tt/mk_enc/kernels/me_dm.hpp b/code/tt_depthpro2/tt/mk_enc/kernels/me_dm.hpp index 6f36eed8c207219218c697a5c74f0be5107bb878..3768abc1795c3c8f1d9294101d76090ac9cbd099 100644 --- a/code/tt_depthpro2/tt/mk_enc/kernels/me_dm.hpp +++ b/code/tt_depthpro2/tt/mk_enc/kernels/me_dm.hpp @@ -11,6 +11,7 @@ namespace mex { constexpr uint32_t T16 = 2048, T32 = 4096; +constexpr uint32_t TIX = ME_INX32 ? T32 : T16; // LN-gather tile bytes (CB_OUTX -> CB_INX; round 10) constexpr uint32_t PAGE_BYTES = PAGE_TILES * T16; FORCE_INLINE uint32_t rt(uint32_t i) { return get_arg_val(i); } diff --git a/code/tt_depthpro2/tt/mk_enc/kernels/me_sched.hpp b/code/tt_depthpro2/tt/mk_enc/kernels/me_sched.hpp index 628df6875aefd0daed3042e5771d4e6afb87d900..e18aad720b86b1a176288692d29723e27def0328 100644 --- a/code/tt_depthpro2/tt/mk_enc/kernels/me_sched.hpp +++ b/code/tt_depthpro2/tt/mk_enc/kernels/me_sched.hpp @@ -41,6 +41,12 @@ constexpr uint32_t PE_T = 24; // patch K tiles constexpr uint32_t PAGE_TILES = 8; constexpr uint32_t NPATCH = T * PT; // patch tiles constexpr uint32_t RI_POOL = MT - 1; +// keys in hi / lo (round 10): S += q k_lo^T for the special key tile of each segment (KLO 1) or for every key (KLO 2); +// a K / V chunk is [K 2 KC | V 2 KC | K lo KLT] tiles +constexpr uint32_t KLO = ME_KLO; +constexpr uint32_t KLT = KLO == 2 ? 2 * KC : (KLO == 1 ? 2 : 0); +constexpr uint32_t CHT = 4 * KC + KLT; +ME_INL uint32_t klo_row(uint32_t ri) { return KLO == 2 ? ri : (ri < T ? ri : T); } constexpr uint32_t SPECIAL_JOINT = POOL ? RI_POOL : 0; // the joint segment's prefix key tile static_assert(RB <= RB_MAX, "slots"); static_assert(2 * RB <= 8, "QKV unit accumulators"); @@ -169,4 +175,20 @@ ME_INL uint32_t key_mask(uint32_t ri) { return 0; } +// a k unit of this wave ships its lo tiles (KLO 1: only when one of the slots holds a special key tile) +ME_INL bool klo_wave(uint32_t l, const uint32_t* kd) { + if (KLO == 2) { + return true; + } + if (KLO == 0) { + return false; + } + for (uint32_t s = 0; s < RB; ++s) { + if (((qkv_mask(l, kd[s]) >> 1) & 1u) && kd[s] != KD_PATCH) { + return true; + } + } + return false; +} + } // namespace mex diff --git a/code/tt_depthpro2/tt/mk_enc/kernels/me_trisc.cpp b/code/tt_depthpro2/tt/mk_enc/kernels/me_trisc.cpp index 4835f66b09df1a98d7024f54d78b232fc7cf669f..40fdef998df1c0ef12ecf0f12217fcddf763cda4 100644 --- a/code/tt_depthpro2/tt/mk_enc/kernels/me_trisc.cpp +++ b/code/tt_depthpro2/tt/mk_enc/kernels/me_trisc.cpp @@ -618,15 +618,32 @@ NOINL void qkv(uint32_t l) { frscale2(2 * s, 4); } } + const bool lo = ty == 1 && klo_wave(l, me.kd); // k: hi (bf16-exact) in place, lo at 4 + i + if (lo) { + for (uint32_t i = 0; i < 2 * RB; ++i) { + fsplit(i, 4 + i); + } + } tile_regs_commit(); cb_reserve_back(CB_OUT, 2 * RB); + if (lo) { + cb_reserve_back(CB_OUTLO, 2 * RB); + } tile_regs_wait(); pack_reconfig_data_format(CB_OUT); for (uint32_t i = 0; i < 2 * RB; ++i) { pack_tile(i, CB_OUT, i); } + if (lo) { + for (uint32_t i = 0; i < 2 * RB; ++i) { + pack_tile(4 + i, CB_OUTLO, i); + } + } tile_regs_release(); cb_push_back(CB_OUT, 2 * RB); + if (lo) { + cb_push_back(CB_OUTLO, 2 * RB); + } continue; } tile_regs_acquire(); @@ -642,7 +659,11 @@ NOINL void qkv(uint32_t l) { tile_regs_release(); cb_push_back(CB_RAW, 8); cb_wait_front(CB_RAW, 8); + const bool lo = ty == 1 && klo_wave(l, me.kd); cb_reserve_back(CB_OUT, 2 * RB); + if (lo) { + cb_reserve_back(CB_OUTLO, 2 * RB); + } for (uint32_t s = 0; s < RB; ++s) { if (!(act & (1u << s))) { continue; @@ -658,14 +679,25 @@ NOINL void qkv(uint32_t l) { } else { frscale2(0, 4); } + if (lo) { + fsplit(0, 2); + fsplit(1, 3); + } tile_regs_commit(); tile_regs_wait(); pack_reconfig_data_format(CB_OUT); pack_tile(0, CB_OUT, 2 * s); pack_tile(1, CB_OUT, 2 * s + 1); + if (lo) { + pack_tile(2, CB_OUTLO, 2 * s); + pack_tile(3, CB_OUTLO, 2 * s + 1); + } tile_regs_release(); } cb_push_back(CB_OUT, 2 * RB); + if (lo) { + cb_push_back(CB_OUTLO, 2 * RB); + } cb_pop_front(CB_RAW, 8); } ws_align(); @@ -897,12 +929,17 @@ NOINL void pool() { // ================================================================ attention item constexpr uint32_t SUB = 6; // score tiles per DST section (DST 0 .. 5; 6 = the shift, 7 = a mask temp) // DST jj = q_i @ K_{j0 + jj}^T (+ mask), jj < n -NOINL void scores(uint32_t i, uint32_t j0, uint32_t n, const uint32_t* mk) { +NOINL void scores(uint32_t i, uint32_t j0, uint32_t n, const uint32_t* mk, bool first_chunk) { mm_init_n(CB_AQ, CB_KV, 1); for (uint32_t jj = 0; jj < n; ++jj) { for (uint32_t d = 0; d < 2; ++d) { mm_n(CB_AQ, CB_KV, 2 * i + d, 2 * (j0 + jj) + d, jj); } + if (KLO == 2 || (KLO == 1 && first_chunk && j0 + jj == 0)) { // + q k_lo^T + for (uint32_t d = 0; d < 2; ++d) { + mm_n(CB_AQ, CB_KV, 2 * i + d, 4 * KC + (KLO == 2 ? 2 * (j0 + jj) : 0) + d, jj); + } + } } for (uint32_t jj = 0; jj < n; ++jj) { if (mk[j0 + jj]) { @@ -977,7 +1014,7 @@ NOINL void att_item(const Item& it, bool two) { for (uint32_t j = 0; j < nk; ++j) { mk[j] = key_mask(seg_key(it, p0 + j)); } - cb_wait_front(CB_KV, 4 * KC); + cb_wait_front(CB_KV, CHT); for (uint32_t i = 0; i < it.nq; ++i) { APROF(0); // S (fp32) -> region (views S32: P / D pass, S32F: max) @@ -986,7 +1023,7 @@ NOINL void att_item(const Item& it, bool two) { for (uint32_t j0 = 0; j0 < nk; j0 += SUB) { const uint32_t n = gmin(SUB, nk - j0); tile_regs_acquire(); - scores(i, j0, n, mk); + scores(i, j0, n, mk, c == 0); tile_regs_commit(); tile_regs_wait(); pack_reconfig_data_format(CB_S32); @@ -1176,7 +1213,7 @@ NOINL void att_item(const Item& it, bool two) { APROFP(5); aprof = false; } - cb_pop_front(CB_KV, 4 * KC); + cb_pop_front(CB_KV, CHT); } // O / l -> bf16 (several chunks) for (uint32_t i = 0; nch > 1 && i < it.nq; ++i) { diff --git a/code/tt_depthpro2/tt/mk_enc/program.py b/code/tt_depthpro2/tt/mk_enc/program.py index 295de1574ac172decc150611cfb74280cd4d0ba7..7a8d5d8978833bf4a66c197a204921c03d818a64 100644 --- a/code/tt_depthpro2/tt/mk_enc/program.py +++ b/code/tt_depthpro2/tt/mk_enc/program.py @@ -52,7 +52,7 @@ def _opt_level(name: str): def env_options() -> Dict: """``DEPTHPRO2_MK_ENC_OPTS`` (A/B knobs, comma-separated ``key=value``): ``exp`` (0 fp32 exp, 1 exp_21f), - ``giant_all`` (0/1), ``fc1p`` (0/1), ``fid`` (HiFi4 / HiFi3 / ...).""" + ``giant_all`` (0/1), ``fc1p`` (0/1), ``fid`` (HiFi4 / HiFi3 / ...), ``inx32`` (0/1: LN-gather tiles bf16 / fp32).""" out: Dict = {} for kv in os.environ.get("DEPTHPRO2_MK_ENC_OPTS", "").split(","): if "=" not in kv: @@ -66,6 +66,12 @@ def env_options() -> Dict: out["fc1p_ok"] = bool(int(v)) elif k == "fid": out["fidelity"] = v + elif k == "inx32": + out["inx32"] = bool(int(v)) + elif k == "klo": + out["klo"] = int(v) + elif k == "ring_first": + out["ring_first"] = bool(int(v)) else: raise ValueError(f"DEPTHPRO2_MK_ENC_OPTS: unknown key {k!r}") return out @@ -162,6 +168,7 @@ class MkEnc: mt32 = geo.Mt * 32 self.xd = z(mt32, ttnn.float32) self.q, self.k, self.v, self.o = (z(mt32, ttnn.bfloat16) for _ in range(4)) + self.klo = z(max(1, geo.klo_rows) * 32, ttnn.bfloat16) # k - bf16(k) of the special / every key tile tap_rows = T * (geo.Np + 32) if mode == "fov" else T * geo.Np self.taps = [z4(tap_rows, ttnn.bfloat16) for _ in range(4)] # [1, 1, rows, C] (the ttnn engines' shape) self.prb = tile(torch.zeros(G.N_PROBE * 32, 32), ttnn.float32) @@ -182,7 +189,7 @@ class MkEnc: def persistent(self) -> List: return [self.arena_e, *self.arenas, self.consts, self.cf32, self.rope, self.pfx, self.xd, self.q, self.k, - self.v, self.o, self.prb, self.prof, self.vf] + self.v, self.o, self.prb, self.prof, self.vf, self.klo] def set_valid_frames(self, n: int) -> None: """The next runs / trace replays process frames ``[0, n)`` as an n-frame clip (BASELINE.md 9.2: frames >= n @@ -226,6 +233,7 @@ class MkEnc: c[G.K_PROBE] = self.prb.buffer_address() c[G.K_PROF] = self.prof.buffer_address() c[G.K_VF] = self.vf.buffer_address() + c[G.K_KLO] = self.klo.buffer_address() return c def program(self, patches, nl: Optional[int] = None, dump: bool = False): diff --git a/image/blobs/sha256/07068e507eb85eb19e2cba161776f09d9dfc409f076a75cb025e91c7a453cc0b b/image/blobs/sha256/07068e507eb85eb19e2cba161776f09d9dfc409f076a75cb025e91c7a453cc0b new file mode 100644 index 0000000000000000000000000000000000000000..cf5ad5aa4c353be321e45a86f16953eb2fa21044 Binary files /dev/null and b/image/blobs/sha256/07068e507eb85eb19e2cba161776f09d9dfc409f076a75cb025e91c7a453cc0b differ diff --git a/image/blobs/sha256/0823fb4d68aa8cf2ae2c0570a0ec29008cc3731b4cf6824f19dec26f1752a595 b/image/blobs/sha256/0823fb4d68aa8cf2ae2c0570a0ec29008cc3731b4cf6824f19dec26f1752a595 new file mode 100644 index 0000000000000000000000000000000000000000..3177b6282c37c89e26402c9a483b348dfc6dcc38 Binary files /dev/null and b/image/blobs/sha256/0823fb4d68aa8cf2ae2c0570a0ec29008cc3731b4cf6824f19dec26f1752a595 differ diff --git a/image/blobs/sha256/199c5c69ff79909fafc6f7ce76f18d9190a126fb2e19b7008b1ea7e420e03143 b/image/blobs/sha256/199c5c69ff79909fafc6f7ce76f18d9190a126fb2e19b7008b1ea7e420e03143 new file mode 100644 index 0000000000000000000000000000000000000000..31ea8e8428da9360517eb5021c1b3b3807c8f163 Binary files /dev/null and b/image/blobs/sha256/199c5c69ff79909fafc6f7ce76f18d9190a126fb2e19b7008b1ea7e420e03143 differ diff --git a/image/blobs/sha256/2adcae1db077911ca2862dd02f273f1e9b4281fdf40b2883120a4f2cc0a62d1c b/image/blobs/sha256/2adcae1db077911ca2862dd02f273f1e9b4281fdf40b2883120a4f2cc0a62d1c new file mode 100644 index 0000000000000000000000000000000000000000..1d94152a6372cf05cf9402cb4d9af652583c46a3 --- /dev/null +++ b/image/blobs/sha256/2adcae1db077911ca2862dd02f273f1e9b4281fdf40b2883120a4f2cc0a62d1c @@ -0,0 +1 @@ +{"architecture":"amd64","config":{"User":"tt","Env":["PATH=/opt/tt-venv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin","VENV=/opt/tt-venv","VIRTUAL_ENV=/opt/tt-venv","TT_METAL_RUNTIME_ROOT=/opt/tt-metal","TT_METAL_HOME=/opt/tt-metal","PYTHONPATH=/opt/tt-metal","LD_LIBRARY_PATH=/opt/tt-metal/build/lib:/opt/openmpi-v5.0.7-ulfm/lib","EXTRA_MODELS_DIR=","TT_VLLM_BUILTIN_MODELS=","TT_MODEL_KIND=tt-dit-server","HF_HOME=/hf","TT_METAL_CACHE=/cache","HOME=/home/tt","USER=tt","LOGNAME=tt"],"Entrypoint":["/usr/local/bin/entrypoint.sh"],"Cmd":["/usr/local/bin/serve-default.sh"],"WorkingDir":"/home/tt/work","Labels":{"org.opencontainers.image.revision":"44d66500520fda9f2c7060c0f6b41ec48f7ab37e","org.opencontainers.image.version":"22.04","org.tenstorrent.tt-model":"depthpro2","org.tenstorrent.tt-model.arch":"blackhole","org.tenstorrent.tt-model.kind":"tt-dit-server","org.tenstorrent.tt-model.plugin":"","org.tenstorrent.tt-model.profiles":"s,b,l,h","org.tenstorrent.tt-model.repo":"changh95/DepthPro2","org.tenstorrent.tt-model.tt-metal":"v0.80.0-dev20261006-78-g44d6650052-dirty","org.tenstorrent.tt-model.weights":"apple/DepthPro2-focal"},"ArgsEscaped":true},"created":"2026-11-29T19:02:42.548514122Z","history":[{"created":"2026-11-17T09:18:24.816545885Z","created_by":"/bin/sh -c #(nop) ARG RELEASE","empty_layer":true},{"created":"2026-11-17T09:18:24.854129732Z","created_by":"/bin/sh -c #(nop) ARG LAUNCHPAD_BUILD_ARCH","empty_layer":true},{"created":"2026-11-17T09:18:24.882016179Z","created_by":"/bin/sh -c #(nop) LABEL org.opencontainers.image.version=22.04","empty_layer":true},{"created":"2026-11-17T09:18:27.119966628Z","created_by":"/bin/sh -c #(nop) ADD file:577abcbf057cdd5d520b6dbfa56d772c9fb1fa3dd63cb6db8942d63dfc9d902b in / "},{"created":"2026-11-17T09:18:27.522347875Z","created_by":"/bin/sh -c #(nop) CMD [\"/bin/bash\"]","empty_layer":true},{"created":"2026-11-28T16:42:42.875638712Z","created_by":"ARG OMPI_DIR=/opt/openmpi-v5.0.7-ulfm","comment":"buildkit.dockerfile.v0","empty_layer":true},{"created":"2026-11-28T16:42:42.875638712Z","created_by":"ARG EXTRA_MODELS_DIR=","comment":"buildkit.dockerfile.v0","empty_layer":true},{"created":"2026-11-28T16:42:42.875638712Z","created_by":"ARG TT_MODEL_KIND","comment":"buildkit.dockerfile.v0","empty_layer":true},{"created":"2026-11-28T16:42:42.875638712Z","created_by":"ARG MODEL_NAME","comment":"buildkit.dockerfile.v0","empty_layer":true},{"created":"2026-11-28T16:42:42.875638712Z","created_by":"ARG MODEL_REPO","comment":"buildkit.dockerfile.v0","empty_layer":true},{"created":"2026-11-28T16:42:42.875638712Z","created_by":"ARG MODEL_WEIGHTS","comment":"buildkit.dockerfile.v0","empty_layer":true},{"created":"2026-11-28T16:42:42.875638712Z","created_by":"ARG MODEL_ARCH","comment":"buildkit.dockerfile.v0","empty_layer":true},{"created":"2026-11-28T16:42:42.875638712Z","created_by":"ARG MODEL_PROFILES","comment":"buildkit.dockerfile.v0","empty_layer":true},{"created":"2026-11-28T16:42:42.875638712Z","created_by":"ARG MODEL_TT_METAL_SHA","comment":"buildkit.dockerfile.v0","empty_layer":true},{"created":"2026-11-28T16:42:42.875638712Z","created_by":"ARG MODEL_TT_METAL_DESCRIBE","comment":"buildkit.dockerfile.v0","empty_layer":true},{"created":"2026-11-28T16:42:42.875638712Z","created_by":"ARG MODEL_PLUGIN_SHA","comment":"buildkit.dockerfile.v0","empty_layer":true},{"created":"2026-11-28T16:42:42.875638712Z","created_by":"RUN |11 OMPI_DIR=/opt/openmpi-v5.0.7-ulfm EXTRA_MODELS_DIR= TT_MODEL_KIND=tt-dit-server MODEL_NAME=depthpro2 MODEL_REPO=changh95/DepthPro2 MODEL_WEIGHTS=apple/DepthPro2-focal MODEL_ARCH=blackhole MODEL_PROFILES=s,b,l,h MODEL_TT_METAL_SHA=44d66500520fda9f2c7060c0f6b41ec48f7ab37e MODEL_TT_METAL_DESCRIBE=v0.80.0-dev20261006-78-g44d6650052-dirty MODEL_PLUGIN_SHA= /bin/sh -c apt-get update \u0026\u0026 apt-get install -y --no-install-recommends libhwloc15 libnuma1 libatomic1 libudev1 libcap2 zlib1g libmpc3 libmpfr6 libgmp10 libzstd1 libevent-core-2.1-7 libevent-pthreads-2.1-7 libgl1 libsndfile1 ca-certificates \u0026\u0026 apt-get clean \u0026\u0026 rm -rf /var/lib/apt/lists/* # buildkit","comment":"buildkit.dockerfile.v0"},{"created":"2026-11-28T16:42:45.530315653Z","created_by":"RUN |11 OMPI_DIR=/opt/openmpi-v5.0.7-ulfm EXTRA_MODELS_DIR= TT_MODEL_KIND=tt-dit-server MODEL_NAME=depthpro2 MODEL_REPO=changh95/DepthPro2 MODEL_WEIGHTS=apple/DepthPro2-focal MODEL_ARCH=blackhole MODEL_PROFILES=s,b,l,h MODEL_TT_METAL_SHA=44d66500520fda9f2c7060c0f6b41ec48f7ab37e MODEL_TT_METAL_DESCRIBE=v0.80.0-dev20261006-78-g44d6650052-dirty MODEL_PLUGIN_SHA= /bin/sh -c existing=\"$(getent passwd 1000 | cut -d: -f1)\" \u0026\u0026 if [ -n \"$existing\" ]; then userdel -r \"$existing\" 2\u003e/dev/null || userdel \"$existing\"; fi \u0026\u0026 useradd --uid 1000 --create-home --home-dir /home/tt --shell /bin/bash tt \u0026\u0026 mkdir -p /home/tt/work/logs /cache /opt/tt-metal \u0026\u0026 chown -R tt:tt /home/tt /cache /opt/tt-metal \u0026\u0026 chmod 1777 /home/tt /home/tt/work /home/tt/work/logs /cache # buildkit","comment":"buildkit.dockerfile.v0"},{"created":"2026-11-28T17:33:04.345303757Z","created_by":"COPY /opt/openmpi-v5.0.7-ulfm /opt/openmpi-v5.0.7-ulfm # buildkit","comment":"buildkit.dockerfile.v0"},{"created":"2026-11-28T17:33:06.736780269Z","created_by":"COPY /opt/tenstorrent /opt/tenstorrent # buildkit","comment":"buildkit.dockerfile.v0"},{"created":"2026-11-29T04:03:58.415192544Z","created_by":"COPY /usr/local/share/uv /usr/local/share/uv # buildkit","comment":"buildkit.dockerfile.v0"},{"created":"2026-11-29T19:01:53.455771105Z","created_by":"COPY /opt/tt-venv /opt/tt-venv # buildkit","comment":"buildkit.dockerfile.v0"},{"created":"2026-11-29T19:01:53.71204838Z","created_by":"COPY /opt/vllm /opt/vllm # buildkit","comment":"buildkit.dockerfile.v0"},{"created":"2026-11-29T19:01:56.039159201Z","created_by":"COPY --chown=tt:tt /opt/tt-metal/runtime /opt/tt-metal/runtime # buildkit","comment":"buildkit.dockerfile.v0"},{"created":"2026-11-29T19:01:56.725986878Z","created_by":"COPY --chown=tt:tt /opt/tt-metal/build_Release /opt/tt-metal/build_Release # buildkit","comment":"buildkit.dockerfile.v0"},{"created":"2026-11-29T19:01:57.40356211Z","created_by":"COPY --chown=tt:tt /opt/tt-metal/build /opt/tt-metal/build # buildkit","comment":"buildkit.dockerfile.v0"},{"created":"2026-11-29T19:01:59.648840947Z","created_by":"COPY --chown=tt:tt /opt/tt-metal/tt_metal /opt/tt-metal/tt_metal # buildkit","comment":"buildkit.dockerfile.v0"},{"created":"2026-11-29T19:02:01.344990943Z","created_by":"COPY --chown=tt:tt /opt/tt-metal/ttnn /opt/tt-metal/ttnn # buildkit","comment":"buildkit.dockerfile.v0"},{"created":"2026-11-29T19:02:01.584031994Z","created_by":"COPY --chown=tt:tt /opt/tt-metal/tools /opt/tt-metal/tools # buildkit","comment":"buildkit.dockerfile.v0"},{"created":"2026-11-29T19:02:01.629928049Z","created_by":"COPY --chown=tt:tt /opt/tt-metal/setup.py /opt/tt-metal/pyproject.toml /opt/tt-metal/ # buildkit","comment":"buildkit.dockerfile.v0"},{"created":"2026-11-29T19:02:01.693333867Z","created_by":"COPY --chown=tt:tt code/ /opt/tt-metal/ # buildkit","comment":"buildkit.dockerfile.v0"},{"created":"2026-11-29T19:02:02.221053604Z","created_by":"RUN |11 OMPI_DIR=/opt/openmpi-v5.0.7-ulfm EXTRA_MODELS_DIR= TT_MODEL_KIND=tt-dit-server MODEL_NAME=depthpro2 MODEL_REPO=changh95/DepthPro2 MODEL_WEIGHTS=apple/DepthPro2-focal MODEL_ARCH=blackhole MODEL_PROFILES=s,b,l,h MODEL_TT_METAL_SHA=44d66500520fda9f2c7060c0f6b41ec48f7ab37e MODEL_TT_METAL_DESCRIBE=v0.80.0-dev20261006-78-g44d6650052-dirty MODEL_PLUGIN_SHA= /bin/sh -c find /opt/tt-metal \\( -type f -o -type d \\) \\( ! -perm -o+r -o \\( -type d ! -perm -o+x \\) \\) -exec chmod a+rX {} + # buildkit","comment":"buildkit.dockerfile.v0"},{"created":"2026-11-29T19:02:02.247803542Z","created_by":"COPY --chmod=0755 entrypoint.sh /usr/local/bin/entrypoint.sh # buildkit","comment":"buildkit.dockerfile.v0"},{"created":"2026-11-29T19:02:02.272786984Z","created_by":"COPY --chmod=0755 serve-default.sh /usr/local/bin/serve-default.sh # buildkit","comment":"buildkit.dockerfile.v0"},{"created":"2026-11-29T19:02:02.272786984Z","created_by":"ENV VENV=/opt/tt-venv","comment":"buildkit.dockerfile.v0","empty_layer":true},{"created":"2026-11-29T19:02:02.272786984Z","created_by":"ENV VIRTUAL_ENV=/opt/tt-venv","comment":"buildkit.dockerfile.v0","empty_layer":true},{"created":"2026-11-29T19:02:02.272786984Z","created_by":"ENV PATH=/opt/tt-venv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin","comment":"buildkit.dockerfile.v0","empty_layer":true},{"created":"2026-11-29T19:02:02.272786984Z","created_by":"ENV TT_METAL_RUNTIME_ROOT=/opt/tt-metal","comment":"buildkit.dockerfile.v0","empty_layer":true},{"created":"2026-11-29T19:02:02.272786984Z","created_by":"ENV TT_METAL_HOME=/opt/tt-metal","comment":"buildkit.dockerfile.v0","empty_layer":true},{"created":"2026-11-29T19:02:02.272786984Z","created_by":"ENV PYTHONPATH=/opt/tt-metal","comment":"buildkit.dockerfile.v0","empty_layer":true},{"created":"2026-11-29T19:02:02.272786984Z","created_by":"ENV LD_LIBRARY_PATH=/opt/tt-metal/build/lib:/opt/openmpi-v5.0.7-ulfm/lib","comment":"buildkit.dockerfile.v0","empty_layer":true},{"created":"2026-11-29T19:02:02.272786984Z","created_by":"ENV EXTRA_MODELS_DIR=","comment":"buildkit.dockerfile.v0","empty_layer":true},{"created":"2026-11-29T19:02:02.272786984Z","created_by":"ARG TT_VLLM_BUILTIN_MODELS=","comment":"buildkit.dockerfile.v0","empty_layer":true},{"created":"2026-11-29T19:02:02.272786984Z","created_by":"ENV TT_VLLM_BUILTIN_MODELS=","comment":"buildkit.dockerfile.v0","empty_layer":true},{"created":"2026-11-29T19:02:02.272786984Z","created_by":"ENV TT_MODEL_KIND=tt-dit-server","comment":"buildkit.dockerfile.v0","empty_layer":true},{"created":"2026-11-29T19:02:02.272786984Z","created_by":"ENV HF_HOME=/hf","comment":"buildkit.dockerfile.v0","empty_layer":true},{"created":"2026-11-29T19:02:02.272786984Z","created_by":"ENV TT_METAL_CACHE=/cache","comment":"buildkit.dockerfile.v0","empty_layer":true},{"created":"2026-11-29T19:02:02.272786984Z","created_by":"ENV HOME=/home/tt","comment":"buildkit.dockerfile.v0","empty_layer":true},{"created":"2026-11-29T19:02:02.272786984Z","created_by":"ENV USER=tt","comment":"buildkit.dockerfile.v0","empty_layer":true},{"created":"2026-11-29T19:02:02.272786984Z","created_by":"ENV LOGNAME=tt","comment":"buildkit.dockerfile.v0","empty_layer":true},{"created":"2026-11-29T19:02:02.272786984Z","created_by":"USER tt","comment":"buildkit.dockerfile.v0","empty_layer":true},{"created":"2026-11-29T19:02:02.304065759Z","created_by":"WORKDIR /home/tt/work","comment":"buildkit.dockerfile.v0"},{"created":"2026-11-29T19:02:02.327135596Z","created_by":"COPY --chmod=0755 verify.sh /ctx/verify.sh # buildkit","comment":"buildkit.dockerfile.v0"},{"created":"2026-11-29T19:02:42.329758021Z","created_by":"RUN |12 OMPI_DIR=/opt/openmpi-v5.0.7-ulfm EXTRA_MODELS_DIR= TT_MODEL_KIND=tt-dit-server MODEL_NAME=depthpro2 MODEL_REPO=changh95/DepthPro2 MODEL_WEIGHTS=apple/DepthPro2-focal MODEL_ARCH=blackhole MODEL_PROFILES=s,b,l,h MODEL_TT_METAL_SHA=44d66500520fda9f2c7060c0f6b41ec48f7ab37e MODEL_TT_METAL_DESCRIBE=v0.80.0-dev20261006-78-g44d6650052-dirty MODEL_PLUGIN_SHA= TT_VLLM_BUILTIN_MODELS= /bin/sh -c bash /ctx/verify.sh # buildkit","comment":"buildkit.dockerfile.v0"},{"created":"2026-11-29T19:02:42.329758021Z","created_by":"USER root","comment":"buildkit.dockerfile.v0","empty_layer":true},{"created":"2026-11-29T19:02:42.548514122Z","created_by":"RUN |12 OMPI_DIR=/opt/openmpi-v5.0.7-ulfm EXTRA_MODELS_DIR= TT_MODEL_KIND=tt-dit-server MODEL_NAME=depthpro2 MODEL_REPO=changh95/DepthPro2 MODEL_WEIGHTS=apple/DepthPro2-focal MODEL_ARCH=blackhole MODEL_PROFILES=s,b,l,h MODEL_TT_METAL_SHA=44d66500520fda9f2c7060c0f6b41ec48f7ab37e MODEL_TT_METAL_DESCRIBE=v0.80.0-dev20261006-78-g44d6650052-dirty MODEL_PLUGIN_SHA= TT_VLLM_BUILTIN_MODELS= /bin/sh -c chmod -R a+rwX /home/tt # buildkit","comment":"buildkit.dockerfile.v0"},{"created":"2026-11-29T19:02:42.548514122Z","created_by":"USER tt","comment":"buildkit.dockerfile.v0","empty_layer":true},{"created":"2026-11-29T19:02:42.548514122Z","created_by":"LABEL org.tenstorrent.tt-model=depthpro2 org.tenstorrent.tt-model.repo=changh95/DepthPro2 org.tenstorrent.tt-model.weights=apple/DepthPro2-focal org.tenstorrent.tt-model.arch=blackhole org.tenstorrent.tt-model.kind=tt-dit-server org.tenstorrent.tt-model.profiles=s,b,l,h org.opencontainers.image.revision=44d66500520fda9f2c7060c0f6b41ec48f7ab37e org.tenstorrent.tt-model.tt-metal=v0.80.0-dev20261006-78-g44d6650052-dirty org.tenstorrent.tt-model.plugin=","comment":"buildkit.dockerfile.v0","empty_layer":true},{"created":"2026-11-29T19:02:42.548514122Z","created_by":"ENTRYPOINT [\"/usr/local/bin/entrypoint.sh\"]","comment":"buildkit.dockerfile.v0","empty_layer":true},{"created":"2026-11-29T19:02:42.548514122Z","created_by":"CMD [\"/usr/local/bin/serve-default.sh\"]","comment":"buildkit.dockerfile.v0","empty_layer":true}],"os":"linux","rootfs":{"type":"layers","diff_ids":["sha256:af272fa34b9eaf77b9456d49daa4d157829b4e27b91a79d1fe5602a1556635ad","sha256:8be42d4b03bc877f158ffd738dbac17e4fa8285b19cf74169c879f5c512a8b71","sha256:22a3ab3fa9eb410f82963b0a29e0ccaab2fd7d1dff10ed16225b57170800648a","sha256:fb97a966331b85e18e7da95840b6cbad01fe8da3b4ee57008db90c4ceefadc60","sha256:f6f59c740d38f0240384e0389b9eb70a0ff1c291067da2551629d026caf317bb","sha256:b5243dd282602a10edfac49ffa271ffe1958c0de5a1ad0939ea7916d2641bb2b","sha256:162ece2834b43febd36d292dc32b0449a2ce13fa12918b639d6101cbb3d5dd5d","sha256:60104333ffb89cfe54ab3f68ed0b24a8fad95f56356aee44ecffe799a0b9974d","sha256:711d7a0b03bf2302318e7774ebbd479a8ce12fb85121c086e699cce564538902","sha256:594f4dedaa2952d3e4cc50eecd6d7db5085dfcc3472c2ea572b5487b2834ee18","sha256:13fb8f8c7803db14f98e2e7ee04376dc2f8b327d612f618de01b7116db046b65","sha256:b73de1fdf404c49c2bd79bc32cb218980390ba0f4a6e7aaccb290b006a1e7578","sha256:b10e2d8a5a1b6099d9345dd76bb88c11a79a763f6fbe2b793ff0ac566400bcb5","sha256:0ede05456006e783ec2519b6eac944cbca58fcb164a727bd52eda94cbc1533f2","sha256:ed7e0b7d0d7cea06cb961286d42a012f886d27c3b423eaac9f29036f62b75d27","sha256:004f7c2ce9585cb3d777e9618be53e38c1d961583308484a913adb103850d94e","sha256:5f70bf18a086007016e948b04aed3b82103a36bea41755b6cddfaf10ace3c6ef","sha256:58b42274cba82a8d305d1c47ae00a20a3805d6d47db703bee4b11a4ba9eb0c0b","sha256:05c07e18b426c06a4a50e3864f540082ad0c906c9e98dbd7b91dcd59bc584f38","sha256:5f70bf18a086007016e948b04aed3b82103a36bea41755b6cddfaf10ace3c6ef","sha256:b5e79d482c89456720297af37279ff2f2c3e953ae3e3b1a98e4df220360a7de3","sha256:786b6b6e48793490357d31e133b27b3e9330bf9067ec396159b5c823b3336cbe","sha256:1a193f852dbed13c9ea6a7138c84bfb6409e12936968e96730225540dafc93b5"]}} \ No newline at end of file diff --git a/image/blobs/sha256/2c086c85a6757d115d88f96d8a61d108d1672dbd93e11378f3e926c30a087721 b/image/blobs/sha256/2c086c85a6757d115d88f96d8a61d108d1672dbd93e11378f3e926c30a087721 new file mode 100644 index 0000000000000000000000000000000000000000..c1ce33d06d8f007310cb4187c9581ba2865a9937 Binary files /dev/null and b/image/blobs/sha256/2c086c85a6757d115d88f96d8a61d108d1672dbd93e11378f3e926c30a087721 differ diff --git a/image/blobs/sha256/33f737b5c90656461fe9bd146cb79535e86801e8ae6ff472fba02d98d642d96d b/image/blobs/sha256/33f737b5c90656461fe9bd146cb79535e86801e8ae6ff472fba02d98d642d96d new file mode 100644 index 0000000000000000000000000000000000000000..d6e73c97ec5fa638f1316e814cd6f1eff2538226 --- /dev/null +++ b/image/blobs/sha256/33f737b5c90656461fe9bd146cb79535e86801e8ae6ff472fba02d98d642d96d @@ -0,0 +1,28 @@ +{ + "schemaVersion": 2, + "mediaType": "application/vnd.oci.image.index.v1+json", + "manifests": [ + { + "mediaType": "application/vnd.oci.image.manifest.v1+json", + "digest": "sha256:9b59c9e70282751d0475ad191c51fa4a6ecc35df69dc3eddbbf3b48e9d0bd0ce", + "size": 4686, + "platform": { + "architecture": "amd64", + "os": "linux" + } + }, + { + "mediaType": "application/vnd.oci.image.manifest.v1+json", + "digest": "sha256:ed45dbdb1c67816fd75b0c894c7016a3708ab62bd262a1f4fd5f291223762b52", + "size": 837, + "annotations": { + "vnd.docker.reference.digest": "sha256:9b59c9e70282751d0475ad191c51fa4a6ecc35df69dc3eddbbf3b48e9d0bd0ce", + "vnd.docker.reference.type": "attestation-manifest" + }, + "platform": { + "architecture": "unknown", + "os": "unknown" + } + } + ] +} \ No newline at end of file diff --git a/image/blobs/sha256/4a09a953b77760f9bc21e019efd2b7c955acbb3da411924422eb1dc152d42cb5 b/image/blobs/sha256/4a09a953b77760f9bc21e019efd2b7c955acbb3da411924422eb1dc152d42cb5 new file mode 100644 index 0000000000000000000000000000000000000000..562326f57db676af24646f97f8bd9b72d4234fca --- /dev/null +++ b/image/blobs/sha256/4a09a953b77760f9bc21e019efd2b7c955acbb3da411924422eb1dc152d42cb5 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4a09a953b77760f9bc21e019efd2b7c955acbb3da411924422eb1dc152d42cb5 +size 63873701 diff --git a/image/blobs/sha256/4b312cf00d10f4cae911fa2d2f3ca94519ecc3af9e6f90613d423b7007a4b58a b/image/blobs/sha256/4b312cf00d10f4cae911fa2d2f3ca94519ecc3af9e6f90613d423b7007a4b58a new file mode 100644 index 0000000000000000000000000000000000000000..4554e1570bd5e95fb5d318f0893c2897c7db70b4 Binary files /dev/null and b/image/blobs/sha256/4b312cf00d10f4cae911fa2d2f3ca94519ecc3af9e6f90613d423b7007a4b58a differ diff --git a/image/blobs/sha256/5e8d5690a24c1c2dd08c724768ff8dfb3cde06d235dc412ea25b99c03cecb0e9 b/image/blobs/sha256/5e8d5690a24c1c2dd08c724768ff8dfb3cde06d235dc412ea25b99c03cecb0e9 new file mode 100644 index 0000000000000000000000000000000000000000..54d9e4d51117929401c0cec8224dee41fe71182b --- /dev/null +++ b/image/blobs/sha256/5e8d5690a24c1c2dd08c724768ff8dfb3cde06d235dc412ea25b99c03cecb0e9 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5e8d5690a24c1c2dd08c724768ff8dfb3cde06d235dc412ea25b99c03cecb0e9 +size 41059882 diff --git a/image/blobs/sha256/62b690ec2bb305674142733157a0c3f23492989a04d9029dc5edfdcad69fb6bf b/image/blobs/sha256/62b690ec2bb305674142733157a0c3f23492989a04d9029dc5edfdcad69fb6bf new file mode 100644 index 0000000000000000000000000000000000000000..9114f3de94456369f7d820570863679e2ee4bcbf --- /dev/null +++ b/image/blobs/sha256/62b690ec2bb305674142733157a0c3f23492989a04d9029dc5edfdcad69fb6bf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:62b690ec2bb305674142733157a0c3f23492989a04d9029dc5edfdcad69fb6bf +size 808527 diff --git a/image/blobs/sha256/682269e8787edd600b6b6f2153622e388f1aee04425e5d9840ee1c2669b62d53 b/image/blobs/sha256/682269e8787edd600b6b6f2153622e388f1aee04425e5d9840ee1c2669b62d53 new file mode 100644 index 0000000000000000000000000000000000000000..576d82cc690f0e7c48c14b85a4125deaf9b07afb Binary files /dev/null and b/image/blobs/sha256/682269e8787edd600b6b6f2153622e388f1aee04425e5d9840ee1c2669b62d53 differ diff --git a/image/blobs/sha256/6abcb58795a986f2819b59f5e6137beb717bbfb72085ac0cf67d65ffec4394f8 b/image/blobs/sha256/6abcb58795a986f2819b59f5e6137beb717bbfb72085ac0cf67d65ffec4394f8 new file mode 100644 index 0000000000000000000000000000000000000000..3dcc8ad959b05dacbcac09f2baf0bcf0d1e3934e --- /dev/null +++ b/image/blobs/sha256/6abcb58795a986f2819b59f5e6137beb717bbfb72085ac0cf67d65ffec4394f8 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6abcb58795a986f2819b59f5e6137beb717bbfb72085ac0cf67d65ffec4394f8 +size 139083839 diff --git a/image/blobs/sha256/7091da5027cb5b595a8e3a28218802237b707ac6788462fa784b679a64498a2c b/image/blobs/sha256/7091da5027cb5b595a8e3a28218802237b707ac6788462fa784b679a64498a2c new file mode 100644 index 0000000000000000000000000000000000000000..5cb2192f56e70b09c3248b9f7e224aa88d741434 --- /dev/null +++ b/image/blobs/sha256/7091da5027cb5b595a8e3a28218802237b707ac6788462fa784b679a64498a2c @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7091da5027cb5b595a8e3a28218802237b707ac6788462fa784b679a64498a2c +size 1950863 diff --git a/image/blobs/sha256/730e5c49f8c863df41fa025f30d1f6b326c7612e58826ce4b3040e91ee6ab6e8 b/image/blobs/sha256/730e5c49f8c863df41fa025f30d1f6b326c7612e58826ce4b3040e91ee6ab6e8 new file mode 100644 index 0000000000000000000000000000000000000000..76b217041dca82d6af8404ac9b7b8570417efe4d --- /dev/null +++ b/image/blobs/sha256/730e5c49f8c863df41fa025f30d1f6b326c7612e58826ce4b3040e91ee6ab6e8 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:730e5c49f8c863df41fa025f30d1f6b326c7612e58826ce4b3040e91ee6ab6e8 +size 281700134 diff --git a/image/blobs/sha256/9b59c9e70282751d0475ad191c51fa4a6ecc35df69dc3eddbbf3b48e9d0bd0ce b/image/blobs/sha256/9b59c9e70282751d0475ad191c51fa4a6ecc35df69dc3eddbbf3b48e9d0bd0ce new file mode 100644 index 0000000000000000000000000000000000000000..cfe043ca914ba8ec82282f98f045a0706738b90a --- /dev/null +++ b/image/blobs/sha256/9b59c9e70282751d0475ad191c51fa4a6ecc35df69dc3eddbbf3b48e9d0bd0ce @@ -0,0 +1,126 @@ +{ + "schemaVersion": 2, + "mediaType": "application/vnd.oci.image.manifest.v1+json", + "config": { + "mediaType": "application/vnd.oci.image.config.v1+json", + "digest": "sha256:2adcae1db077911ca2862dd02f273f1e9b4281fdf40b2883120a4f2cc0a62d1c", + "size": 14815 + }, + "layers": [ + { + "mediaType": "application/vnd.oci.image.layer.v1.tar+gzip", + "digest": "sha256:ba082564e6605eeb2e1abc91a762985d2e8afea393433de08e798c1eee36d028", + "size": 30069815 + }, + { + "mediaType": "application/vnd.oci.image.layer.v1.tar+gzip", + "digest": "sha256:671912666b1102907184fdf4478ef31010aaa5d3e790c872ed63a6f305af1674", + "size": 69477905 + }, + { + "mediaType": "application/vnd.oci.image.layer.v1.tar+gzip", + "digest": "sha256:fdd5150ca1a0c2c722f552dda7ed3deaaa9289294931aca6825aed95c2ce4760", + "size": 4400 + }, + { + "mediaType": "application/vnd.oci.image.layer.v1.tar+gzip", + "digest": "sha256:d43baab0c30010379faae769137459154234a3db3176feafda3ba268ba069d0f", + "size": 30938306 + }, + { + "mediaType": "application/vnd.oci.image.layer.v1.tar+gzip", + "digest": "sha256:a90d913a3b293654e45a902690e86ee0a9cbee6dac59ccc9b8f5b6dcf70acfa0", + "size": 153119814 + }, + { + "mediaType": "application/vnd.oci.image.layer.v1.tar+gzip", + "digest": "sha256:b5d78d46efec8b21102fcabc61b536b7c710fa075c56cc5573c7f25d000b2958", + "size": 65830751 + }, + { + "mediaType": "application/vnd.oci.image.layer.v1.tar+gzip", + "digest": "sha256:730e5c49f8c863df41fa025f30d1f6b326c7612e58826ce4b3040e91ee6ab6e8", + "size": 281700134 + }, + { + "mediaType": "application/vnd.oci.image.layer.v1.tar+gzip", + "digest": "sha256:682269e8787edd600b6b6f2153622e388f1aee04425e5d9840ee1c2669b62d53", + "size": 116 + }, + { + "mediaType": "application/vnd.oci.image.layer.v1.tar+gzip", + "digest": "sha256:6abcb58795a986f2819b59f5e6137beb717bbfb72085ac0cf67d65ffec4394f8", + "size": 139083839 + }, + { + "mediaType": "application/vnd.oci.image.layer.v1.tar+gzip", + "digest": "sha256:5e8d5690a24c1c2dd08c724768ff8dfb3cde06d235dc412ea25b99c03cecb0e9", + "size": 41059882 + }, + { + "mediaType": "application/vnd.oci.image.layer.v1.tar+gzip", + "digest": "sha256:a25af6f70d283cd4531f41b6e80960e4f4f58169c01983ce52ce353c76a302fb", + "size": 41059784 + }, + { + "mediaType": "application/vnd.oci.image.layer.v1.tar+gzip", + "digest": "sha256:4a09a953b77760f9bc21e019efd2b7c955acbb3da411924422eb1dc152d42cb5", + "size": 63873701 + }, + { + "mediaType": "application/vnd.oci.image.layer.v1.tar+gzip", + "digest": "sha256:dd4a48658276f0dc5d844c924df0ea916711b0afda94aa06db2a9463b6010cdb", + "size": 13068082 + }, + { + "mediaType": "application/vnd.oci.image.layer.v1.tar+gzip", + "digest": "sha256:7091da5027cb5b595a8e3a28218802237b707ac6788462fa784b679a64498a2c", + "size": 1950863 + }, + { + "mediaType": "application/vnd.oci.image.layer.v1.tar+gzip", + "digest": "sha256:07068e507eb85eb19e2cba161776f09d9dfc409f076a75cb025e91c7a453cc0b", + "size": 6887 + }, + { + "mediaType": "application/vnd.oci.image.layer.v1.tar+gzip", + "digest": "sha256:62b690ec2bb305674142733157a0c3f23492989a04d9029dc5edfdcad69fb6bf", + "size": 808527 + }, + { + "mediaType": "application/vnd.oci.image.layer.v1.tar+gzip", + "digest": "sha256:4f4fb700ef54461cfa02571ae0db9a0dc1e0cdb5577484a6d75e68dc38e8acc1", + "size": 32 + }, + { + "mediaType": "application/vnd.oci.image.layer.v1.tar+gzip", + "digest": "sha256:199c5c69ff79909fafc6f7ce76f18d9190a126fb2e19b7008b1ea7e420e03143", + "size": 1078 + }, + { + "mediaType": "application/vnd.oci.image.layer.v1.tar+gzip", + "digest": "sha256:2c086c85a6757d115d88f96d8a61d108d1672dbd93e11378f3e926c30a087721", + "size": 1341 + }, + { + "mediaType": "application/vnd.oci.image.layer.v1.tar+gzip", + "digest": "sha256:4f4fb700ef54461cfa02571ae0db9a0dc1e0cdb5577484a6d75e68dc38e8acc1", + "size": 32 + }, + { + "mediaType": "application/vnd.oci.image.layer.v1.tar+gzip", + "digest": "sha256:4b312cf00d10f4cae911fa2d2f3ca94519ecc3af9e6f90613d423b7007a4b58a", + "size": 2987 + }, + { + "mediaType": "application/vnd.oci.image.layer.v1.tar+gzip", + "digest": "sha256:c1775688fd5d80d39eead952ffb71947d7c9372f0afab378cd209c7790aeddd9", + "size": 267915 + }, + { + "mediaType": "application/vnd.oci.image.layer.v1.tar+gzip", + "digest": "sha256:0823fb4d68aa8cf2ae2c0570a0ec29008cc3731b4cf6824f19dec26f1752a595", + "size": 4025 + } + ] +} \ No newline at end of file diff --git a/image/blobs/sha256/a25af6f70d283cd4531f41b6e80960e4f4f58169c01983ce52ce353c76a302fb b/image/blobs/sha256/a25af6f70d283cd4531f41b6e80960e4f4f58169c01983ce52ce353c76a302fb new file mode 100644 index 0000000000000000000000000000000000000000..cbe35a5e121b0328340211434cae40cd44814c73 --- /dev/null +++ b/image/blobs/sha256/a25af6f70d283cd4531f41b6e80960e4f4f58169c01983ce52ce353c76a302fb @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a25af6f70d283cd4531f41b6e80960e4f4f58169c01983ce52ce353c76a302fb +size 41059784 diff --git a/image/blobs/sha256/c1775688fd5d80d39eead952ffb71947d7c9372f0afab378cd209c7790aeddd9 b/image/blobs/sha256/c1775688fd5d80d39eead952ffb71947d7c9372f0afab378cd209c7790aeddd9 new file mode 100644 index 0000000000000000000000000000000000000000..7067a19a6d7ae0b5c5fa331492b79a991f4085a0 --- /dev/null +++ b/image/blobs/sha256/c1775688fd5d80d39eead952ffb71947d7c9372f0afab378cd209c7790aeddd9 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c1775688fd5d80d39eead952ffb71947d7c9372f0afab378cd209c7790aeddd9 +size 267915 diff --git a/image/blobs/sha256/cd0c901565527f4b2fd02b95be2585a420745d065f007f7ede3e6b3cdc13c560 b/image/blobs/sha256/cd0c901565527f4b2fd02b95be2585a420745d065f007f7ede3e6b3cdc13c560 new file mode 100644 index 0000000000000000000000000000000000000000..f3e33a3d9f348b1ed296da536b42eb96c7ffc6ee --- /dev/null +++ b/image/blobs/sha256/cd0c901565527f4b2fd02b95be2585a420745d065f007f7ede3e6b3cdc13c560 @@ -0,0 +1 @@ +{"_type":"https://in-toto.io/Statement/v1","predicateType":"https://slsa.dev/provenance/v1","subject":[{"name":"pkg:docker/tt-model/depthpro2@build-44d665005?platform=linux%2Famd64","digest":{"sha256":"9b59c9e70282751d0475ad191c51fa4a6ecc35df69dc3eddbbf3b48e9d0bd0ce"}}],"predicate":{"buildDefinition":{"buildType":"https://github.com/moby/buildkit/blob/master/docs/attestations/slsa-definitions.md","resolvedDependencies":[{"uri":"pkg:docker/docker/dockerfile@1.7-labs","digest":{"sha256":"b99fecfe00268a8b556fad7d9c37ee25d716ae08a5d7320e6d51c4dd83246894"}},{"uri":"pkg:docker/ubuntu@22.04?platform=linux%2Famd64","digest":{"sha256":"b000e69a50ff940390233025e7a337fb8469b509e2334fa4d018ac30f3e18cdb"}},{"uri":"pkg:docker/ghcr.io/tenstorrent/tt-metal/tt-metalium/ubuntu-22.04-dev-amd64@latest?platform=linux%2Famd64","digest":{"sha256":"7f43e71c95b7873fb6b2b37876d23ddb34735d6905e1963e32d548ae98570374"}}],"externalParameters":{"configSource":{"path":"Dockerfile"},"request":{"frontend":"gateway.v0","args":{"cmdline":"docker/dockerfile:1.7-labs","context:metalsrc":"local:metalsrc","frontend.caps":"moby.buildkit.frontend.contexts+forward","sharedkey:localdir:metalsrc":"metalsrc:4e7665ce329afc22","source":"docker/dockerfile:1.7-labs"},"locals":[{"name":"context"},{"name":"dockerfile"},{"name":"metalsrc"}],"root":{"configSource":{"path":"Dockerfile"},"request":{"args":{"context:metalsrc":"local:metalsrc","frontend.caps":"moby.buildkit.frontend.contexts+forward","sharedkey:localdir:metalsrc":"metalsrc:4e7665ce329afc22"}}},"compatibilityVersion":30}},"internalParameters":{"builderPlatform":"linux/amd64"}},"runDetails":{"builder":{"id":""},"metadata":{"invocationId":"o2mn7aos5hriqmp885cui1xj5","startedOn":"2026-11-30T01:25:57.718070365Z","finishedOn":"2026-11-30T01:26:02.154385277Z","buildkit_metadata":{},"buildkit_completeness":{"request":false,"resolvedDependencies":false}}}}} \ No newline at end of file diff --git a/image/blobs/sha256/dd4a48658276f0dc5d844c924df0ea916711b0afda94aa06db2a9463b6010cdb b/image/blobs/sha256/dd4a48658276f0dc5d844c924df0ea916711b0afda94aa06db2a9463b6010cdb new file mode 100644 index 0000000000000000000000000000000000000000..4617549838d2f788f401df4ae0ee4353255e1f87 --- /dev/null +++ b/image/blobs/sha256/dd4a48658276f0dc5d844c924df0ea916711b0afda94aa06db2a9463b6010cdb @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:dd4a48658276f0dc5d844c924df0ea916711b0afda94aa06db2a9463b6010cdb +size 13068082 diff --git a/image/blobs/sha256/ed45dbdb1c67816fd75b0c894c7016a3708ab62bd262a1f4fd5f291223762b52 b/image/blobs/sha256/ed45dbdb1c67816fd75b0c894c7016a3708ab62bd262a1f4fd5f291223762b52 new file mode 100644 index 0000000000000000000000000000000000000000..9cd98a68219933a3ebb33e74cb36b3cbe00eaaf1 --- /dev/null +++ b/image/blobs/sha256/ed45dbdb1c67816fd75b0c894c7016a3708ab62bd262a1f4fd5f291223762b52 @@ -0,0 +1,26 @@ +{ + "schemaVersion": 2, + "mediaType": "application/vnd.oci.image.manifest.v1+json", + "artifactType": "application/vnd.docker.attestation.manifest.v1+json", + "config": { + "mediaType": "application/vnd.oci.empty.v1+json", + "digest": "sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a", + "size": 2, + "data": "e30=" + }, + "layers": [ + { + "mediaType": "application/vnd.in-toto+json", + "digest": "sha256:cd0c901565527f4b2fd02b95be2585a420745d065f007f7ede3e6b3cdc13c560", + "size": 1890, + "annotations": { + "in-toto.io/predicate-type": "https://slsa.dev/provenance/v1" + } + } + ], + "subject": { + "mediaType": "application/vnd.oci.image.manifest.v1+json", + "digest": "sha256:9b59c9e70282751d0475ad191c51fa4a6ecc35df69dc3eddbbf3b48e9d0bd0ce", + "size": 4686 + } +} \ No newline at end of file diff --git a/image/index.json b/image/index.json index a28a258af190417324db4b3666d3838399afd3fe..1e41b881b5e92730aa6d784924131ef173d39e0d 100644 --- a/image/index.json +++ b/image/index.json @@ -1 +1 @@ -{"schemaVersion":2,"mediaType":"application/vnd.oci.image.index.v1+json","manifests":[{"mediaType":"application/vnd.oci.image.index.v1+json","digest":"sha256:7d4a5a78b320ccf9ed7016c84749884f55b0006c74138e412a411da88e96c90d","size":856,"annotations":{"io.containerd.image.name":"docker.io/tt-model/depthpro2:7d4a5a78b320","org.opencontainers.image.ref.name":"7d4a5a78b320"}},{"mediaType":"application/vnd.oci.image.manifest.v1+json","digest":"sha256:019c993236fff2503e7919f178371e28a8d151d36ec72982bd75e79b5d61d5af","size":837,"annotations":{"io.containerd.manifest.subject":"sha256:0ee4564ba810e29d04812b4384a625bd8ae704d13e375f9c34c8d9d49039ff65"},"artifactType":"application/vnd.docker.attestation.manifest.v1+json"}]} \ No newline at end of file +{"schemaVersion":2,"mediaType":"application/vnd.oci.image.index.v1+json","manifests":[{"mediaType":"application/vnd.oci.image.index.v1+json","digest":"sha256:33f737b5c90656461fe9bd146cb79535e86801e8ae6ff472fba02d98d642d96d","size":856,"annotations":{"io.containerd.image.name":"docker.io/tt-model/depthpro2:33f737b5c906","org.opencontainers.image.ref.name":"33f737b5c906"}}]} \ No newline at end of file diff --git a/image/manifest.json b/image/manifest.json index 05f4cd7e25d39a10d9162bdec12f3138a52092ff..ed010a2c6b94c9ffbf4c1f3f70106218be1f61a5 100644 --- a/image/manifest.json +++ b/image/manifest.json @@ -1 +1 @@ -[{"Config":"blobs/sha256/34020e6601d2b3b40db6cdfec30536e8a7b15b6b0c9612cd2fa29f21a7eee863","RepoTags":["tt-model/depthpro2:7d4a5a78b320"],"Layers":["blobs/sha256/ba082564e6605eeb2e1abc91a762985d2e8afea393433de08e798c1eee36d028","blobs/sha256/671912666b1102907184fdf4478ef31010aaa5d3e790c872ed63a6f305af1674","blobs/sha256/fdd5150ca1a0c2c722f552dda7ed3deaaa9289294931aca6825aed95c2ce4760","blobs/sha256/d43baab0c30010379faae769137459154234a3db3176feafda3ba268ba069d0f","blobs/sha256/a90d913a3b293654e45a902690e86ee0a9cbee6dac59ccc9b8f5b6dcf70acfa0","blobs/sha256/b5d78d46efec8b21102fcabc61b536b7c710fa075c56cc5573c7f25d000b2958","blobs/sha256/5b016d79bb0d0f231feb56432bca597d22372330cae9fcbd57b66a767a0e0bde","blobs/sha256/6b84c4b1e198fcf5606226d8bcbcb2bee61c8c2d7e45e4a24ebb077d51e7dbb9","blobs/sha256/e5758dccd78c32a99fa2ad6fede7dcdc9a010195d5b2e52fdf578ad053a5efe1","blobs/sha256/8ea3df7e57eca539aaef3886da4416edc8049442de5819442ff93435714efda2","blobs/sha256/1431ca2d06bf0e3d6b058e48861af84ab9e0a76124a34cfc8668fbc33128cf31","blobs/sha256/b2c200cde9649039e625dcd0b97cb038730866e1eea1f36fa1ade18f52890b37","blobs/sha256/bd2a1526ee7e957e7890edc94a56b8d87c4106f128c96d3dfc5dbe5c6ca324d4","blobs/sha256/26978a700289f033dd9238f908fb9bde859d9bf209a916db1a441ef7f08bbbcd","blobs/sha256/8e640e05879de6ee1f5a3a511bd4907cc6fa5811d23ec76da3f9a4f7aec55599","blobs/sha256/fed26da465205879ddefd477dede4d90fccc48b762849d028c45f589ea4bf6f4","blobs/sha256/4f4fb700ef54461cfa02571ae0db9a0dc1e0cdb5577484a6d75e68dc38e8acc1","blobs/sha256/a78d4158910533ecef000d98be19cc62db3ace7841507634f52935afcdb587ad","blobs/sha256/8dbb9dc6159f3f43fbb2af7bbc5ee536597279b22e23412ee49b4fb346a8f6ae","blobs/sha256/4f4fb700ef54461cfa02571ae0db9a0dc1e0cdb5577484a6d75e68dc38e8acc1","blobs/sha256/599e044f5d508c6d7465d5c227174c066871016ed5afbea49f73a5b588c68a63","blobs/sha256/a0f9120f8473031e9c31209f61fc7dd3ab859a2dfb3001d7dfd8b5996df48b72","blobs/sha256/d068284065b9a015a2304692ae9ecfb3eb7886643b8dc12dd2d1123c1688a40f"]}] \ No newline at end of file +[{"Config":"blobs/sha256/2adcae1db077911ca2862dd02f273f1e9b4281fdf40b2883120a4f2cc0a62d1c","RepoTags":["tt-model/depthpro2:33f737b5c906"],"Layers":["blobs/sha256/ba082564e6605eeb2e1abc91a762985d2e8afea393433de08e798c1eee36d028","blobs/sha256/671912666b1102907184fdf4478ef31010aaa5d3e790c872ed63a6f305af1674","blobs/sha256/fdd5150ca1a0c2c722f552dda7ed3deaaa9289294931aca6825aed95c2ce4760","blobs/sha256/d43baab0c30010379faae769137459154234a3db3176feafda3ba268ba069d0f","blobs/sha256/a90d913a3b293654e45a902690e86ee0a9cbee6dac59ccc9b8f5b6dcf70acfa0","blobs/sha256/b5d78d46efec8b21102fcabc61b536b7c710fa075c56cc5573c7f25d000b2958","blobs/sha256/730e5c49f8c863df41fa025f30d1f6b326c7612e58826ce4b3040e91ee6ab6e8","blobs/sha256/682269e8787edd600b6b6f2153622e388f1aee04425e5d9840ee1c2669b62d53","blobs/sha256/6abcb58795a986f2819b59f5e6137beb717bbfb72085ac0cf67d65ffec4394f8","blobs/sha256/5e8d5690a24c1c2dd08c724768ff8dfb3cde06d235dc412ea25b99c03cecb0e9","blobs/sha256/a25af6f70d283cd4531f41b6e80960e4f4f58169c01983ce52ce353c76a302fb","blobs/sha256/4a09a953b77760f9bc21e019efd2b7c955acbb3da411924422eb1dc152d42cb5","blobs/sha256/dd4a48658276f0dc5d844c924df0ea916711b0afda94aa06db2a9463b6010cdb","blobs/sha256/7091da5027cb5b595a8e3a28218802237b707ac6788462fa784b679a64498a2c","blobs/sha256/07068e507eb85eb19e2cba161776f09d9dfc409f076a75cb025e91c7a453cc0b","blobs/sha256/62b690ec2bb305674142733157a0c3f23492989a04d9029dc5edfdcad69fb6bf","blobs/sha256/4f4fb700ef54461cfa02571ae0db9a0dc1e0cdb5577484a6d75e68dc38e8acc1","blobs/sha256/199c5c69ff79909fafc6f7ce76f18d9190a126fb2e19b7008b1ea7e420e03143","blobs/sha256/2c086c85a6757d115d88f96d8a61d108d1672dbd93e11378f3e926c30a087721","blobs/sha256/4f4fb700ef54461cfa02571ae0db9a0dc1e0cdb5577484a6d75e68dc38e8acc1","blobs/sha256/4b312cf00d10f4cae911fa2d2f3ca94519ecc3af9e6f90613d423b7007a4b58a","blobs/sha256/c1775688fd5d80d39eead952ffb71947d7c9372f0afab378cd209c7790aeddd9","blobs/sha256/0823fb4d68aa8cf2ae2c0570a0ec29008cc3731b4cf6824f19dec26f1752a595"]}] \ No newline at end of file diff --git a/media/demo_sample.png b/media/demo_sample.png index c71255aec398a5d6c8279db373a5bb06c83c6391..837f01150fcdc148f1d5b798d58264b97e92aa51 100644 --- a/media/demo_sample.png +++ b/media/demo_sample.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e447ce95468ae35a04cb1aea06bc7a6525db760370264d6875a097d565d7523c -size 843457 +oid sha256:f68a6f146580b0e49aec10a7578759f896b012fa51fce78d9151a7c1e307c472 +size 843628 diff --git a/media/demo_tt.gif b/media/demo_tt.gif index 7c7f4df804088c22cc63ad1f27491b42b022a413..45388e7030bd74e37aef7a6c811a4995d775d1ef 100644 --- a/media/demo_tt.gif +++ b/media/demo_tt.gif @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:96734b327c6311f2d5db5df2a455f2888b86294b27709d0d0c0618be791d4236 -size 7268461 +oid sha256:4b7345140c20d1b31e8a28ebd905067b89f7f60d2afe26b032a6789820d3f9d2 +size 7338259 diff --git a/media/demo_tt.mp4 b/media/demo_tt.mp4 index c9904cb6eef99c1c7c2dfe0b0090c6b429e41a17..f04aa1e223829a30530b64af4e2b5ddc08e8038e 100644 --- a/media/demo_tt.mp4 +++ b/media/demo_tt.mp4 @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a4c8feb9c76938a1ecf8aaaab03816eddc9bc2762ba204cebc8c98498e289173 -size 1164388 +oid sha256:24819e2efbabcefef064e6edc211bb338f138d6809180bdb75620a365b7417c9 +size 1164980 diff --git a/tt-model.yaml b/tt-model.yaml index d96c913807c95ac90052669dc882e0192d55d09b..4c3e845b0d652a5d8ae6f654a7f3322ed8a8f7f0 100644 --- a/tt-model.yaml +++ b/tt-model.yaml @@ -105,6 +105,9 @@ serve: # The shipped engines (gated + soaked): encoder, decoder and focal-estimator trunk as persistent megakernels; # any stage can fall back to its tt-nn ops (e.g. DEPTHPRO2_ENGINE=enc=mk,dec=ttnn,fov=mk). DEPTHPRO2_ENGINE: "enc=mk,dec=mk,fov=mk" + # Encoder megakernel numerics: high (the per-size defaults: fp32 LayerNorm output into QKV / FC1 and hi / lo + # prefix keys on L) or fast (plain bf16 everywhere: changes L only; high costs L 5-18 % more encoder time). + DEPTHPRO2_ENC_PRECISION: "high" serve_profiles: - name: s @@ -132,7 +135,7 @@ verify: - "from tt_depthpro2.server.app import parse_mesh_shape as p; assert p('1x1') == p('(1, 1)') == p('1,1') == (1, 1)" - "from tt_depthpro2.server.app import load_config; c = load_config({'DEPTHPRO2_SIZE': 'L', 'DEPTHPRO2_RESOLUTIONS': 'vga,vga_portrait', 'DEPTHPRO2_WINDOW': '16', 'DEPTHPRO2_OVERLAP': '4', 'DEPTHPRO2_VIDEO_MODES': 'auto', 'DEPTHPRO2_KV_STREAMS': '1', 'DEPTHPRO2_FOV': '1', 'DEPTHPRO2_DISPATCH': 'eth', 'DEPTHPRO2_NUM_CQS': '1', 'DEPTHPRO2_ENGINE': 'enc=mk,dec=mk,fov=mk', 'TT_AUXILIARY_WEIGHTS': 'apple/DepthPro2-S@903a1c1ade918831d138adcc4aedbcc8f4da0078,apple/DepthPro2-B@85e67fdfb7f5b36a6f6c4495e6789d331b1d8a04,apple/DepthPro2-L@849dc5461267e0bc006ec63ab46920ea1ed98702,apple/DepthPro2-H@68426c789f75a7c760273e857222625b4fe69576', 'TT_MODEL_WEIGHTS_REVISION': '622659d44a2002cf9ae4333f2569afa938290d9a'}); m = c.model; assert m.engine == {'enc': 'mk', 'dec': 'mk', 'fov': 'mk'}, m.engine; assert (m.size, m.resolutions, m.window, m.overlap, m.video_modes, m.video_modes_auto, m.kv_streams, m.clip_lengths, m.fov, c.dispatch, c.num_command_queues, c.revision, c.fov_revision) == ('L', ((480, 640), (640, 480)), 16, 4, ('buffered', 'unbuffered'), True, 1, (1, 16), True, 'eth', 1, '849dc5461267e0bc006ec63ab46920ea1ed98702', '622659d44a2002cf9ae4333f2569afa938290d9a'), c" # a bad configuration refuses to start - - "from tt_depthpro2.server.app import load_config as L\nfor bad in ({'DEPTHPRO2_SIZE': 'XL'}, {'DEPTHPRO2_RESOLUTIONS': '480x'}, {'DEPTHPRO2_WINDOW': '17'}, {'DEPTHPRO2_OVERLAP': '16'}, {'DEPTHPRO2_VIDEO_MODES': 'live'}, {'DEPTHPRO2_KV_STREAMS': '0'}, {'DEPTHPRO2_ENGINE': 'dec=gpu'}, {'TT_MESH_SHAPE': '1x2'}):\n try:\n L(bad)\n except RuntimeError:\n continue\n raise AssertionError(bad)" + - "from tt_depthpro2.server.app import load_config as L\nfor bad in ({'DEPTHPRO2_SIZE': 'XL'}, {'DEPTHPRO2_RESOLUTIONS': '480x'}, {'DEPTHPRO2_WINDOW': '17'}, {'DEPTHPRO2_OVERLAP': '16'}, {'DEPTHPRO2_VIDEO_MODES': 'live'}, {'DEPTHPRO2_KV_STREAMS': '0'}, {'DEPTHPRO2_ENGINE': 'dec=gpu'}, {'DEPTHPRO2_ENC_PRECISION': 'medium'}, {'TT_MESH_SHAPE': '1x2'}):\n try:\n L(bad)\n except RuntimeError:\n continue\n raise AssertionError(bad)" # the weights pins (focal + the four sizes) - "from tt_depthpro2.config import WEIGHTS; assert WEIGHTS == {'focal': ('apple/DepthPro2-focal', '622659d44a2002cf9ae4333f2569afa938290d9a'), 'S': ('apple/DepthPro2-S', '903a1c1ade918831d138adcc4aedbcc8f4da0078'), 'B': ('apple/DepthPro2-B', '85e67fdfb7f5b36a6f6c4495e6789d331b1d8a04'), 'L': ('apple/DepthPro2-L', '849dc5461267e0bc006ec63ab46920ea1ed98702'), 'H': ('apple/DepthPro2-H', '68426c789f75a7c760273e857222625b4fe69576')}" # the API, the CPU engine, the streaming and the reference import (torch, no device) @@ -143,6 +146,8 @@ verify: - "import importlib.util; from pathlib import Path; d = Path('/opt/tt-metal/tt_depthpro2/tt'); assert all((d / f'mk_enc/kernels/me_{r}.cpp').is_file() and (d / f'mk_dec/kernels/md_{r}.cpp').is_file() for r in ('brisc', 'ncrisc', 'trisc')) and all(importlib.util.find_spec(f'tt_depthpro2.tt.{m}') for m in ('mk_enc', 'mk_fov', 'mk_dec'))" - "from pathlib import Path; d = Path('/opt/tt-metal/tt_depthpro2/tt'); n = {p.name for p in (d / 'mk_enc' / 'kernels').iterdir()}; m = {p.name for p in (d / 'mk_dec' / 'kernels').iterdir()}; assert {'me_brisc.cpp', 'me_ncrisc.cpp', 'me_trisc.cpp', 'me_defs.hpp', 'me_dm.hpp'} <= n and {'md_brisc.cpp', 'md_ncrisc.cpp', 'md_trisc.cpp', 'md_defs.hpp'} <= m, (n, m)" # the default engines: the three megakernels; each stage can fall back to tt-nn + # the encoder precision switch: high by default; fast maps to the megakernel's v1 options before any program is built + - "from tt_depthpro2 import config as C; assert C.resolve_config(env={}).enc_precision == 'high' and C.resolve_config(env={'DEPTHPRO2_ENC_PRECISION': 'fast'}).enc_precision == 'fast' and C.mk_enc_options('fast', 'exp=1,inx32=1') == 'exp=1,inx32=0,klo=0' and C.mk_enc_options('high', 'inx32=0,klo=0') == ''; from tt_depthpro2.tt.mk_enc.program import env_options; import os; os.environ['DEPTHPRO2_MK_ENC_OPTS'] = C.mk_enc_options('fast'); assert env_options() == {'inx32': False, 'klo': 0}, env_options()" - "from tt_depthpro2.config import DEFAULT_ENGINE, resolve_config; assert DEFAULT_ENGINE == {'enc': 'mk', 'dec': 'mk', 'fov': 'mk'} and resolve_config(env={}).engine == DEFAULT_ENGINE and resolve_config(env={'DEPTHPRO2_ENGINE': 'dec=ttnn'}).engine == {'enc': 'mk', 'dec': 'ttnn', 'fov': 'mk'}" # the shipped sample (CC0), its stored CPU-reference outputs for every size, the licence notice, the scripts - "import hashlib, json; from pathlib import Path; d = Path('/opt/tt-metal/tt_depthpro2/samples/kropa_street'); assert hashlib.sha256((d / 'image.jpg').read_bytes()).hexdigest() == 'dee4f3aafb7a1724d251e9af56ad9cd5eebbb95289ff63f4cdc1a2e0609445ae' and (d / 'PROVENANCE.md').is_file() and all(json.loads((d / f'reference.{s}.json').read_text())['size'] == s and (d / f'reference.{s}.npy').is_file() for s in 'SBLH')" @@ -240,8 +245,8 @@ card: "device_size": [480, 640], "resized": false, "focallength_px": 490.04, "focal_source": "fov", "fov_deg": [[65.85, 52.19]], "depth": {"format": "npy", "dtype": "float16", "shape": [480, 640], "data": "...", "units": "m"}, - "stats_m": {"pixels": 307200, "infinite_pixels": 32165, "min": 1.43, "p05": 1.68, "median": 6.97, - "p95": 29.5, "max": 28666.4}, + "stats_m": {"pixels": 307200, "infinite_pixels": 32160, "min": 1.43, "p05": 1.68, "median": 6.96, + "p95": 29.6, "max": 44182.7}, "timing_ms": {"decode": "...", "preprocess": "...", "device": "...", "fov": "...", "postprocess": "...", "encode": "...", "total": "..."}} ``` @@ -280,6 +285,7 @@ card: | video modes | `DEPTHPRO2_VIDEO_MODES` | `buffered`, `unbuffered`, both, or `auto` | `auto`: both when the key-value caches fit 4 GiB of device memory | | unbuffered streams open at once | `DEPTHPRO2_KV_STREAMS` | 1 to 8 (one cache per bucket each) | 1 | | device engines | `DEPTHPRO2_ENGINE` | per stage `mk` (megakernel) or `ttnn` (tt-nn operations), e.g. `dec=ttnn`; stages not named keep the default | `enc=mk,dec=mk,fov=mk` | + | encoder precision | `DEPTHPRO2_ENC_PRECISION` | `high`: on L, float32 LayerNorm output into the attention and MLP input matmuls and two-part (hi / lo) prefix keys; `fast`: the plain bfloat16 encoder on L too (`high` costs L 5-18 % more encoder time); S, B, H+ and the focal-length estimator run the same either way | `high` | Every bucket adds device programs and their start-up time; any clip length up to the window runs on the window's program. The unbuffered key-value caches take device memory per bucket and stream (window 16): @@ -325,11 +331,11 @@ card: | eval | S | B | L | H+ | frames | | --- | --- | --- | --- | --- | --- | | Inverse depth PCC, a 480 x 640 image | 0.999996 | 0.999997 | 0.999999 | 0.999999 | 1 | - | Depth AbsRel, a 480 x 640 image | 0.0035 (0.0039) | 0.0025 (0.0021) | 0.0016 (0.0035) | 0.0024 (0.0016) | 1 | - | Inverse depth PCC / depth AbsRel, a 4-frame 240 x 320 clip (frames attending each other) | 0.999998 / 0.0062 (0.0055) | 0.999998 / 0.0037 (0.0032) | 0.999999 / 0.0024 (0.0042) | 0.999998 / 0.0019 (0.0020) | 4 | - | Inverse depth PCC / depth AbsRel, a 375 x 500 image (padded to 384 x 512) | 0.99961 / 0.0179 (0.0133) | 0.99992 / 0.0094 (0.0079) | 0.9952 [1] / 0.0035 (0.0052) | 0.99993 / 0.0057 (0.0050) | 1 | + | Depth AbsRel, a 480 x 640 image | 0.0035 (0.0039) | 0.0025 (0.0021) | 0.0014 (0.0035) | 0.0024 (0.0016) | 1 | + | Inverse depth PCC / depth AbsRel, a 4-frame 240 x 320 clip (frames attending each other) | 0.999998 / 0.0062 (0.0055) | 0.999998 / 0.0037 (0.0032) | 0.999999 / 0.0018 (0.0042) | 0.999998 / 0.0019 (0.0020) | 4 | + | Inverse depth PCC / depth AbsRel, a 375 x 500 image (padded to 384 x 512) | 0.99961 / 0.0179 (0.0133) | 0.99992 / 0.0094 (0.0079) | 0.9913 [1] / 0.0049 (0.0052) | 0.99993 / 0.0057 (0.0050) | 1 | | Focal length error: 480 x 640 image / 4-frame clip / 375 x 500 image | 0.05 % / 0.16 % / 1.0 % (0.12 % / 0.13 % / 1.45 %) | same estimator | same estimator | same estimator | 6 | - | Inverse depth PCC, every frame of a 16-frame 480 x 640 clip, a 5-frame clip and a 20-frame buffered video (lowest frame, vs this package's float32 CPU reference) | 0.99998 | 0.999996 | 0.999996 | 0.999998 | 41 | + | Inverse depth PCC, every frame of a 16-frame 480 x 640 clip, a 5-frame clip and a 20-frame buffered video (lowest frame, vs this package's float32 CPU reference) | 0.99998 | 0.999996 | 0.999997 | 0.999998 | 41 | | Unbuffered video, every frame (key-value cache; 6 frames of 480 x 640, vs this package's float32 CPU reference) | 0.999988 | 0.999995 | 0.999997 | 0.999998 | 6 | AbsRel is the mean relative depth error over the pixels within 100 times the nearest distance, with Apple's @@ -337,33 +343,35 @@ card: compared with this package's float32 CPU reference (equal to Apple's float32 code to a relative error of 1e-5, this image included); the numbers in parentheses are Apple's own code run in bfloat16 on the same inputs. The focal-length estimator is shared by every size. [1] L's prediction for this image is nearly flat (its inverse - depth varies by about 6 % across the image, against 33-42 % for the other sizes), so its PCC is low (0.995 here, - against 0.9995 for Apple's own bfloat16 run), but its depth AbsRel (0.0035) is within Apple's own bfloat16 AbsRel + depth varies by about 6 % across the image, against 33-42 % for the other sizes), so its PCC is low (0.991 here, + against 0.9995 for Apple's own bfloat16 run), but its depth AbsRel (0.0049) is within Apple's own bfloat16 AbsRel (0.0052). - Determinism: the encoder and focal-estimator megakernels gave bit-identical outputs over 10 launches and 1000 - trace replays at each of 10 shapes (480 x 640 with 1, 4 and 16 frames, 736 x 1280, the focal-estimator trunk), - with no hang; the decoder megakernel over 22 launches and 1000 trace replays at each of 15 configurations (every + Determinism: the encoder megakernel gave bit-identical outputs over 1000 trace replays (after 10 to 21 launches) + at each soaked configuration (S at 480 x 640 with 1 and 16 frames, B with 1, L with 1, 4 and 16, H+ with 1 and 4 + and at 736 x 1280), as did the focal-estimator trunk, with no hang; the decoder megakernel over 22 launches and 1000 trace replays at each of 15 configurations (every size at 640 x 480 with 1 and 16 frames; 480 x 640 with 16 frames for S, L and H+, with 4 frames for B and H+, with 1 frame for H+; 736 x 1280 for L), with no hang, and over 500 trace replays at each of 20 (every size at 480 x 640 with 1, 4 and 16 frames, 736 x 1280 and 1088 x 1920). | speed (batch 1, warm) | input | S | B | L | H+ | | --- | --- | --- | --- | --- | --- | - | Device time, encoder megakernel: 1 frame / 16-frame clip | 480 x 640 | 4.2 / 158 ms | 8.7 / 325 ms | 22.0 / 865 ms | 42.3 / 1934 ms | + | Device time, encoder megakernel: 1 frame / 16-frame clip | 480 x 640 | 4.2 / 158 ms | 8.2 / 325 ms | 23.2 / 947 ms | 42.2 / 1933 ms | | Device time, decoder megakernel: 1 frame / 16 frames | 480 x 640 | 1.5 / 11.3 ms | 3.3 / 22.3 ms | 8.1 / 62.2 ms | 8.3 / 63.8 ms | | Device time, focal-estimator megakernel: 1 / 4 frames | 480 x 640 | 5.7 / 18.3 ms | same | same | same | - | Device time per image (encoder + decoder) | 480 x 640 | 5.7 ms | 12.0 ms | 30.2 ms | 50.6 ms | - | Device time per 16-frame clip (frames/s) | 16 x 480 x 640 | 170 ms (94) | 347 ms (46) | 928 ms (17.2) | 2.00 s (8.0) | - | Served `POST /predict`, server `timing_ms.total` (focal estimated) | the sample, 640 x 480 JPEG | 39 ms | 44 ms | 64 ms | 84 ms | - | Served `POST /predict`, client round trip on loopback | the sample | 58 ms | 63 ms | 82 ms | 102 ms | - | Served `POST /predict_video`, one 16-frame clip, client round trip | 16 frames of 480 x 640 | 1.63 s | 1.72 s | 2.31 s | 3.44 s | - | Served `POST /predict_video`, a 5-frame clip (runs on the 16-frame program), client round trip | 5 frames of 480 x 640 | 0.75 s | 0.83 s | 1.15 s | 1.66 s | - | Served `POST /predict_video`, buffered video of 20 frames (two 16-frame clips), client round trip | 20 frames of 480 x 640 | 2.34 s | 2.66 s | 3.72 s | 5.77 s | - | Served unbuffered stream, one frame per request (tt-nn encoder step, decoder megakernel, 16-frame cache), client round trip | 480 x 640 frames | 86-107 ms | 117-134 ms | 201-233 ms | 305-339 ms | - | Server start-up in the container (compile and capture every program): a restart with the kernel cache of an earlier start / the first start (empty kernel cache) | default configuration | 31 s / 190 s | 34 s / 190 s | 43 s / 189 s | 60 s / 247 s | - - Device times: traced replays back to back on one p150 (each megakernel from its release benchmark). Served rows: + | Device time per image (encoder + decoder) | 480 x 640 | 5.7 ms | 11.5 ms | 31.4 ms | 51.8 ms | + | Device time per 16-frame clip (frames/s) | 16 x 480 x 640 | 170 ms (94) | 347 ms (46) | 1.01 s (15.9) | 2.00 s (8.0) | + | Served `POST /predict`, server `timing_ms.total` (focal estimated) | the sample, 640 x 480 JPEG | 40 ms | 44 ms | 67 ms | 84 ms | + | Served `POST /predict`, client round trip on loopback | the sample | 57 ms | 62 ms | 85 ms | 102 ms | + | Served `POST /predict_video`, one 16-frame clip, client round trip | 16 frames of 480 x 640 | 1.63 s | 1.69 s | 2.32 s | 3.34 s | + | Served `POST /predict_video`, a 5-frame clip (runs on the 16-frame program), client round trip | 5 frames of 480 x 640 | 0.73 s | 0.78 s | 1.12 s | 1.65 s | + | Served `POST /predict_video`, buffered video of 20 frames (two 16-frame clips), client round trip | 20 frames of 480 x 640 | 2.26 s | 2.53 s | 3.89 s | 5.73 s | + | Served unbuffered stream, one frame per request (tt-nn encoder step, decoder megakernel, 16-frame cache), client round trip | 480 x 640 frames | 87-101 ms | 115-130 ms | 200-228 ms | 305-347 ms | + | Server start-up in the container (compile and capture every program): a restart with the kernel cache of an earlier start / the first start (empty kernel cache) | default configuration | 20 s / 169 s | 27 s / 172 s | 38 s / 186 s | 58 s / 211 s | + + Device times: traced replays back to back on one p150, 20 per configuration, with the default encoder precision + `high` (the decoder rows from the decoder megakernel's release benchmark; per image and per clip: encoder and + decoder replayed together). Served rows: requests to the HTTP server of this package with its default configuration (buckets 480 x 640 and 640 x 480, window 16, unbuffered video on) on the same p150 in an 8-vCPU AMD EPYC-Rome host (`code/scripts/device_server_smoke.py`: 10 requests of the sample, one of each video request; the video requests @@ -383,15 +391,17 @@ card: aspect ratio far from every bucket is stretched, and a small image upscaled to a larger bucket changes the focal-length estimate). Configure your camera's native resolution as a bucket (`DEPTHPRO2_RESOLUTIONS`) for the most faithful results. - - Accuracy outside the gate images: of 16 held-out cases (four inputs at every size, scored against Apple's - float32 output with the same gates), 14 pass. Both misses are on one 480 x 640 photo (Apple's `images.jpg`). - L sees that scene as nearly flat (its inverse depth varies by about 15 % across the image) and reaches an - inverse-depth PCC of 0.998, below the 0.999 gate, where Apple's own bfloat16 run reaches 0.9993; its depth - AbsRel (0.0060) is 1.1 times Apple's bfloat16 error, within the 2x target. S's depth AbsRel on that photo is - 0.027, 2.05 times Apple's bfloat16 error (0.0133), just over the 2x target. Near-flat scenes (for PCC) and S's - depth error on sensitive scenes are the weakest points of this port. The all-tt-nn engine - (`DEPTHPRO2_ENGINE=ttnn`) gives S a lower depth error on that photo (0.022, 1.7 times Apple's bfloat16 error) - at about 2.8 times the device time per image. + - Accuracy outside the gate images: on an independent held-out set (10 inputs: outdoor, indoor, portrait, + telephoto and near-flat images plus a 4- and an 8-frame clip; 40 cases over the four sizes, scored against + Apple's float32 output with the same gates), 38 of 40 pass (S 10, B 9, L 10, H+ 9). The two misses: B on a + sky-and-water landscape, depth AbsRel 0.013 against a budget of 0.010 (Apple's own bfloat16: 0.004), a uniform + 1.5 % depth scale offset; H+ on a 4-frame close-up clip, inverse-depth PCC 0.993 against 0.999, where Apple's own + bfloat16 run reaches only 0.995 (its depth AbsRel, 0.014, is lower than that run's 0.017). The closest passes + are S on the 8-frame clip (AbsRel 0.024 within 0.026) and L on a bright-background beach portrait (0.025 + within 0.035; Apple's bfloat16 0.018). On four further inputs, used to + tune L's encoder precision and so not held out, L reaches an inverse-depth PCC of 0.99957 on Apple's + `images.jpg` at 480 x 640, while S's depth AbsRel on that photo is 0.027, 2.05 times Apple's own bfloat16 error + (0.0133), just over the 2x target. - The resolution buckets and the video window are fixed when the server starts. A clip shorter than the window runs on the window's device program and takes as long as a full window. - Buffered video returns a frame only once its clip is predicted, so it lags the input by up to a window; diff --git a/tt_kernel_manifest.json b/tt_kernel_manifest.json index a106abb6d1e5d51ba486d77ac8f90990cd88e5f9..8ca6daafd7bd18d33381b4ca41f9e61982cbbfa4 100644 --- a/tt_kernel_manifest.json +++ b/tt_kernel_manifest.json @@ -6,7 +6,7 @@ "device_count": 1, "producer": { "tt_kernel_version": "0.1.0", - "created_at": "2026-11-29T15:31:52.763551+00:00", + "created_at": "2026-11-30T01:26:23.045478+00:00", "hostname": "hchang-bh" }, "weights": { @@ -82,8 +82,8 @@ "image": { "registry": "hf", "repository": "depthpro2", - "tag": "tt-model/depthpro2:7d4a5a78b320", - "digest": "sha256:7d4a5a78b320ccf9ed7016c84749884f55b0006c74138e412a411da88e96c90d" + "tag": "tt-model/depthpro2:33f737b5c906", + "digest": "sha256:33f737b5c90656461fe9bd146cb79535e86801e8ae6ff472fba02d98d642d96d" }, "kind": "tt-dit-server", "runtime": { @@ -125,7 +125,8 @@ "DEPTHPRO2_KV_STREAMS": "1", "DEPTHPRO2_FOV": "1", "DEPTHPRO2_TORCH_THREADS": "4", - "DEPTHPRO2_ENGINE": "enc=mk,dec=mk,fov=mk" + "DEPTHPRO2_ENGINE": "enc=mk,dec=mk,fov=mk", + "DEPTHPRO2_ENC_PRECISION": "high" } }, "serve_profiles": [ @@ -207,12 +208,13 @@ "import sys, tt_depthpro2.server.app as a; assert a.app and 'ttnn' not in sys.modules and 'torch' not in sys.modules, 'the server module must import without ttnn / torch'", "from tt_depthpro2.server.app import parse_mesh_shape as p; assert p('1x1') == p('(1, 1)') == p('1,1') == (1, 1)", "from tt_depthpro2.server.app import load_config; c = load_config({'DEPTHPRO2_SIZE': 'L', 'DEPTHPRO2_RESOLUTIONS': 'vga,vga_portrait', 'DEPTHPRO2_WINDOW': '16', 'DEPTHPRO2_OVERLAP': '4', 'DEPTHPRO2_VIDEO_MODES': 'auto', 'DEPTHPRO2_KV_STREAMS': '1', 'DEPTHPRO2_FOV': '1', 'DEPTHPRO2_DISPATCH': 'eth', 'DEPTHPRO2_NUM_CQS': '1', 'DEPTHPRO2_ENGINE': 'enc=mk,dec=mk,fov=mk', 'TT_AUXILIARY_WEIGHTS': 'apple/DepthPro2-S@903a1c1ade918831d138adcc4aedbcc8f4da0078,apple/DepthPro2-B@85e67fdfb7f5b36a6f6c4495e6789d331b1d8a04,apple/DepthPro2-L@849dc5461267e0bc006ec63ab46920ea1ed98702,apple/DepthPro2-H@68426c789f75a7c760273e857222625b4fe69576', 'TT_MODEL_WEIGHTS_REVISION': '622659d44a2002cf9ae4333f2569afa938290d9a'}); m = c.model; assert m.engine == {'enc': 'mk', 'dec': 'mk', 'fov': 'mk'}, m.engine; assert (m.size, m.resolutions, m.window, m.overlap, m.video_modes, m.video_modes_auto, m.kv_streams, m.clip_lengths, m.fov, c.dispatch, c.num_command_queues, c.revision, c.fov_revision) == ('L', ((480, 640), (640, 480)), 16, 4, ('buffered', 'unbuffered'), True, 1, (1, 16), True, 'eth', 1, '849dc5461267e0bc006ec63ab46920ea1ed98702', '622659d44a2002cf9ae4333f2569afa938290d9a'), c", - "from tt_depthpro2.server.app import load_config as L\nfor bad in ({'DEPTHPRO2_SIZE': 'XL'}, {'DEPTHPRO2_RESOLUTIONS': '480x'}, {'DEPTHPRO2_WINDOW': '17'}, {'DEPTHPRO2_OVERLAP': '16'}, {'DEPTHPRO2_VIDEO_MODES': 'live'}, {'DEPTHPRO2_KV_STREAMS': '0'}, {'DEPTHPRO2_ENGINE': 'dec=gpu'}, {'TT_MESH_SHAPE': '1x2'}):\n try:\n L(bad)\n except RuntimeError:\n continue\n raise AssertionError(bad)", + "from tt_depthpro2.server.app import load_config as L\nfor bad in ({'DEPTHPRO2_SIZE': 'XL'}, {'DEPTHPRO2_RESOLUTIONS': '480x'}, {'DEPTHPRO2_WINDOW': '17'}, {'DEPTHPRO2_OVERLAP': '16'}, {'DEPTHPRO2_VIDEO_MODES': 'live'}, {'DEPTHPRO2_KV_STREAMS': '0'}, {'DEPTHPRO2_ENGINE': 'dec=gpu'}, {'DEPTHPRO2_ENC_PRECISION': 'medium'}, {'TT_MESH_SHAPE': '1x2'}):\n try:\n L(bad)\n except RuntimeError:\n continue\n raise AssertionError(bad)", "from tt_depthpro2.config import WEIGHTS; assert WEIGHTS == {'focal': ('apple/DepthPro2-focal', '622659d44a2002cf9ae4333f2569afa938290d9a'), 'S': ('apple/DepthPro2-S', '903a1c1ade918831d138adcc4aedbcc8f4da0078'), 'B': ('apple/DepthPro2-B', '85e67fdfb7f5b36a6f6c4495e6789d331b1d8a04'), 'L': ('apple/DepthPro2-L', '849dc5461267e0bc006ec63ab46920ea1ed98702'), 'H': ('apple/DepthPro2-H', '68426c789f75a7c760273e857222625b4fe69576')}", "import tt_depthpro2.api, tt_depthpro2.cpu_engine, tt_depthpro2.streaming, tt_depthpro2.reference.model as R; assert R.SIZES['H'].swiglu and tt_depthpro2.api.plan_buffered_clips(10, 4, 1) == [4, 4, 4]", "from tt_depthpro2.tt.model import DepthPro2Device as D, trace_region_bytes, planned_frames, kv_state_bytes; import inspect; p = inspect.signature(D).parameters; assert D.supports_kv_cache and all(k in p for k in ('fov_shapes', 'clip_lengths', 'precision', 'kv_cache', 'kv_streams')) and hasattr(D, 'inverse_depth_step') and trace_region_bytes('L', [(480, 640), (640, 480)], [1, 16], kv_cache=True) > (64 << 20)", "import importlib.util; from pathlib import Path; d = Path('/opt/tt-metal/tt_depthpro2/tt'); assert all((d / f'mk_enc/kernels/me_{r}.cpp').is_file() and (d / f'mk_dec/kernels/md_{r}.cpp').is_file() for r in ('brisc', 'ncrisc', 'trisc')) and all(importlib.util.find_spec(f'tt_depthpro2.tt.{m}') for m in ('mk_enc', 'mk_fov', 'mk_dec'))", "from pathlib import Path; d = Path('/opt/tt-metal/tt_depthpro2/tt'); n = {p.name for p in (d / 'mk_enc' / 'kernels').iterdir()}; m = {p.name for p in (d / 'mk_dec' / 'kernels').iterdir()}; assert {'me_brisc.cpp', 'me_ncrisc.cpp', 'me_trisc.cpp', 'me_defs.hpp', 'me_dm.hpp'} <= n and {'md_brisc.cpp', 'md_ncrisc.cpp', 'md_trisc.cpp', 'md_defs.hpp'} <= m, (n, m)", + "from tt_depthpro2 import config as C; assert C.resolve_config(env={}).enc_precision == 'high' and C.resolve_config(env={'DEPTHPRO2_ENC_PRECISION': 'fast'}).enc_precision == 'fast' and C.mk_enc_options('fast', 'exp=1,inx32=1') == 'exp=1,inx32=0,klo=0' and C.mk_enc_options('high', 'inx32=0,klo=0') == ''; from tt_depthpro2.tt.mk_enc.program import env_options; import os; os.environ['DEPTHPRO2_MK_ENC_OPTS'] = C.mk_enc_options('fast'); assert env_options() == {'inx32': False, 'klo': 0}, env_options()", "from tt_depthpro2.config import DEFAULT_ENGINE, resolve_config; assert DEFAULT_ENGINE == {'enc': 'mk', 'dec': 'mk', 'fov': 'mk'} and resolve_config(env={}).engine == DEFAULT_ENGINE and resolve_config(env={'DEPTHPRO2_ENGINE': 'dec=ttnn'}).engine == {'enc': 'mk', 'dec': 'ttnn', 'fov': 'mk'}", "import hashlib, json; from pathlib import Path; d = Path('/opt/tt-metal/tt_depthpro2/samples/kropa_street'); assert hashlib.sha256((d / 'image.jpg').read_bytes()).hexdigest() == 'dee4f3aafb7a1724d251e9af56ad9cd5eebbb95289ff63f4cdc1a2e0609445ae' and (d / 'PROVENANCE.md').is_file() and all(json.loads((d / f'reference.{s}.json').read_text())['size'] == s and (d / f'reference.{s}.npy').is_file() for s in 'SBLH')", "from pathlib import Path; d = Path('/opt/tt-metal/tt_depthpro2/licenses'); assert 'Apple Machine Learning Research Model is licensed under the Apple Machine Learning Research Model License Agreement.' in (d / 'NOTICE.md').read_text() and 'Research Purposes' in (d / 'APPLE_MLR_MODEL_LICENSE.txt').read_text() and (d / 'APPLE_SOFTWARE_LICENSE.txt').read_text().startswith('Copyright (C) 2026 Apple Inc.')", @@ -223,10 +225,10 @@ "import ttnn; assert all(hasattr(ttnn, a) for a in ('DispatchCoreConfig', 'begin_trace_capture', 'end_trace_capture', 'execute_trace', 'release_trace', 'copy_host_to_device_tensor', 'generic_op'))" ], "built": { - "image": "tt-model/depthpro2:7d4a5a78b320", + "image": "tt-model/depthpro2:33f737b5c906", "repo": "changh95/DepthPro2", "tt_model_version": "0.1.0", - "created_at": "2026-11-29T15:31:26+00:00", + "created_at": "2026-11-30T01:25:57+00:00", "tt_metal": { "sha": "44d66500520fda9f2c7060c0f6b41ec48f7ab37e", "describe": "v0.80.0-dev20261006-78-g44d6650052-dirty", @@ -237,8 +239,8 @@ "branch": "main", "pushed": true }, - "code_sha256": "bc0132ce79669bfc545af9782cb4e5f8fe2a8edb0d9acb2f749485c4fd0fc5c3", - "image_digest": "sha256:7d4a5a78b320ccf9ed7016c84749884f55b0006c74138e412a411da88e96c90d" + "code_sha256": "a2e9acdc6e000466e400aea5a0c51398ac83036bb1ea2d46a0ae13065dfcac3b", + "image_digest": "sha256:33f737b5c90656461fe9bd146cb79535e86801e8ae6ff472fba02d98d642d96d" }, "card": { "description": "Depth Pro 2 estimates metric depth (metres) and the camera's focal length from a single RGB image or from the frames of a video. Four sizes are served from one image, as the serve profiles `s`, `b`, `l` (default) and `h`: S (24M parameters), B (97M), L (334M) and H+ (872M). Each is a DINOv3 vision transformer with 16 x 16 patches and class / register tokens, in which some blocks attend across all frames of a clip, followed by a DPT decoder and head that output the focal-normalized inverse depth at the input resolution. A shared DINOv3 ViT-S with an attention head estimates the field of view, from which the focal length in pixels follows (median over a clip); metric depth is `f_px / (width * inverse_depth)`, infinite for sky. Inputs run at resolution buckets fixed when the server starts (480 x 640 and 640 x 480 by default; up to 8 buckets from presets such as 720p or 1080p, or any size); an input of another size is resized to the bucket of the nearest aspect ratio and the outputs are resized back. Videos run as overlapping clips of 16 frames (4 shared), cross-faded, as Apple's buffered streaming does, or frame by frame with a key-value cache of the previous frames (Apple's unbuffered streaming). The package includes the pre- and post-processing (EXIF orientation and 35 mm focal length, normalization, padding, the FOV resize, the focal-length median). Decoding, resizing and post-processing run on the host CPU; the network runs on the device as three persistent megakernels, the encoder, the decoder and the focal-length estimator's trunk (one program each per input shape, replayed from traces).", @@ -249,9 +251,9 @@ "status": null, "intended_use": "Non-commercial scientific research with Depth Pro 2's metric depth and focal-length estimates on images and video, for example studying the model's outputs, comparing implementations, or offline experiments, one request at a time. Apple's licence limits every use of the weights and of models derived from them to research purposes.", "out_of_scope_use": null, - "usage": "`POST /predict` takes one base64 image and returns its depth map; `POST /predict_png` takes the raw image file and\nreturns a 16-bit depth PNG; `POST /predict_video` takes the frames of a clip or video and returns one depth map\nper frame. `GET /health` reports readiness, `GET /info` the weights and their commits, the device, the engines,\nthe configuration and the limits, `GET /config` the configuration only; `GET /v1/models` is a stub, not a chat\nAPI.\n\n| request field (`POST /predict`) | meaning |\n| --- | --- |\n| `image` | base64 image file (PNG, JPEG or any format Pillow reads), 16 to 8192 px per side, at most 50 megapixels; turned upright per its EXIF orientation |\n| `f_px` (optional) | the focal length in pixels of the image; default: the image's EXIF 35 mm-equivalent focal length, else the model's estimate |\n| `use_exif` (optional) | `true` (default): use the EXIF focal length when `f_px` is not given |\n| `output_format` (optional) | `npy16` (default: base64 float16 `.npy`), `npy32` (float32), `png16` (base64 16-bit PNG, `uint16 = round(depth_m * png_scale)`, 0 = infinite) or `none` (statistics only) |\n| `include_inverse_depth` (optional) | also return the focal-normalized inverse depth |\n| `png_scale` (optional) | `png16`: units per metre, default 1000 (millimetres; 65.535 m saturates) |\n\n`POST /predict_png` takes the image file as the body and the query parameters `f_px`, `png_scale` and `use_exif`;\nthe focal length, the statistics and the timing come back in `X-Focal-Length-Px`, `X-Stats-M`, `X-Timing-Ms` and\nfurther `X-*` headers.\n\n| request field (`POST /predict_video`) | meaning |\n| --- | --- |\n| `frames` or `clip` | base64 image files in order, or one base64 uint8 `(T, H, W, 3)` `.npy` / `.npz`; one size per video; at most 64 frames per request |\n| `mode` (optional) | `buffered` (default: clips of 16 frames overlapping by 4, cross-faded; one focal length per video, from the first 16 frames), `unbuffered` (each frame attends a key-value cache of the previous 15 frames and is returned at once), `clip` (the frames as one clip that attends to itself, 1 to 16 frames) |\n| `stream` (optional) | `{\"id\": \"\", \"end\": false}` keeps a buffered or unbuffered stream open across requests for long or live videos; each request returns the frames it finishes, `end: true` returns the rest and closes it; one unbuffered stream at a time by default |\n| `f_px`, `window`, `overlap`, `output_format`, `include_inverse_depth` (optional) | as above; `window` / `overlap` at most the server's |\n\nResponse of `/predict` for the sample image as served on the p150 (depth data elided, values rounded, profile\n`l`):\n\n```json\n{\"model\": \"depthpro2\", \"size\": \"L\", \"frames\": 1, \"input_size\": [480, 640], \"bucket\": [480, 640],\n \"device_size\": [480, 640], \"resized\": false, \"focallength_px\": 490.04, \"focal_source\": \"fov\",\n \"fov_deg\": [[65.85, 52.19]],\n \"depth\": {\"format\": \"npy\", \"dtype\": \"float16\", \"shape\": [480, 640], \"data\": \"...\", \"units\": \"m\"},\n \"stats_m\": {\"pixels\": 307200, \"infinite_pixels\": 32165, \"min\": 1.43, \"p05\": 1.68, \"median\": 6.97,\n \"p95\": 29.5, \"max\": 28666.4},\n \"timing_ms\": {\"decode\": \"...\", \"preprocess\": \"...\", \"device\": \"...\", \"fov\": \"...\", \"postprocess\": \"...\",\n \"encode\": \"...\", \"total\": \"...\"}}\n```\n\n- `depth` is metres along the optical axis at the input size; `inf` (`infinite_pixels`) marks sky, where the\n network's inverse depth is 0. Decode with `np.load(io.BytesIO(base64.b64decode(depth[\"data\"])))`; values\n above 65504 m read as `inf` in the float16 encoding (`npy32` keeps them).\n- `focallength_px` is in input pixels; `focal_source` is `request`, `exif` or `fov`. `fov_deg` is the estimated\n horizontal and vertical field of view per frame.\n- An input of exactly a bucket's size runs natively (`resized: false`); any other size is resized to the bucket\n of the nearest aspect ratio and back (`resized: true`). `/info` lists the buckets.\n- `timing_ms` is measured in the server: decoding, pre-processing, the device run, the focal-length estimate,\n post-processing and response encoding.\n- Errors: HTTP 400 with the reason for an image that cannot be decoded or is out of the size range, a\n non-positive `f_px`, frames of different sizes, a clip length the device programs were not built for, or a\n disabled video mode; 422 for an unknown field or a value of the wrong type; 429 when too many video streams are\n open; 503 while the server starts; 500 with the exception text on a device failure.\n- A Python API with the same outputs (`tt_depthpro2.DepthPro2`: `infer`, `infer_clip`, `infer_video`, `stream`)\n is described in [`code/PYTHON.md`](code/PYTHON.md); it needs a tt-metal build with the two patches in\n [`patches/`](patches/).\n\n### Configuration\n\nThe server builds its device programs for one configuration when it starts; change it with environment variables\nin the container's launch command (`tt-model serve --print` prints it) and start it again. `GET /config` reports\nit.\n\n| item | environment variable | values | default |\n| --- | --- | --- | --- |\n| model size | `DEPTHPRO2_SIZE` (the serve profiles set it) | `S`, `B`, `L`, `H` | `L` (profile `l`) |\n| resolution buckets | `DEPTHPRO2_RESOLUTIONS` | up to 8 of `HxW` (32 to 4096 px per side) or `qvga`, `vga`, `square`, `720p`, `1080p` and their `_portrait` forms | `vga,vga_portrait` |\n| video clip length | `DEPTHPRO2_WINDOW` | 1 to 16 | 16 |\n| buffered overlap | `DEPTHPRO2_OVERLAP` | 0 to window - 1 | 4 |\n| further clip lengths | `DEPTHPRO2_CLIP_LENGTHS` | `auto` (1 and the window), `all`, or a list | `auto` |\n| focal-length estimator | `DEPTHPRO2_FOV` | 1 / 0 | 1 |\n| video modes | `DEPTHPRO2_VIDEO_MODES` | `buffered`, `unbuffered`, both, or `auto` | `auto`: both when the key-value caches fit 4 GiB of device memory |\n| unbuffered streams open at once | `DEPTHPRO2_KV_STREAMS` | 1 to 8 (one cache per bucket each) | 1 |\n| device engines | `DEPTHPRO2_ENGINE` | per stage `mk` (megakernel) or `ttnn` (tt-nn operations), e.g. `dec=ttnn`; stages not named keep the default | `enc=mk,dec=mk,fov=mk` |\n\nEvery bucket adds device programs and their start-up time; any clip length up to the window runs on the window's\nprogram. The unbuffered key-value caches take device memory per bucket and stream (window 16):\n\n| size | per 480 x 640 bucket | default (2 buckets, 1 stream) | per 1080 x 1920 bucket |\n| --- | --- | --- | --- |\n| S | 108 MiB | 217 MiB | 720 MiB |\n| B | 217 MiB | 434 MiB | 1.41 GiB |\n| L | 578 MiB | 1.13 GiB | 3.75 GiB |\n| H+ | 993 MiB | 1.94 GiB | 6.45 GiB (above the `auto` budget: buffered only) |\n\n### Example output\n\n![Depth Pro 2 L on a Tenstorrent p150: a walk down a street in Ljubljana and its inverse depth, served by /predict_video in buffered mode](media/demo_tt.gif)\n\n92 frames (7.4 s at 12.5 frames/s) of a walk down Trubarjeva street in Ljubljana, resized to the 480 x 640 bucket\nand sent to this package's container (profile `l`) as one buffered `/predict_video` stream (16-frame clips\noverlapping by 4). Left: the input; right: the inverse depth it returned, on one logarithmic colour scale for the\nwhole clip (near = red, far = blue, sky = black). Also as [MP4](media/demo_tt.mp4) (1280 x 512, H.264). Source\nvideo: \"Walking down the Trubarjeva street\" by Sounds of Changes,\n[Wikimedia Commons](https://commons.wikimedia.org/wiki/File:Walking_down_the_Trubarjeva_street.webm),\n[CC BY 3.0](https://creativecommons.org/licenses/by/3.0/), trimmed, cropped, resized and shown with the model's\noutput; its author does not endorse this work. Attributions for every file in `media/`:\n[`media/ATTRIBUTION.md`](media/ATTRIBUTION.md).\n\n![Depth Pro 2 L on a Tenstorrent p150: the shipped sample image and its inverse depth from /predict](media/demo_sample.png)\n\nThe shipped sample image (CC0) and the inverse depth `/predict` returned for it on profile `l` (the response\nshown above), with the focal length and the depth range in the caption.\n", - "performance": "Agreement with Apple's own float32 code on the CPU (same weights and inputs) of the shipped engines (encoder,\ndecoder and focal-estimator megakernels), per size, with Apple's own bfloat16 run (its default on GPUs) in\nparentheses:\n\n| eval | S | B | L | H+ | frames |\n| --- | --- | --- | --- | --- | --- |\n| Inverse depth PCC, a 480 x 640 image | 0.999996 | 0.999997 | 0.999999 | 0.999999 | 1 |\n| Depth AbsRel, a 480 x 640 image | 0.0035 (0.0039) | 0.0025 (0.0021) | 0.0016 (0.0035) | 0.0024 (0.0016) | 1 |\n| Inverse depth PCC / depth AbsRel, a 4-frame 240 x 320 clip (frames attending each other) | 0.999998 / 0.0062 (0.0055) | 0.999998 / 0.0037 (0.0032) | 0.999999 / 0.0024 (0.0042) | 0.999998 / 0.0019 (0.0020) | 4 |\n| Inverse depth PCC / depth AbsRel, a 375 x 500 image (padded to 384 x 512) | 0.99961 / 0.0179 (0.0133) | 0.99992 / 0.0094 (0.0079) | 0.9952 [1] / 0.0035 (0.0052) | 0.99993 / 0.0057 (0.0050) | 1 |\n| Focal length error: 480 x 640 image / 4-frame clip / 375 x 500 image | 0.05 % / 0.16 % / 1.0 % (0.12 % / 0.13 % / 1.45 %) | same estimator | same estimator | same estimator | 6 |\n| Inverse depth PCC, every frame of a 16-frame 480 x 640 clip, a 5-frame clip and a 20-frame buffered video (lowest frame, vs this package's float32 CPU reference) | 0.99998 | 0.999996 | 0.999996 | 0.999998 | 41 |\n| Unbuffered video, every frame (key-value cache; 6 frames of 480 x 640, vs this package's float32 CPU reference) | 0.999988 | 0.999995 | 0.999997 | 0.999998 | 6 |\n\nAbsRel is the mean relative depth error over the pixels within 100 times the nearest distance, with Apple's\nfocal length. Apple's float32 output exists for every case except the 375 x 500 image at L and H+, which is\ncompared with this package's float32 CPU reference (equal to Apple's float32 code to a relative error of 1e-5,\nthis image included); the numbers in parentheses are Apple's own code run in bfloat16 on the same inputs. The\nfocal-length estimator is shared by every size. [1] L's prediction for this image is nearly flat (its inverse\ndepth varies by about 6 % across the image, against 33-42 % for the other sizes), so its PCC is low (0.995 here,\nagainst 0.9995 for Apple's own bfloat16 run), but its depth AbsRel (0.0035) is within Apple's own bfloat16 AbsRel\n(0.0052).\n\nDeterminism: the encoder and focal-estimator megakernels gave bit-identical outputs over 10 launches and 1000\ntrace replays at each of 10 shapes (480 x 640 with 1, 4 and 16 frames, 736 x 1280, the focal-estimator trunk),\nwith no hang; the decoder megakernel over 22 launches and 1000 trace replays at each of 15 configurations (every\nsize at 640 x 480 with 1 and 16 frames; 480 x 640 with 16 frames for S, L and H+, with 4 frames for B and H+, with\n1 frame for H+; 736 x 1280 for L), with no hang, and over 500 trace replays at each of 20 (every size at 480 x 640\nwith 1, 4 and 16 frames, 736 x 1280 and 1088 x 1920).\n\n| speed (batch 1, warm) | input | S | B | L | H+ |\n| --- | --- | --- | --- | --- | --- |\n| Device time, encoder megakernel: 1 frame / 16-frame clip | 480 x 640 | 4.2 / 158 ms | 8.7 / 325 ms | 22.0 / 865 ms | 42.3 / 1934 ms |\n| Device time, decoder megakernel: 1 frame / 16 frames | 480 x 640 | 1.5 / 11.3 ms | 3.3 / 22.3 ms | 8.1 / 62.2 ms | 8.3 / 63.8 ms |\n| Device time, focal-estimator megakernel: 1 / 4 frames | 480 x 640 | 5.7 / 18.3 ms | same | same | same |\n| Device time per image (encoder + decoder) | 480 x 640 | 5.7 ms | 12.0 ms | 30.2 ms | 50.6 ms |\n| Device time per 16-frame clip (frames/s) | 16 x 480 x 640 | 170 ms (94) | 347 ms (46) | 928 ms (17.2) | 2.00 s (8.0) |\n| Served `POST /predict`, server `timing_ms.total` (focal estimated) | the sample, 640 x 480 JPEG | 39 ms | 44 ms | 64 ms | 84 ms |\n| Served `POST /predict`, client round trip on loopback | the sample | 58 ms | 63 ms | 82 ms | 102 ms |\n| Served `POST /predict_video`, one 16-frame clip, client round trip | 16 frames of 480 x 640 | 1.63 s | 1.72 s | 2.31 s | 3.44 s |\n| Served `POST /predict_video`, a 5-frame clip (runs on the 16-frame program), client round trip | 5 frames of 480 x 640 | 0.75 s | 0.83 s | 1.15 s | 1.66 s |\n| Served `POST /predict_video`, buffered video of 20 frames (two 16-frame clips), client round trip | 20 frames of 480 x 640 | 2.34 s | 2.66 s | 3.72 s | 5.77 s |\n| Served unbuffered stream, one frame per request (tt-nn encoder step, decoder megakernel, 16-frame cache), client round trip | 480 x 640 frames | 86-107 ms | 117-134 ms | 201-233 ms | 305-339 ms |\n| Server start-up in the container (compile and capture every program): a restart with the kernel cache of an earlier start / the first start (empty kernel cache) | default configuration | 31 s / 190 s | 34 s / 190 s | 43 s / 189 s | 60 s / 247 s |\n\nDevice times: traced replays back to back on one p150 (each megakernel from its release benchmark). Served rows:\nrequests to the HTTP server of this package with its default configuration (buckets 480 x 640 and 640 x 480,\nwindow 16, unbuffered video on) on the same p150 in an 8-vCPU AMD EPYC-Rome host\n(`code/scripts/device_server_smoke.py`: 10 requests of the sample, one of each video request; the video requests\nreturned float32 depth and inverse depth for every frame, which is part of their time). A served request adds\nimage decoding, resizing, the focal estimate when no `f_px` is sent and the response encoding on the host CPU.\nStart-up: the server's own \"ready in\" time in the container started by `tt serve`, per profile; the first start\ncompiles the device kernels into the container's kernel cache, which `tt serve` keeps for later starts.\n", - "limitations": "- Research use only: Apple's licence allows the weights, and models derived from them such as this package, to be\n used exclusively for non-commercial scientific research; no commercial use, product development or use in a\n commercial product or service. Not for safety-critical uses (driving, robot control, medical or industrial\n measurement): the depth is an estimate from one camera, unvalidated for such uses, on the device and on Apple's\n code alike.\n- Inputs of a size that is not a configured bucket are resized to the bucket of the nearest aspect ratio and the\n outputs are resized back, so their results approximate what the network gives at the input's own size (an\n aspect ratio far from every bucket is stretched, and a small image upscaled to a larger bucket changes the\n focal-length estimate). Configure your camera's native resolution as a bucket (`DEPTHPRO2_RESOLUTIONS`) for the\n most faithful results.\n- Accuracy outside the gate images: of 16 held-out cases (four inputs at every size, scored against Apple's\n float32 output with the same gates), 14 pass. Both misses are on one 480 x 640 photo (Apple's `images.jpg`).\n L sees that scene as nearly flat (its inverse depth varies by about 15 % across the image) and reaches an\n inverse-depth PCC of 0.998, below the 0.999 gate, where Apple's own bfloat16 run reaches 0.9993; its depth\n AbsRel (0.0060) is 1.1 times Apple's bfloat16 error, within the 2x target. S's depth AbsRel on that photo is\n 0.027, 2.05 times Apple's bfloat16 error (0.0133), just over the 2x target. Near-flat scenes (for PCC) and S's\n depth error on sensitive scenes are the weakest points of this port. The all-tt-nn engine\n (`DEPTHPRO2_ENGINE=ttnn`) gives S a lower depth error on that photo (0.022, 1.7 times Apple's bfloat16 error)\n at about 2.8 times the device time per image.\n- The resolution buckets and the video window are fixed when the server starts. A clip shorter than the window\n runs on the window's device program and takes as long as a full window.\n- Buffered video returns a frame only once its clip is predicted, so it lags the input by up to a window;\n unbuffered video returns each frame at once but sees only earlier frames, and one unbuffered stream is open at\n a time by default (more need `DEPTHPRO2_KV_STREAMS`; a stream beyond it is refused with HTTP 429). The\n unbuffered frame-by-frame steps run the encoder in tt-nn operations (the encoder megakernel has no key-value\n cache path), so they are slower per frame than an image.\n- The tt-nn decoder remains selectable (`DEPTHPRO2_ENGINE=dec=ttnn`), as does each stage's tt-nn implementation.\n- The tt-nn encoder (the unbuffered steps, and `enc=ttnn`) uses tt-nn's scaled-dot-product attention, which\n returned wrong rows when its batch x heads exceeded 24 (tt-nn encoder clips of 16 frames at 480 x 640 or of 4\n frames for H+); the package runs those attentions in tt-nn's windowed mode, which is correct and gives the same\n results.\n- Batch 1; requests are served one at a time. One p150 only: the image runs device dispatch on the chip's Ethernet\n cores, so multi-chip meshes are not supported.\n- Precision: bfloat16 weights and activations on the device with float32 accumulation, residual streams,\n normalisation statistics and positional rotations, against Apple's float32 reference (Apple evaluates in\n bfloat16 on GPUs); Expected performance gives the measured agreement.\n- All four sizes' weights are downloaded whichever profile is served. The focal length comes from the image's EXIF\n data when present (35 mm-equivalent focal length), which can be wrong for cropped or digitally zoomed images:\n pass `f_px` or `use_exif: false` then.\n", + "usage": "`POST /predict` takes one base64 image and returns its depth map; `POST /predict_png` takes the raw image file and\nreturns a 16-bit depth PNG; `POST /predict_video` takes the frames of a clip or video and returns one depth map\nper frame. `GET /health` reports readiness, `GET /info` the weights and their commits, the device, the engines,\nthe configuration and the limits, `GET /config` the configuration only; `GET /v1/models` is a stub, not a chat\nAPI.\n\n| request field (`POST /predict`) | meaning |\n| --- | --- |\n| `image` | base64 image file (PNG, JPEG or any format Pillow reads), 16 to 8192 px per side, at most 50 megapixels; turned upright per its EXIF orientation |\n| `f_px` (optional) | the focal length in pixels of the image; default: the image's EXIF 35 mm-equivalent focal length, else the model's estimate |\n| `use_exif` (optional) | `true` (default): use the EXIF focal length when `f_px` is not given |\n| `output_format` (optional) | `npy16` (default: base64 float16 `.npy`), `npy32` (float32), `png16` (base64 16-bit PNG, `uint16 = round(depth_m * png_scale)`, 0 = infinite) or `none` (statistics only) |\n| `include_inverse_depth` (optional) | also return the focal-normalized inverse depth |\n| `png_scale` (optional) | `png16`: units per metre, default 1000 (millimetres; 65.535 m saturates) |\n\n`POST /predict_png` takes the image file as the body and the query parameters `f_px`, `png_scale` and `use_exif`;\nthe focal length, the statistics and the timing come back in `X-Focal-Length-Px`, `X-Stats-M`, `X-Timing-Ms` and\nfurther `X-*` headers.\n\n| request field (`POST /predict_video`) | meaning |\n| --- | --- |\n| `frames` or `clip` | base64 image files in order, or one base64 uint8 `(T, H, W, 3)` `.npy` / `.npz`; one size per video; at most 64 frames per request |\n| `mode` (optional) | `buffered` (default: clips of 16 frames overlapping by 4, cross-faded; one focal length per video, from the first 16 frames), `unbuffered` (each frame attends a key-value cache of the previous 15 frames and is returned at once), `clip` (the frames as one clip that attends to itself, 1 to 16 frames) |\n| `stream` (optional) | `{\"id\": \"\", \"end\": false}` keeps a buffered or unbuffered stream open across requests for long or live videos; each request returns the frames it finishes, `end: true` returns the rest and closes it; one unbuffered stream at a time by default |\n| `f_px`, `window`, `overlap`, `output_format`, `include_inverse_depth` (optional) | as above; `window` / `overlap` at most the server's |\n\nResponse of `/predict` for the sample image as served on the p150 (depth data elided, values rounded, profile\n`l`):\n\n```json\n{\"model\": \"depthpro2\", \"size\": \"L\", \"frames\": 1, \"input_size\": [480, 640], \"bucket\": [480, 640],\n \"device_size\": [480, 640], \"resized\": false, \"focallength_px\": 490.04, \"focal_source\": \"fov\",\n \"fov_deg\": [[65.85, 52.19]],\n \"depth\": {\"format\": \"npy\", \"dtype\": \"float16\", \"shape\": [480, 640], \"data\": \"...\", \"units\": \"m\"},\n \"stats_m\": {\"pixels\": 307200, \"infinite_pixels\": 32160, \"min\": 1.43, \"p05\": 1.68, \"median\": 6.96,\n \"p95\": 29.6, \"max\": 44182.7},\n \"timing_ms\": {\"decode\": \"...\", \"preprocess\": \"...\", \"device\": \"...\", \"fov\": \"...\", \"postprocess\": \"...\",\n \"encode\": \"...\", \"total\": \"...\"}}\n```\n\n- `depth` is metres along the optical axis at the input size; `inf` (`infinite_pixels`) marks sky, where the\n network's inverse depth is 0. Decode with `np.load(io.BytesIO(base64.b64decode(depth[\"data\"])))`; values\n above 65504 m read as `inf` in the float16 encoding (`npy32` keeps them).\n- `focallength_px` is in input pixels; `focal_source` is `request`, `exif` or `fov`. `fov_deg` is the estimated\n horizontal and vertical field of view per frame.\n- An input of exactly a bucket's size runs natively (`resized: false`); any other size is resized to the bucket\n of the nearest aspect ratio and back (`resized: true`). `/info` lists the buckets.\n- `timing_ms` is measured in the server: decoding, pre-processing, the device run, the focal-length estimate,\n post-processing and response encoding.\n- Errors: HTTP 400 with the reason for an image that cannot be decoded or is out of the size range, a\n non-positive `f_px`, frames of different sizes, a clip length the device programs were not built for, or a\n disabled video mode; 422 for an unknown field or a value of the wrong type; 429 when too many video streams are\n open; 503 while the server starts; 500 with the exception text on a device failure.\n- A Python API with the same outputs (`tt_depthpro2.DepthPro2`: `infer`, `infer_clip`, `infer_video`, `stream`)\n is described in [`code/PYTHON.md`](code/PYTHON.md); it needs a tt-metal build with the two patches in\n [`patches/`](patches/).\n\n### Configuration\n\nThe server builds its device programs for one configuration when it starts; change it with environment variables\nin the container's launch command (`tt-model serve --print` prints it) and start it again. `GET /config` reports\nit.\n\n| item | environment variable | values | default |\n| --- | --- | --- | --- |\n| model size | `DEPTHPRO2_SIZE` (the serve profiles set it) | `S`, `B`, `L`, `H` | `L` (profile `l`) |\n| resolution buckets | `DEPTHPRO2_RESOLUTIONS` | up to 8 of `HxW` (32 to 4096 px per side) or `qvga`, `vga`, `square`, `720p`, `1080p` and their `_portrait` forms | `vga,vga_portrait` |\n| video clip length | `DEPTHPRO2_WINDOW` | 1 to 16 | 16 |\n| buffered overlap | `DEPTHPRO2_OVERLAP` | 0 to window - 1 | 4 |\n| further clip lengths | `DEPTHPRO2_CLIP_LENGTHS` | `auto` (1 and the window), `all`, or a list | `auto` |\n| focal-length estimator | `DEPTHPRO2_FOV` | 1 / 0 | 1 |\n| video modes | `DEPTHPRO2_VIDEO_MODES` | `buffered`, `unbuffered`, both, or `auto` | `auto`: both when the key-value caches fit 4 GiB of device memory |\n| unbuffered streams open at once | `DEPTHPRO2_KV_STREAMS` | 1 to 8 (one cache per bucket each) | 1 |\n| device engines | `DEPTHPRO2_ENGINE` | per stage `mk` (megakernel) or `ttnn` (tt-nn operations), e.g. `dec=ttnn`; stages not named keep the default | `enc=mk,dec=mk,fov=mk` |\n| encoder precision | `DEPTHPRO2_ENC_PRECISION` | `high`: on L, float32 LayerNorm output into the attention and MLP input matmuls and two-part (hi / lo) prefix keys; `fast`: the plain bfloat16 encoder on L too (`high` costs L 5-18 % more encoder time); S, B, H+ and the focal-length estimator run the same either way | `high` |\n\nEvery bucket adds device programs and their start-up time; any clip length up to the window runs on the window's\nprogram. The unbuffered key-value caches take device memory per bucket and stream (window 16):\n\n| size | per 480 x 640 bucket | default (2 buckets, 1 stream) | per 1080 x 1920 bucket |\n| --- | --- | --- | --- |\n| S | 108 MiB | 217 MiB | 720 MiB |\n| B | 217 MiB | 434 MiB | 1.41 GiB |\n| L | 578 MiB | 1.13 GiB | 3.75 GiB |\n| H+ | 993 MiB | 1.94 GiB | 6.45 GiB (above the `auto` budget: buffered only) |\n\n### Example output\n\n![Depth Pro 2 L on a Tenstorrent p150: a walk down a street in Ljubljana and its inverse depth, served by /predict_video in buffered mode](media/demo_tt.gif)\n\n92 frames (7.4 s at 12.5 frames/s) of a walk down Trubarjeva street in Ljubljana, resized to the 480 x 640 bucket\nand sent to this package's container (profile `l`) as one buffered `/predict_video` stream (16-frame clips\noverlapping by 4). Left: the input; right: the inverse depth it returned, on one logarithmic colour scale for the\nwhole clip (near = red, far = blue, sky = black). Also as [MP4](media/demo_tt.mp4) (1280 x 512, H.264). Source\nvideo: \"Walking down the Trubarjeva street\" by Sounds of Changes,\n[Wikimedia Commons](https://commons.wikimedia.org/wiki/File:Walking_down_the_Trubarjeva_street.webm),\n[CC BY 3.0](https://creativecommons.org/licenses/by/3.0/), trimmed, cropped, resized and shown with the model's\noutput; its author does not endorse this work. Attributions for every file in `media/`:\n[`media/ATTRIBUTION.md`](media/ATTRIBUTION.md).\n\n![Depth Pro 2 L on a Tenstorrent p150: the shipped sample image and its inverse depth from /predict](media/demo_sample.png)\n\nThe shipped sample image (CC0) and the inverse depth `/predict` returned for it on profile `l` (the response\nshown above), with the focal length and the depth range in the caption.\n", + "performance": "Agreement with Apple's own float32 code on the CPU (same weights and inputs) of the shipped engines (encoder,\ndecoder and focal-estimator megakernels), per size, with Apple's own bfloat16 run (its default on GPUs) in\nparentheses:\n\n| eval | S | B | L | H+ | frames |\n| --- | --- | --- | --- | --- | --- |\n| Inverse depth PCC, a 480 x 640 image | 0.999996 | 0.999997 | 0.999999 | 0.999999 | 1 |\n| Depth AbsRel, a 480 x 640 image | 0.0035 (0.0039) | 0.0025 (0.0021) | 0.0014 (0.0035) | 0.0024 (0.0016) | 1 |\n| Inverse depth PCC / depth AbsRel, a 4-frame 240 x 320 clip (frames attending each other) | 0.999998 / 0.0062 (0.0055) | 0.999998 / 0.0037 (0.0032) | 0.999999 / 0.0018 (0.0042) | 0.999998 / 0.0019 (0.0020) | 4 |\n| Inverse depth PCC / depth AbsRel, a 375 x 500 image (padded to 384 x 512) | 0.99961 / 0.0179 (0.0133) | 0.99992 / 0.0094 (0.0079) | 0.9913 [1] / 0.0049 (0.0052) | 0.99993 / 0.0057 (0.0050) | 1 |\n| Focal length error: 480 x 640 image / 4-frame clip / 375 x 500 image | 0.05 % / 0.16 % / 1.0 % (0.12 % / 0.13 % / 1.45 %) | same estimator | same estimator | same estimator | 6 |\n| Inverse depth PCC, every frame of a 16-frame 480 x 640 clip, a 5-frame clip and a 20-frame buffered video (lowest frame, vs this package's float32 CPU reference) | 0.99998 | 0.999996 | 0.999997 | 0.999998 | 41 |\n| Unbuffered video, every frame (key-value cache; 6 frames of 480 x 640, vs this package's float32 CPU reference) | 0.999988 | 0.999995 | 0.999997 | 0.999998 | 6 |\n\nAbsRel is the mean relative depth error over the pixels within 100 times the nearest distance, with Apple's\nfocal length. Apple's float32 output exists for every case except the 375 x 500 image at L and H+, which is\ncompared with this package's float32 CPU reference (equal to Apple's float32 code to a relative error of 1e-5,\nthis image included); the numbers in parentheses are Apple's own code run in bfloat16 on the same inputs. The\nfocal-length estimator is shared by every size. [1] L's prediction for this image is nearly flat (its inverse\ndepth varies by about 6 % across the image, against 33-42 % for the other sizes), so its PCC is low (0.991 here,\nagainst 0.9995 for Apple's own bfloat16 run), but its depth AbsRel (0.0049) is within Apple's own bfloat16 AbsRel\n(0.0052).\n\nDeterminism: the encoder megakernel gave bit-identical outputs over 1000 trace replays (after 10 to 21 launches)\nat each soaked configuration (S at 480 x 640 with 1 and 16 frames, B with 1, L with 1, 4 and 16, H+ with 1 and 4\nand at 736 x 1280), as did the focal-estimator trunk, with no hang; the decoder megakernel over 22 launches and 1000 trace replays at each of 15 configurations (every\nsize at 640 x 480 with 1 and 16 frames; 480 x 640 with 16 frames for S, L and H+, with 4 frames for B and H+, with\n1 frame for H+; 736 x 1280 for L), with no hang, and over 500 trace replays at each of 20 (every size at 480 x 640\nwith 1, 4 and 16 frames, 736 x 1280 and 1088 x 1920).\n\n| speed (batch 1, warm) | input | S | B | L | H+ |\n| --- | --- | --- | --- | --- | --- |\n| Device time, encoder megakernel: 1 frame / 16-frame clip | 480 x 640 | 4.2 / 158 ms | 8.2 / 325 ms | 23.2 / 947 ms | 42.2 / 1933 ms |\n| Device time, decoder megakernel: 1 frame / 16 frames | 480 x 640 | 1.5 / 11.3 ms | 3.3 / 22.3 ms | 8.1 / 62.2 ms | 8.3 / 63.8 ms |\n| Device time, focal-estimator megakernel: 1 / 4 frames | 480 x 640 | 5.7 / 18.3 ms | same | same | same |\n| Device time per image (encoder + decoder) | 480 x 640 | 5.7 ms | 11.5 ms | 31.4 ms | 51.8 ms |\n| Device time per 16-frame clip (frames/s) | 16 x 480 x 640 | 170 ms (94) | 347 ms (46) | 1.01 s (15.9) | 2.00 s (8.0) |\n| Served `POST /predict`, server `timing_ms.total` (focal estimated) | the sample, 640 x 480 JPEG | 40 ms | 44 ms | 67 ms | 84 ms |\n| Served `POST /predict`, client round trip on loopback | the sample | 57 ms | 62 ms | 85 ms | 102 ms |\n| Served `POST /predict_video`, one 16-frame clip, client round trip | 16 frames of 480 x 640 | 1.63 s | 1.69 s | 2.32 s | 3.34 s |\n| Served `POST /predict_video`, a 5-frame clip (runs on the 16-frame program), client round trip | 5 frames of 480 x 640 | 0.73 s | 0.78 s | 1.12 s | 1.65 s |\n| Served `POST /predict_video`, buffered video of 20 frames (two 16-frame clips), client round trip | 20 frames of 480 x 640 | 2.26 s | 2.53 s | 3.89 s | 5.73 s |\n| Served unbuffered stream, one frame per request (tt-nn encoder step, decoder megakernel, 16-frame cache), client round trip | 480 x 640 frames | 87-101 ms | 115-130 ms | 200-228 ms | 305-347 ms |\n| Server start-up in the container (compile and capture every program): a restart with the kernel cache of an earlier start / the first start (empty kernel cache) | default configuration | 20 s / 169 s | 27 s / 172 s | 38 s / 186 s | 58 s / 211 s |\n\nDevice times: traced replays back to back on one p150, 20 per configuration, with the default encoder precision\n`high` (the decoder rows from the decoder megakernel's release benchmark; per image and per clip: encoder and\ndecoder replayed together). Served rows:\nrequests to the HTTP server of this package with its default configuration (buckets 480 x 640 and 640 x 480,\nwindow 16, unbuffered video on) on the same p150 in an 8-vCPU AMD EPYC-Rome host\n(`code/scripts/device_server_smoke.py`: 10 requests of the sample, one of each video request; the video requests\nreturned float32 depth and inverse depth for every frame, which is part of their time). A served request adds\nimage decoding, resizing, the focal estimate when no `f_px` is sent and the response encoding on the host CPU.\nStart-up: the server's own \"ready in\" time in the container started by `tt serve`, per profile; the first start\ncompiles the device kernels into the container's kernel cache, which `tt serve` keeps for later starts.\n", + "limitations": "- Research use only: Apple's licence allows the weights, and models derived from them such as this package, to be\n used exclusively for non-commercial scientific research; no commercial use, product development or use in a\n commercial product or service. Not for safety-critical uses (driving, robot control, medical or industrial\n measurement): the depth is an estimate from one camera, unvalidated for such uses, on the device and on Apple's\n code alike.\n- Inputs of a size that is not a configured bucket are resized to the bucket of the nearest aspect ratio and the\n outputs are resized back, so their results approximate what the network gives at the input's own size (an\n aspect ratio far from every bucket is stretched, and a small image upscaled to a larger bucket changes the\n focal-length estimate). Configure your camera's native resolution as a bucket (`DEPTHPRO2_RESOLUTIONS`) for the\n most faithful results.\n- Accuracy outside the gate images: on an independent held-out set (10 inputs: outdoor, indoor, portrait,\n telephoto and near-flat images plus a 4- and an 8-frame clip; 40 cases over the four sizes, scored against\n Apple's float32 output with the same gates), 38 of 40 pass (S 10, B 9, L 10, H+ 9). The two misses: B on a\n sky-and-water landscape, depth AbsRel 0.013 against a budget of 0.010 (Apple's own bfloat16: 0.004), a uniform\n 1.5 % depth scale offset; H+ on a 4-frame close-up clip, inverse-depth PCC 0.993 against 0.999, where Apple's own\n bfloat16 run reaches only 0.995 (its depth AbsRel, 0.014, is lower than that run's 0.017). The closest passes\n are S on the 8-frame clip (AbsRel 0.024 within 0.026) and L on a bright-background beach portrait (0.025\n within 0.035; Apple's bfloat16 0.018). On four further inputs, used to\n tune L's encoder precision and so not held out, L reaches an inverse-depth PCC of 0.99957 on Apple's\n `images.jpg` at 480 x 640, while S's depth AbsRel on that photo is 0.027, 2.05 times Apple's own bfloat16 error\n (0.0133), just over the 2x target.\n- The resolution buckets and the video window are fixed when the server starts. A clip shorter than the window\n runs on the window's device program and takes as long as a full window.\n- Buffered video returns a frame only once its clip is predicted, so it lags the input by up to a window;\n unbuffered video returns each frame at once but sees only earlier frames, and one unbuffered stream is open at\n a time by default (more need `DEPTHPRO2_KV_STREAMS`; a stream beyond it is refused with HTTP 429). The\n unbuffered frame-by-frame steps run the encoder in tt-nn operations (the encoder megakernel has no key-value\n cache path), so they are slower per frame than an image.\n- The tt-nn decoder remains selectable (`DEPTHPRO2_ENGINE=dec=ttnn`), as does each stage's tt-nn implementation.\n- The tt-nn encoder (the unbuffered steps, and `enc=ttnn`) uses tt-nn's scaled-dot-product attention, which\n returned wrong rows when its batch x heads exceeded 24 (tt-nn encoder clips of 16 frames at 480 x 640 or of 4\n frames for H+); the package runs those attentions in tt-nn's windowed mode, which is correct and gives the same\n results.\n- Batch 1; requests are served one at a time. One p150 only: the image runs device dispatch on the chip's Ethernet\n cores, so multi-chip meshes are not supported.\n- Precision: bfloat16 weights and activations on the device with float32 accumulation, residual streams,\n normalisation statistics and positional rotations, against Apple's float32 reference (Apple evaluates in\n bfloat16 on GPUs); Expected performance gives the measured agreement.\n- All four sizes' weights are downloaded whichever profile is served. The focal length comes from the image's EXIF\n data when present (35 mm-equivalent focal length), which can be wrong for cropped or digitally zoomed images:\n pass `f_px` or `use_exif: false` then.\n", "risks": null, "licensing": "- Weights (not redistributed here; `tt serve` downloads them from Apple's repositories at these commits):\n [apple/DepthPro2-focal](https://huggingface.co/apple/DepthPro2-focal) `622659d4`,\n [apple/DepthPro2-S](https://huggingface.co/apple/DepthPro2-S) `903a1c1a`,\n [apple/DepthPro2-B](https://huggingface.co/apple/DepthPro2-B) `85e67fdf`,\n [apple/DepthPro2-L](https://huggingface.co/apple/DepthPro2-L) `849dc546`,\n [apple/DepthPro2-H](https://huggingface.co/apple/DepthPro2-H) `68426c78`, under the\n [Apple Machine Learning Research Model License Agreement](https://huggingface.co/apple/DepthPro2/blob/main/LICENSE):\n **research purposes only**. Apple Machine Learning Research Model is licensed under the Apple Machine Learning\n Research Model License Agreement. A copy of the agreement and the notices are in\n [`code/tt_depthpro2/licenses/`](code/tt_depthpro2/licenses/NOTICE.md).\n- This package is a model derivative of Depth Pro 2 and is identified as such. Its modifications: the inference\n code is re-implemented (the network and the pre- and post-processing written anew; the video streaming logic\n follows the structure of Apple's `streaming.py`, see below); on the device the network runs in bfloat16 in\n tt-nn operations and custom device kernels; inputs are resized to fixed resolution buckets. The weights are\n loaded unmodified. Apple's name is used only to identify the original model; Apple does not endorse this\n package.\n- The video streaming logic (`code/tt_depthpro2/streaming.py`) follows the structure of Apple's `streaming.py`\n from [apple-aiml-research/ml-depth-pro-2](https://github.com/apple-aiml-research/ml-depth-pro-2) (Copyright (C)\n 2026 Apple Inc.), used under Apple's software licence, a copy of which is\n [`code/tt_depthpro2/licenses/APPLE_SOFTWARE_LICENSE.txt`](code/tt_depthpro2/licenses/APPLE_SOFTWARE_LICENSE.txt).\n- Port, server and scripts (`code/`, except as noted above) and the tt-metal patches in [`patches/`](patches/):\n Apache-2.0.\n- Sample `code/tt_depthpro2/samples/kropa_street/image.jpg`: \"Kropa, cobblestone side street 01\" by Ajznponar,\n [Wikimedia Commons](https://commons.wikimedia.org/wiki/File:Kropa,_cobblestone_side_street_01.jpg), CC0 1.0\n (public domain dedication), resized to 640 x 480 without its EXIF data; the `reference.*` files next to it hold\n this package's float32 CPU outputs for it.\n- Demo media: `media/demo_tt.gif` and `media/demo_tt.mp4` are rendered from \"Walking down the Trubarjeva street\"\n by Sounds of Changes ([Wikimedia Commons](https://commons.wikimedia.org/wiki/File:Walking_down_the_Trubarjeva_street.webm),\n [CC BY 3.0](https://creativecommons.org/licenses/by/3.0/)), trimmed, cropped, resized and shown with the\n model's output, and are distributed under CC BY 3.0; the author does not endorse this work.\n `media/demo_sample.png` shows the CC0 sample above with its output. Attributions:\n [`media/ATTRIBUTION.md`](media/ATTRIBUTION.md).\n", "related": "- [changh95/depth-anything-3-p150](https://huggingface.co/changh95/depth-anything-3-p150): Depth Anything 3 metric depth on p150.\n",