tt-model push depthpro2 (container)
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
Files changed (50)
- .gitattributes+9
- PYTHON.md+1
- README.md+39-35
- SERVING.md+1
- build_info.json+6-6
- code/PYTHON.md+1
- code/tt_depthpro2/__init__.py+1-1
- code/tt_depthpro2/api.py+16-4
- code/tt_depthpro2/config.py+38-4
- code/tt_depthpro2/server/app.py+2-2
- code/tt_depthpro2/server/smoke_test.py+3
- code/tt_depthpro2/tests/baseline_helpers.py+52-5
- code/tt_depthpro2/tests/mk_enc_ab.pyAdded+81
- code/tt_depthpro2/tests/mk_enc_bench.py+1-3
- code/tt_depthpro2/tests/mk_enc_e2e.py+2-3
- code/tt_depthpro2/tests/mk_enc_heldout.pyAdded+110
- code/tt_depthpro2/tests/mk_enc_ref.py+31-5
- code/tt_depthpro2/tests/mk_enc_soak.py+1-3
- code/tt_depthpro2/tests/mk_enc_sweep.py+5-6
- code/tt_depthpro2/tests/mk_fov_check.py+1-3
- code/tt_depthpro2/tests/test_device_mk_enc.py+3
- code/tt_depthpro2/tests/test_host_api.py+38
- code/tt_depthpro2/tests/test_host_config.py+18
- code/tt_depthpro2/tests/test_host_server.py+6
- code/tt_depthpro2/tt/mk_enc/geometry.py+52-9
- code/tt_depthpro2/tt/mk_enc/kernels/me_brisc.cpp+27-5
- code/tt_depthpro2/tt/mk_enc/kernels/me_defs.hpp+6-2
- code/tt_depthpro2/tt/mk_enc/kernels/me_dm.hpp+1
- code/tt_depthpro2/tt/mk_enc/kernels/me_sched.hpp+22
- code/tt_depthpro2/tt/mk_enc/kernels/me_trisc.cpp+41-4
- code/tt_depthpro2/tt/mk_enc/program.py+10-2
- image/blobs/sha256/07068e507eb85eb19e2cba161776f09d9dfc409f076a75cb025e91c7a453cc0bAdded
- image/blobs/sha256/0823fb4d68aa8cf2ae2c0570a0ec29008cc3731b4cf6824f19dec26f1752a595Added
- image/blobs/sha256/199c5c69ff79909fafc6f7ce76f18d9190a126fb2e19b7008b1ea7e420e03143Added
- image/blobs/sha256/2adcae1db077911ca2862dd02f273f1e9b4281fdf40b2883120a4f2cc0a62d1cAdded+1
- image/blobs/sha256/2c086c85a6757d115d88f96d8a61d108d1672dbd93e11378f3e926c30a087721Added
- image/blobs/sha256/33f737b5c90656461fe9bd146cb79535e86801e8ae6ff472fba02d98d642d96dAdded+28
- image/blobs/sha256/4a09a953b77760f9bc21e019efd2b7c955acbb3da411924422eb1dc152d42cb5Added+3
- image/blobs/sha256/4b312cf00d10f4cae911fa2d2f3ca94519ecc3af9e6f90613d423b7007a4b58aAdded
- image/blobs/sha256/5e8d5690a24c1c2dd08c724768ff8dfb3cde06d235dc412ea25b99c03cecb0e9Added+3
- image/blobs/sha256/62b690ec2bb305674142733157a0c3f23492989a04d9029dc5edfdcad69fb6bfAdded+3
- image/blobs/sha256/682269e8787edd600b6b6f2153622e388f1aee04425e5d9840ee1c2669b62d53Added
- image/blobs/sha256/6abcb58795a986f2819b59f5e6137beb717bbfb72085ac0cf67d65ffec4394f8Added+3
- image/blobs/sha256/7091da5027cb5b595a8e3a28218802237b707ac6788462fa784b679a64498a2cAdded+3
- image/blobs/sha256/730e5c49f8c863df41fa025f30d1f6b326c7612e58826ce4b3040e91ee6ab6e8Added+3
- image/blobs/sha256/9b59c9e70282751d0475ad191c51fa4a6ecc35df69dc3eddbbf3b48e9d0bd0ceAdded+126
- image/blobs/sha256/a25af6f70d283cd4531f41b6e80960e4f4f58169c01983ce52ce353c76a302fbAdded+3
- image/blobs/sha256/c1775688fd5d80d39eead952ffb71947d7c9372f0afab378cd209c7790aeddd9Added+3
- image/blobs/sha256/cd0c901565527f4b2fd02b95be2585a420745d065f007f7ede3e6b3cdc13c560Added+1
- image/blobs/sha256/dd4a48658276f0dc5d844c924df0ea916711b0afda94aa06db2a9463b6010cdbAdded+3
50 unmodified lines51525350 unmodified linesmedia/demo_sample.png filter=lfs diff=lfs merge=lfs -textmedia/demo_tt.gif filter=lfs diff=lfs merge=lfs -textmedia/demo_tt.mp4 filter=lfs diff=lfs merge=lfs -text50 unmodified lines51525354555657585960616250 unmodified linesmedia/demo_sample.png filter=lfs diff=lfs merge=lfs -textmedia/demo_tt.gif filter=lfs diff=lfs merge=lfs -textmedia/demo_tt.mp4 filter=lfs diff=lfs merge=lfs -textimage/blobs/sha256/4a09a953b77760f9bc21e019efd2b7c955acbb3da411924422eb1dc152d42cb5 filter=lfs diff=lfs merge=lfs -textimage/blobs/sha256/5e8d5690a24c1c2dd08c724768ff8dfb3cde06d235dc412ea25b99c03cecb0e9 filter=lfs diff=lfs merge=lfs -textimage/blobs/sha256/62b690ec2bb305674142733157a0c3f23492989a04d9029dc5edfdcad69fb6bf filter=lfs diff=lfs merge=lfs -textimage/blobs/sha256/6abcb58795a986f2819b59f5e6137beb717bbfb72085ac0cf67d65ffec4394f8 filter=lfs diff=lfs merge=lfs -textimage/blobs/sha256/7091da5027cb5b595a8e3a28218802237b707ac6788462fa784b679a64498a2c filter=lfs diff=lfs merge=lfs -textimage/blobs/sha256/730e5c49f8c863df41fa025f30d1f6b326c7612e58826ce4b3040e91ee6ab6e8 filter=lfs diff=lfs merge=lfs -textimage/blobs/sha256/a25af6f70d283cd4531f41b6e80960e4f4f58169c01983ce52ce353c76a302fb filter=lfs diff=lfs merge=lfs -textimage/blobs/sha256/c1775688fd5d80d39eead952ffb71947d7c9372f0afab378cd209c7790aeddd9 filter=lfs diff=lfs merge=lfs -textimage/blobs/sha256/dd4a48658276f0dc5d844c924df0ea916711b0afda94aa06db2a9463b6010cdb filter=lfs diff=lfs merge=lfs -text
49 unmodified lines50515253545549 unmodified lines| `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 || `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-<size>/`, `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) |49 unmodified lines5051525354555649 unmodified lines| `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-<size>/`, `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) |
3 unmodified lines45678910106 unmodified lines11711811912012112212312432 unmodified lines15715815916016116233 unmodified lines1961971981992002012022032042052061 unmodified line20820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924014 unmodified lines25525625725825926026126226326426526626726826965 unmodified lines3353363373383393403 unmodified lines- p150- tt-dit-server- tt-model-cache- tt-model-catalog- tt-model-containerlicense: otherlicense_name: apple-amlr106 unmodified lines"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},"timing_ms": {"decode": "...", "preprocess": "...", "device": "...", "fov": "...", "postprocess": "...","encode": "...", "total": "..."}}```32 unmodified lines| 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` |Every bucket adds device programs and their start-up time; any clip length up to the window runs on the window'sprogram. The unbuffered key-value caches take device memory per bucket and stream (window 16):33 unmodified lines| 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 || 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 || 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's1 unmodified linecompared 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. Thefocal-length estimator is shared by every size. [1] L's prediction for this image is nearly flat (its inversedepth 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(0.0052).Determinism: the encoder and focal-estimator megakernels gave bit-identical outputs over 10 launches and 1000trace 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 (everysize 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+, with1 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 640with 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, 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: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 requests14 unmodified linesaspect ratio far from every bucket is stretched, and a small image upscaled to a larger bucket changes thefocal-length estimate). Configure your camera's native resolution as a bucket (`DEPTHPRO2_RESOLUTIONS`) for themost faithful results.- Accuracy outside the gate images: of 16 held-out cases (four inputs at every size, scored against Apple'sfloat32 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 aninverse-depth PCC of 0.998, below the 0.999 gate, where Apple's own bfloat16 run reaches 0.9993; its depthAbsRel (0.0060) is 1.1 times Apple's bfloat16 error, within the 2x target. S's depth AbsRel on that photo is0.027, 2.05 times Apple's bfloat16 error (0.0133), just over the 2x target. Near-flat scenes (for PCC) and S'sdepth 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.- The resolution buckets and the video window are fixed when the server starts. A clip shorter than the windowruns 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;65 unmodified lines| 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 |3 unmodified lines456789106 unmodified lines11611711811912012112212332 unmodified lines15615715815916016116233 unmodified lines1961971981992002012022032042052061 unmodified line20820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124214 unmodified lines25725825926026126226326426526626726826927027127227365 unmodified lines3393403413423433443 unmodified lines- p150- tt-dit-server- tt-model-cache- tt-model-containerlicense: otherlicense_name: apple-amlr106 unmodified lines"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": 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": "..."}}```32 unmodified lines| 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'sprogram. The unbuffered key-value caches take device memory per bucket and stream (window 16):33 unmodified lines| 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.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.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's1 unmodified linecompared 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. Thefocal-length estimator is shared by every size. [1] L's prediction for this image is nearly flat (its inversedepth 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 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 4and 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 (everysize 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+, with1 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 640with 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.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 | 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 anddecoder 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 requests14 unmodified linesaspect ratio far from every bucket is stretched, and a small image upscaled to a larger bucket changes thefocal-length estimate). Configure your camera's native resolution as a bucket (`DEPTHPRO2_RESOLUTIONS`) for themost faithful results.- 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 againstApple's float32 output with the same gates), 38 of 40 pass (S 10, B 9, L 10, H+ 9). The two misses: B on asky-and-water landscape, depth AbsRel 0.013 against a budget of 0.010 (Apple's own bfloat16: 0.004), a uniform1.5 % depth scale offset; H+ on a 4-frame close-up clip, inverse-depth PCC 0.993 against 0.999, where Apple's ownbfloat16 run reaches only 0.995 (its depth AbsRel, 0.014, is lower than that run's 0.017). The closest passesare S on the 8-frame clip (AbsRel 0.024 within 0.026) and L on a bright-background beach portrait (0.025within 0.035; Apple's bfloat16 0.018). On four further inputs, used totune 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 windowruns 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;65 unmodified lines| component | built from || --- | --- || tt-metal | [`44d66500520fda9f2c7060c0f6b41ec48f7ab37e`](https://github.com/tenstorrent/tt-metal/commit/44d66500520fda9f2c7060c0f6b41ec48f7ab37e) *(dirty tree — the image includes uncommitted changes)* || `code/` digest | `a2e9acdc6e000466` (sha256, first 16 hex digits) || built | 2026-11-30T01:25:57+00:00 by tt-model 0.1.0 |
85 unmodified lines86878889909185 unmodified lines| `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_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 |85 unmodified lines8687888990919285 unmodified lines| `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 |
12345678910111213{"schema": "ttaw-build-info/1","bundle": "depthpro2","recorded_at": "2026-11-29T15:32:06Z","image": {"tag": "tt-model/depthpro2:7d4a5a78b320","digest": "sha256:7d4a5a78b320ccf9ed7016c84749884f55b0006c74138e412a411da88e96c90d","built_at": "2026-11-29T15:31:26+00:00","code_sha256": "bc0132ce79669bfc545af9782cb4e5f8fe2a8edb0d9acb2f749485c4fd0fc5c3","size_bytes": 4201980118,"layers": 23},"base_images": {12345678910111213{"schema": "ttaw-build-info/1","bundle": "depthpro2","recorded_at": "2026-11-30T01:26:24Z","image": {"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": {
49 unmodified lines50515253545549 unmodified lines| `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 || `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-<size>/`, `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) |49 unmodified lines5051525354555649 unmodified lines| `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-<size>/`, `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) |
15 unmodified lines1617181920212215 unmodified linesLearning Research Model License Agreement."""__version__ = "0.1.0"__all__ = ["DepthPro2", "DepthOutput", "VideoSession", "load_sample", "InputError", "open_device", "close_device","__version__"]15 unmodified lines1617181920212215 unmodified linesLearning Research Model License Agreement."""__version__ = "0.2.0"__all__ = ["DepthPro2", "DepthOutput", "VideoSession", "load_sample", "InputError", "open_device", "close_device","__version__"]
235 unmodified lines23623723823924024124211 unmodified lines2542552562572582592609 unmodified lines27027127227327427527640 unmodified lines317318319320321322396 unmodified lines719720721722723724725235 unmodified lines@classmethoddef 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,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,11 unmodified lines(default: both when the caches fit ``config.KV_BUDGET_BYTES``). ``kv_streams``: unbuffered streams open atonce (default 1, ``$DEPTHPRO2_KV_STREAMS``). ``fov``: loadthe 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``DEPTHPRO2_*`` variable (``config.resolve_config``); a bad value raises ``ValueError``.``weights_dir`` / ``fov_weights_dir`` (or ``$DEPTHPRO2_WEIGHTS_DIR`` / ``$DEPTHPRO2_FOV_WEIGHTS_DIR``):9 unmodified linessize = 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)self = cls.__new__(cls)self._lock = threading.RLock()self._closed = False40 unmodified linesif device is not None:self.device_info = dict(_device.describe_device(device, device_id), backend=backend)t1 = time.perf_counter()self._build_engine(sw, fw, engine_factory)del sw, fwself.warmup_ms["build"] = (time.perf_counter() - t1) * 1e3396 unmodified lines"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_modeselse None, "fov": cfg.fov, "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,235 unmodified lines23623723823924024124224311 unmodified lines2552562572582592602612622632649 unmodified lines27427527627727827928040 unmodified lines321322323324325326327328329330331332333396 unmodified lines730731732733734735736737235 unmodified lines@classmethoddef 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,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,11 unmodified lines(default: both when the caches fit ``config.KV_BUDGET_BYTES``). ``kv_streams``: unbuffered streams open atonce (default 1, ``$DEPTHPRO2_KV_STREAMS``). ``fov``: loadthe focal-length estimator (default True). ``engine``: per-stage ``mk`` / ``ttnn`` (``"enc=mk,dec=ttnn"``).``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 beforethe 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``):9 unmodified linessize = 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, enc_precision=enc_precision)self = cls.__new__(cls)self._lock = threading.RLock()self._closed = False40 unmodified linesif 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 builtopts = C.mk_enc_options(cfg.enc_precision, os.environ.get(C.MK_ENC_OPTS_ENV))if opts:os.environ[C.MK_ENC_OPTS_ENV] = optselse: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 Noneself._build_engine(sw, fw, engine_factory)del sw, fwself.warmup_ms["build"] = (time.perf_counter() - t1) * 1e3396 unmodified lines"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_modeselse 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,
19 unmodified lines20212223242513 unmodified lines3940414243444552 unmodified lines9899100101102103174 unmodified lines27827928028128228316 unmodified lines30030130230330430530630730830931031131239 unmodified lines35235335435535635735835936019 unmodified lines| 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) |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 other13 unmodified lines"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",]MODEL_NAME = "depthpro2"52 unmodified lines#: up to 2.2 GB (H+), the compiled programs' activations up to ~1.3 GB at 1080p T=16)KV_BUDGET_BYTES = 4 << 30KV_STREAMS_RANGE = (1, 8)ENGINE_STAGES = ("enc", "dec", "fov")ENGINE_KINDS = ("mk", "ttnn")174 unmodified linesfov: bool = Trueengine: Optional[Dict[str, str]] = field(default_factory=lambda: dict(DEFAULT_ENGINE))precision: Optional[str] = None@propertydef device_buckets(self) -> List[Tuple[int, int]]:16 unmodified linesenv["ENGINE"] = ",".join(f"{k}={v}" for k, v in self.engine.items())if self.precision:env["PRECISION"] = self.precisionreturn {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:"""Explicit values > ``DEPTHPRO2_*`` environment > defaults. Raises ``ValueError`` naming the setting (and theenvironment variable it came from) for anything out of range, so a bad value refuses to start."""env = os.environ if env is None else env39 unmodified linesprec = str(v).strip().lower()if prec not in PRECISIONS:raise ValueError(f"{src}={v!r}: one of {list(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)def choose_bucket(height: int, width: int, buckets: Sequence[Tuple[int, int]]) -> Tuple[Tuple[int, int], bool]:19 unmodified lines2021222324252627282913 unmodified lines434445464748495052 unmodified lines103104105106107108109110111112113114115116117174 unmodified lines29229329429529629729816 unmodified lines31531631731831932032132232332432532632732839 unmodified lines36836937037137237337437537637737837938038138238338438538638738838939039139239339419 unmodified lines| 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 other13 unmodified lines"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", "ENC_PRECISIONS", "DEFAULT_ENC_PRECISION", "MK_ENC_OPTS_ENV","MK_ENC_FAST_OPTS", "mk_enc_options",]MODEL_NAME = "depthpro2"52 unmodified lines#: up to 2.2 GB (H+), the compiled programs' activations up to ~1.3 GB at 1080p T=16)KV_BUDGET_BYTES = 4 << 30KV_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")174 unmodified linesfov: bool = Trueengine: Optional[Dict[str, str]] = field(default_factory=lambda: dict(DEFAULT_ENGINE))precision: Optional[str] = Noneenc_precision: str = DEFAULT_ENC_PRECISION@propertydef device_buckets(self) -> List[Tuple[int, int]]:16 unmodified linesenv["ENGINE"] = ",".join(f"{k}={v}" for k, v in self.engine.items())if self.precision:env["PRECISION"] = self.precisionenv["ENC_PRECISION"] = self.enc_precisionreturn {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, enc_precision: Any = None,env: Optional[Mapping[str, str]] = None) -> DepthConfig:"""Explicit values > ``DEPTHPRO2_*`` environment > defaults. Raises ``ValueError`` naming the setting (and theenvironment variable it came from) for anything out of range, so a bad value refuses to start."""env = os.environ if env is None else env39 unmodified linesprec = 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, 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`` (thevariable's present value) without its ``inx32`` / ``klo`` keys, plus :data:`MK_ENC_FAST_OPTS` for ``fast``. Setbefore 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]:
33 unmodified lines34353637383940128 unmodified lines16917017117217317417533 unmodified linesthis 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`` /``_FOV_WEIGHTS_DIR`` (local snapshots, offline); ``TT_AUXILIARY_WEIGHTS`` (tt-model: ``repo@rev,...``, the sizerepos' commits) and ``TT_MODEL_WEIGHTS_REVISION`` / ``TT_WEIGHTS_REVISION`` (the focal repo's commit), default thepinned commits; ``DEPTHPRO2_DISPATCH`` (``eth`` | ``worker``), ``_NUM_CQS``, ``_TRACE_REGION``, ``_L1_SMALL``;128 unmodified linesreturn 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,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)33 unmodified lines34353637383940128 unmodified lines16917017117217317417533 unmodified linesthis 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``, ``_ENC_PRECISION``; ``DEPTHPRO2_WEIGHTS_DIR`` /``_FOV_WEIGHTS_DIR`` (local snapshots, offline); ``TT_AUXILIARY_WEIGHTS`` (tt-model: ``repo@rev,...``, the sizerepos' commits) and ``TT_MODEL_WEIGHTS_REVISION`` / ``TT_WEIGHTS_REVISION`` (the focal repo's commit), default thepinned commits; ``DEPTHPRO2_DISPATCH`` (``eth`` | ``worker``), ``_NUM_CQS``, ``_TRACE_REGION``, ``_L1_SMALL``;128 unmodified linesreturn 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, 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)
162 unmodified lines163164165166167168162 unmodified lineseng = 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}")for key, name in (("window", "WINDOW"), ("overlap", "OVERLAP")):v = env.get(f"{ENV_PREFIX}_{name}")if v and str(cfgd.get(key)) != v.strip():162 unmodified lines163164165166167168169170171162 unmodified lineseng = 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():
1234567891011121314151617181920212223242526272829303132# SPDX-License-Identifier: Apache-2.0"""Helpers for the ttnn-baseline device tests and benchmarks (paths, goldens, metrics, device open)."""from __future__ import annotationsimport jsonimport mathimport osfrom typing import Dict, Optional, Tupleimport torchROOT = os.environ.get("TT_MODELS_ROOT", "/home/ubuntu/experiments/tt-models")WEIGHTS = os.environ.get("DEPTHPRO2_WEIGHTS", "/mnt/chang/models/apple")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"# device-open parameters the ttnn baseline needs (conv2d halo / config buffers; traces of every compiled shape)L1_SMALL_SIZE = 32768TRACE_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])def fov_dir() -> str:return os.path.join(WEIGHTS, FOV_DIR)BASELINE_REF = os.path.join(ROOT, "assets/depthpro2/baseline_ref") # tests/make_baseline_refs.py (reference outputs)12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879# SPDX-License-Identifier: Apache-2.0"""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 thedevice scripts live under it.* weights: ``$DEPTHPRO2_WEIGHTS`` (else ``$DEPTHPRO2_TEST_WEIGHTS`` / ``$DEPTHPRO2_WEIGHTS_DIR``), a parent of``DepthPro2-<S|B|L|H|focal>/``; 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 annotationsimport jsonimport mathimport osimport sysfrom pathlib import Pathfrom typing import Dict, Optional, Tupleimport torch_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 envfor p in _CODE.parents:if (p / "assets" / "depthpro2").is_dir():return str(p)return str(_CODE)ROOT = _find_root()#: a parent of DepthPro2-<size>/ and DepthPro2-focal/, or None: the Hugging Face cache at the pinned commitsWEIGHTS: 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 Cexcept ImportError: # imported as a top-level module (tests/ on sys.path)sys.path.insert(0, str(_CODE))from tt_depthpro2 import config as Cfrom huggingface_hub import snapshot_downloadrepo, 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 cacheraise 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 = 32768TRACE_REGION_SIZE = int(os.environ.get("DEPTHPRO2_TRACE_REGION", str(256 << 20)))def size_dir(size: str) -> str:return _weights_dir(size)def fov_dir() -> str:return _weights_dir("focal")BASELINE_REF = os.path.join(ROOT, "assets/depthpro2/baseline_ref") # tests/make_baseline_refs.py (reference outputs)
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081# 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 betweenthem and vs the golden taps (when the case has them). Weights / goldens: DEPTHPRO2_TEST_WEIGHTS / DEPTHPRO2_GOLDEN.
bin/devrun -t 1200 -- python -u <pkg>/tests/mk_enc_ab.py --size S --case img_vga --a inx32=0 --b inx32=1"""
from __future__ import annotations
import argparseimport osimport sysimport 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: E402from tt_depthpro2.tests import mk_enc_ref as H # noqa: E402from tt_depthpro2.tt.mk_enc import arena as A # noqa: E402from 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()23 unmodified lines2425262728293051 unmodified lines828384858687888923 unmodified linesfrom tt_depthpro2.tt.mk_enc import arena as A # noqa: E402from tt_depthpro2.tt.mk_enc.program import MkEnc, MkEncWeights # noqa: E402LOG = "/home/ubuntu/experiments/tt-models/logs/depthpro2/mk_enc/bench.jsonl"def frames(hp: int, wp: int, T: int) -> torch.Tensor:51 unmodified lines"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")del mk, patches, rawgc.collect()del wts23 unmodified lines24252627282951 unmodified lines8182838485868723 unmodified linesfrom tt_depthpro2.tt.mk_enc import arena as A # noqa: E402from tt_depthpro2.tt.mk_enc.program import MkEnc, MkEncWeights # noqa: E402def frames(hp: int, wp: int, T: int) -> torch.Tensor:51 unmodified lines"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)H.append_log("bench.jsonl", rec)del mk, patches, rawgc.collect()del wts
19 unmodified lines20212223242526272847 unmodified lines767778798081828319 unmodified linesfrom tt_depthpro2.reference import model as ref # noqa: E402from tt_depthpro2.tests import baseline_helpers as BH # noqa: E402CASES = ("img_vga", "clip4_240x320", "img_375x500_pad")LOG = "/home/ubuntu/experiments/tt-models/logs/depthpro2/mk_enc/e2e.jsonl"def main():47 unmodified lines"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")m.close()finally:ttnn.close_device(dev)19 unmodified lines20212223242526272847 unmodified lines7677787980818219 unmodified linesfrom tt_depthpro2.reference import model as ref # noqa: E402from tt_depthpro2.tests import baseline_helpers as BH # noqa: E402from tt_depthpro2.tests import mk_enc_ref as H # noqa: E402CASES = ("img_vga", "clip4_240x320", "img_375x500_pad")def main():47 unmodified lines"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)H.append_log("e2e.jsonl", rec)m.close()finally:ttnn.close_device(dev)
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110# SPDX-License-Identifier: Apache-2.0"""Held-out check of the device engines through DepthPro2Device (default enc=mk, dec=mk, fov=mk) against Apple'sfloat32 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/<case>__<size>__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-<size>/ 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 argparseimport jsonimport osimport sysimport 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: E402from 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 <case>__<size>__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()12 unmodified lines13141516171819202122232425261 unmodified line282930313233343512 unmodified linesfrom tt_depthpro2.reference import model as RROOT = "/home/ubuntu/experiments/tt-models"GOLDEN = os.path.join(ROOT, "assets/depthpro2/golden")WEIGHTS = "/mnt/chang/models/apple/DepthPro2-{}/model.safetensors"P = R.NUM_PREFIXdef load_weights(size: str) -> Dict[str, torch.Tensor]:return R.load_safetensors(WEIGHTS.format("focal" if size == "fov" else size))def load_case(case: str, size: str) -> Dict[str, torch.Tensor]:1 unmodified linefrom safetensors.torch import load_filep = os.path.join(GOLDEN, f"{case}__{size}.safetensors")if not os.path.exists(p):p = os.path.join(ROOT, "assets/depthpro2/baseline_ref", f"{case}__{size}.safetensors")return load_file(p)12 unmodified lines13141516171819202122232425262728293031323334353637383940414243444546474849501 unmodified line5253545556575859606112 unmodified linesfrom tt_depthpro2.reference import model as R_CODE = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) # code/ (the package's parent)#: parent of DepthPro2-<size>/ 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 <case>__<size>.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_PREFIXdef 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]: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-<size>/")return R.load_safetensors(p)def append_log(name: str, rec: dict) -> None:"""Append ``rec`` to ``$DEPTHPRO2_MK_ENC_LOGDIR/<name>`` (no-op when the variable is unset)."""if LOG_DIR:import jsonos.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]:1 unmodified linefrom safetensors.torch import load_filep = 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):raise FileNotFoundError(f"no golden {case}__{size}: set DEPTHPRO2_GOLDEN (or DEPTHPRO2_BASELINE_REF)")return load_file(p)
22 unmodified lines2324252627282968 unmodified lines989910010110210310410522 unmodified linesfrom tt_depthpro2.tt.mk_enc import arena as A # noqa: E402from tt_depthpro2.tt.mk_enc.program import MkEnc, MkEncWeights # noqa: E402LOG = "/home/ubuntu/experiments/tt-models/logs/depthpro2/mk_enc/soak.jsonl"def main():68 unmodified linesfinally: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")ttnn.close_device(dev)22 unmodified lines23242526272868 unmodified lines97989910010110210322 unmodified linesfrom tt_depthpro2.tt.mk_enc import arena as A # noqa: E402from tt_depthpro2.tt.mk_enc.program import MkEnc, MkEncWeights # noqa: E402def main():68 unmodified linesfinally:rec["end"] = time.strftime("%Y-%m-%d %H:%M:%S")print("REC " + json.dumps(rec), flush=True)H.append_log("soak.jsonl", rec)ttnn.close_device(dev)
25 unmodified lines262728293031323334353637383940113 unmodified lines15415515615715815916016125 unmodified linesfrom tt_depthpro2.tt.mk_enc import arena as A # noqa: E402from tt_depthpro2.tt.mk_enc.program import MkEnc, MkEncWeights # noqa: E402ROOT = "/home/ubuntu/experiments/tt-models"LOG = os.path.join(ROOT, "logs/depthpro2/mk_enc/sweep.jsonl")def baseline_ms(size, hp, wp, T):best = Nonefor f in ("bench.jsonl", "bench_r2.jsonl"):p = os.path.join(ROOT, "logs/depthpro2/baseline", f)if not os.path.exists(p):continuefor line in open(p):d = json.loads(line)113 unmodified linesfinally: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")gc.collect()ttnn.close_device(dev)25 unmodified lines262728293031323334353637383940113 unmodified lines15415515615715815916025 unmodified linesfrom tt_depthpro2.tt.mk_enc import arena as A # noqa: E402from tt_depthpro2.tt.mk_enc.program import MkEnc, MkEncWeights # noqa: E402#: 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 = Nonefor f in ("bench.jsonl", "bench_r2.jsonl"):p = os.path.join(BASELINE_BENCH, f)if not BASELINE_BENCH or not os.path.exists(p):continuefor line in open(p):d = json.loads(line)113 unmodified linesfinally:rec["time"] = time.strftime("%Y-%m-%d %H:%M:%S")print("REC " + json.dumps(rec), flush=True)H.append_log("sweep.jsonl", rec)gc.collect()ttnn.close_device(dev)
23 unmodified lines2425262728293077 unmodified lines10810911011111211311411523 unmodified linesfrom tt_depthpro2.tt.mk_enc import arena as A # noqa: E402CASES = ("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):77 unmodified linesok = 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")del em, fpif args.bench_t4:g, _ = BH.load_golden("img_vga", "S")23 unmodified lines24252627282977 unmodified lines10710810911011111211323 unmodified linesfrom tt_depthpro2.tt.mk_enc import arena as A # noqa: E402CASES = ("img_vga", "img_384x512", "clip4_240x320", "img_375x500_pad")def trace_ms(dev, fn, reps=5):77 unmodified linesok = ok and rec["passed"]rec["time"] = time.strftime("%Y-%m-%d %H:%M:%S")print(json.dumps(rec), flush=True)H.append_log("fov.jsonl", rec)del em, fpif args.bench_t4:g, _ = BH.load_golden("img_vga", "S")
18 unmodified lines19202122232418 unmodified linesfrom tt_depthpro2.tests import mk_enc_ref as Httnn = pytest.importorskip("ttnn")#: 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"))18 unmodified lines19202122232425262718 unmodified linesfrom tt_depthpro2.tests import mk_enc_ref as Httnn = 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-<size>/) 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"))
257 unmodified lines258259260261262263257 unmodified linesfov_weights_dir=str(WEIGHTS_ROOT))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:257 unmodified lines258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301257 unmodified linesfov_weights_dir=str(WEIGHTS_ROOT))class EnvRecorder(Recorder):"""Records ``DEPTHPRO2_MK_ENC_OPTS`` as the engine is built."""opts = Nonedef __init__(self, device, size, size_weights, fov_weights, buckets, max_frames, engine=None, frames=None):import osEnvRecorder.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 Amonkeypatch.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 setfor 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"] == precfinally:m.close()# the CPU backend leaves the variable alonem = 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 Nonefinally: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:
148 unmodified lines149150151148 unmodified lineswith pytest.raises(RuntimeError):load_config(_server_env(**over))148 unmodified lines149150151152153154155156157158159160161162163164165166167168169148 unmodified lineswith 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 keptassert 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")
109 unmodified lines110111112113114115174 unmodified lines290291292293294295109 unmodified linesassert "Research Model License" in info["license"]["notice"]cfg = client.get("/config").json()assert cfg["configuration"]["window"] == 2 and cfg["limits"]["max_streams"] == 1assert client.get("/v1/models").json()["data"][0]["id"] == "apple/DepthPro2-S"174 unmodified lineswith pytest.raises(RuntimeError, match="DEPTHPRO2_WINDOW"):with client_with(monkeypatch, DEPTHPRO2_WINDOW="99"):passassert server.app.state.dp2.error is None # restored by client_with109 unmodified lines110111112113114115116117118174 unmodified lines293294295296297298299300301109 unmodified linesassert "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"174 unmodified lineswith pytest.raises(RuntimeError, match="DEPTHPRO2_WINDOW"):with client_with(monkeypatch, DEPTHPRO2_WINDOW="99"):passwith 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
51 unmodified lines52535455565748 unmodified lines10610710810911011122 unmodified lines134135136137138139113 unmodified lines2532542552562572582592601 unmodified line26226326426526626726826912 unmodified lines2822832842852862872 unmodified lines2902912922932942952961 unmodified line2982993003013023033043053063073081 unmodified line31031131231331431529 unmodified lines34534634734834935035151 unmodified lines}#: default slots per row and wave (L1 budget, MK_LOG 1.3)RB_DEFAULT = {"S": 4, "B": 2, "L": 2, "H": 2}#: 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 maxGIANT = {"S": (0,), "B": (0,), "L": (1,), "H": (0, 1), "fov": (0,)}48 unmodified linesgiant_all: bool = False # two-step row max in every blockalias_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)derived: Dict = field(default_factory=dict)def __post_init__(self):22 unmodified linesself.NC = self.gx * self.gyif self.rb == 0:self.rb = RB_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))113 unmodified linesf = lambda i, n, u: (((i, "fp32", u),), n * T32) # noqa: E731return [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),f(CB_ST, (self.qb + 1) * 4, True),]) + [(((CB_INF, "bf16", False), (CB_KV, "bf16", False)), self.inf_tiles * T16),1 unmodified linef(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),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),12 unmodified linesf(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_AO, self.qb * 2),(((CB_SYNC, "raw", False),), SYNC_BYTES),b(CB_TOK, 1),2 unmodified lines@propertydef 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)@propertydef inf_cap(self) -> int:1 unmodified line@propertydef inx_bytes(self) -> int:"""CB_INX bytes: the LN gather (rb * DT bf16) or the attention state FIFO ((qb + 1) * 4 fp32 tiles), whole16 KB states"""need = max(self.rb * self.DT * T16, (self.qb + 1) * 4 * T32)return -(-need // (4 * T32)) * (4 * T32)def cb_bytes(self) -> int:return sum(n for _, n in self.cb_table())1 unmodified line"""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 = 0while self.cb_bytes() > L1_BUDGET:if self.kc > 16:self.kc //= 229 unmodified lines"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_ABI_HOST": ME_ABI, # noqa: F821 (parsed from me_defs.hpp)}return [(k, str(v)) for k, v in d.items()]51 unmodified lines52535455565758596061626348 unmodified lines11211311411511611711811912022 unmodified lines143144145146147148149150151152113 unmodified lines2662672682692702712722731 unmodified line27527627727827928028128212 unmodified lines2952962972982993003012 unmodified lines3043053063073083093103113123133143153163173183193201 unmodified line3223233243253263273283293303313323333343353363373383393403411 unmodified line34334434534634734834935035135235335435535629 unmodified lines38638738838939039139239339451 unmodified lines}#: 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 keyKLO_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 maxGIANT = {"S": (0,), "B": (0,), "L": (1,), "H": (0, 1), "fov": (0,)}48 unmodified linesgiant_all: bool = False # two-step row max in every blockalias_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 chunkderived: Dict = field(default_factory=dict)def __post_init__(self):22 unmodified linesself.NC = self.gx * self.gyif self.rb == 0:self.rb = RB_DEFAULT[self.size]if self.inx32 is None: # the FOV trunk keeps v1 numerics whatever its size keyself.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))113 unmodified linesf = lambda i, n, u: (((i, "fp32", u),), n * T32) # noqa: E731return [b(CB_W, self.ring * PAGE_TILES),] + ([(((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),1 unmodified linef(CB_X, 2 * rb * nxm, True),f(CB_SUMS, 4 * rb, False),f(CB_STO, 1, False),(((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),12 unmodified linesf(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),2 unmodified lines@propertydef 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 // self.cht) * self.cht@propertydef 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)@propertydef klo_rows(self) -> int:"""row tiles of the k-lo staging"""return self.Mt if self.klo == 2 else self.T + 1@propertydef inf_cap(self) -> int:1 unmodified line@propertydef inx_bytes(self) -> int:"""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)@propertydef fix(self) -> str:return "fp32" if self.inx32 else "bf16"@propertydef tix(self) -> int:"""bytes of one LN-gather tile (CB_INX / CB_OUTX / CB_EXT)"""return T32 if self.inx32 else T16def cb_bytes(self) -> int:return sum(n for _, n in self.cb_table())1 unmodified line"""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 = 0if self.ring_first and self.cb_bytes() > L1_BUDGET: # keep the largest K / V chunk, the ring as large as fitskc0, ring0 = self.kc, self.ringfor kc in (kc0, kc0 // 2, kc0 // 4):for ring in range(ring0, 5, -2):self.kc, self.ring = kc, ringif self.cb_bytes() <= L1_BUDGET:returnself.kc, self.ring = kc0, ring0while self.cb_bytes() > L1_BUDGET:if self.kc > 16:self.kc //= 229 unmodified lines"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 * 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()]
240 unmodified lines24124224324424524624782 unmodified lines33033133233333433533633733833934034134234334434527 unmodified lines3733743753763773783793802 unmodified lines3833843853863873883 unmodified lines3923933943953963974 unmodified lines402403404405406407408240 unmodified linescb_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_flag(W_IX + me.x, SRC_IX, gen_ix);cb_pop_front(CB_STO, 1);cb_pop_front(CB_OUTX, NXM * RB);82 unmodified linesfor (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);cb_wait_front(CB_OUT, 2 * RB);const uint32_t a = get_read_ptr(CB_OUT);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);}}noc_async_writes_flushed();cb_pop_front(CB_OUT, 2 * RB);}}27 unmodified linesuint32_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;if (me.role & R_KVR) {const uint32_t ka = ca(K_K), va = ca(K_V);for (uint32_t j = 0; j < nk; ++j) {2 unmodified linesrd16(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);}for (uint32_t y = 0; y + 1 < R; ++y) {wait_ge(W_KCRED + y, kv_count + 1);3 unmodified linesconst 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);const uint32_t srcw = sync_addr(W_KSRC);*reinterpret_cast<volatile tt_l1_ptr uint32_t*>(srcw) = kv_count + 1;noc_semaphore_set_multicast(srcw, mcast_addr(kx, y0, kx, y1, sync_addr(W_KV)), R - 1);4 unmodified lineswait_ge(W_KV, kv_count + 1);}++kv_count;cb_push_back(CB_KV, 4 * KC);}void att_reads(const Item& it) {240 unmodified lines24124224324424524624782 unmodified lines33033133233333433533633733833934034134234334434534634734834935035135235335435535635727 unmodified lines3853863873883893903913922 unmodified lines3953963973983994004014024034044053 unmodified lines4094104114124134144154164174184194 unmodified lines424425426427428429430240 unmodified linescb_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 * 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);82 unmodified linesfor (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);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);}}}27 unmodified linesuint32_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, 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) {2 unmodified linesrd16(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);3 unmodified linesconst 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<volatile tt_l1_ptr uint32_t*>(srcw) = kv_count + 1;noc_semaphore_set_multicast(srcw, mcast_addr(kx, y0, kx, y1, sync_addr(W_KV)), R - 1);4 unmodified lineswait_ge(W_KV, kv_count + 1);}++kv_count;cb_push_back(CB_KV, CHT);}void att_reads(const Item& it) {
11 unmodified lines1213141516171841 unmodified lines606162636465122 unmodified lines18818919019119219319411 unmodified lines// 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;#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");41 unmodified lines// 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_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)122 unmodified linesconstexpr uint32_t K_PROBE = 59; // fp32 [N_PROBE * 32, 32] TILE debug probesconstexpr 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 / nconstexpr uint32_t N_COMMON_ARGS = 62;// ---------------------------------------------------------------- compile-time argsconstexpr uint32_t CT_ACC0 = 0; // TensorAccessorArgs (DRAM interleaved; page size given per use)11 unmodified lines1213141516171841 unmodified lines6061626364656667122 unmodified lines19019119219319419519619719811 unmodified lines// 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 = 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");41 unmodified lines// 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)122 unmodified linesconstexpr uint32_t K_PROBE = 59; // fp32 [N_PROBE * 32, 32] TILE debug probesconstexpr 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 / nconstexpr 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 argsconstexpr uint32_t CT_ACC0 = 0; // TensorAccessorArgs (DRAM interleaved; page size given per use)
10 unmodified lines11121314151610 unmodified linesnamespace mex {constexpr uint32_t T16 = 2048, T32 = 4096;constexpr uint32_t PAGE_BYTES = PAGE_TILES * T16;FORCE_INLINE uint32_t rt(uint32_t i) { return get_arg_val<uint32_t>(i); }10 unmodified lines1112131415161710 unmodified linesnamespace 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<uint32_t>(i); }
40 unmodified lines414243444546122 unmodified lines16917017117240 unmodified linesconstexpr uint32_t PAGE_TILES = 8;constexpr uint32_t NPATCH = T * PT; // patch tilesconstexpr uint32_t RI_POOL = MT - 1;constexpr uint32_t SPECIAL_JOINT = POOL ? RI_POOL : 0; // the joint segment's prefix key tilestatic_assert(RB <= RB_MAX, "slots");static_assert(2 * RB <= 8, "QKV unit accumulators");122 unmodified linesreturn 0;}} // namespace mex40 unmodified lines414243444546474849505152122 unmodified lines17517617717817918018118218318418518618718818919019119219319440 unmodified linesconstexpr uint32_t PAGE_TILES = 8;constexpr uint32_t NPATCH = T * PT; // patch tilesconstexpr 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] tilesconstexpr 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 tilestatic_assert(RB <= RB_MAX, "slots");static_assert(2 * RB <= 8, "QKV unit accumulators");122 unmodified linesreturn 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
617 unmodified lines6186196206216226236246256266276286296306316329 unmodified lines6426436446456466476489 unmodified lines658659660661662663664665666667668669670671225 unmodified lines89789889990090190290390490590690790868 unmodified lines9779789799809819829832 unmodified lines986987988989990991992183 unmodified lines1176117711781179118011811182617 unmodified linesfrscale2(2 * s, 4);}}tile_regs_commit();cb_reserve_back(CB_OUT, 2 * RB);tile_regs_wait();pack_reconfig_data_format(CB_OUT);for (uint32_t i = 0; i < 2 * RB; ++i) {pack_tile<true>(i, CB_OUT, i);}tile_regs_release();cb_push_back(CB_OUT, 2 * RB);continue;}tile_regs_acquire();9 unmodified linestile_regs_release();cb_push_back(CB_RAW, 8);cb_wait_front(CB_RAW, 8);cb_reserve_back(CB_OUT, 2 * RB);for (uint32_t s = 0; s < RB; ++s) {if (!(act & (1u << s))) {continue;9 unmodified lines} else {frscale2(0, 4);}tile_regs_commit();tile_regs_wait();pack_reconfig_data_format(CB_OUT);pack_tile<true>(0, CB_OUT, 2 * s);pack_tile<true>(1, CB_OUT, 2 * s + 1);tile_regs_release();}cb_push_back(CB_OUT, 2 * RB);cb_pop_front(CB_RAW, 8);}ws_align();225 unmodified lines// ================================================================ attention itemconstexpr 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 < nNOINL void scores(uint32_t i, uint32_t j0, uint32_t n, const uint32_t* mk) {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);}}for (uint32_t jj = 0; jj < n; ++jj) {if (mk[j0 + jj]) {68 unmodified linesfor (uint32_t j = 0; j < nk; ++j) {mk[j] = key_mask(seg_key(it, p0 + j));}cb_wait_front(CB_KV, 4 * KC);for (uint32_t i = 0; i < it.nq; ++i) {APROF(0);// S (fp32) -> region (views S32: P / D pass, S32F: max)2 unmodified linesfor (uint32_t j0 = 0; j0 < nk; j0 += SUB) {const uint32_t n = gmin(SUB, nk - j0);tile_regs_acquire();scores(i, j0, n, mk);tile_regs_commit();tile_regs_wait();pack_reconfig_data_format(CB_S32);183 unmodified linesAPROFP(5);aprof = false;}cb_pop_front(CB_KV, 4 * KC);}// O / l -> bf16 (several chunks)for (uint32_t i = 0; nch > 1 && i < it.nq; ++i) {617 unmodified lines6186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486499 unmodified lines6596606616626636646656666676686699 unmodified lines679680681682683684685686687688689690691692693694695696697698699700701702703225 unmodified lines92993093193293393493593693793893994094194294394494568 unmodified lines10141015101610171018101910202 unmodified lines1023102410251026102710281029183 unmodified lines1213121412151216121712181219617 unmodified linesfrscale2(2 * s, 4);}}const bool lo = ty == 1 && klo_wave(l, me.kd); // k: hi (bf16-exact) in place, lo at 4 + iif (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<true>(i, CB_OUT, i);}if (lo) {for (uint32_t i = 0; i < 2 * RB; ++i) {pack_tile<true>(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();9 unmodified linestile_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;9 unmodified lines} 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<true>(0, CB_OUT, 2 * s);pack_tile<true>(1, CB_OUT, 2 * s + 1);if (lo) {pack_tile<true>(2, CB_OUTLO, 2 * s);pack_tile<true>(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();225 unmodified lines// ================================================================ attention itemconstexpr 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 < nNOINL 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^Tfor (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]) {68 unmodified linesfor (uint32_t j = 0; j < nk; ++j) {mk[j] = key_mask(seg_key(it, p0 + j));}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)2 unmodified linesfor (uint32_t j0 = 0; j0 < nk; j0 += SUB) {const uint32_t n = gmin(SUB, nk - j0);tile_regs_acquire();scores(i, j0, n, mk, c == 0);tile_regs_commit();tile_regs_wait();pack_reconfig_data_format(CB_S32);183 unmodified linesAPROFP(5);aprof = false;}cb_pop_front(CB_KV, CHT);}// O / l -> bf16 (several chunks)for (uint32_t i = 0; nch > 1 && i < it.nq; ++i) {
51 unmodified lines525354555657587 unmodified lines66676869707190 unmodified lines16216316416516616714 unmodified lines18218318418518618718837 unmodified lines22622722822923023151 unmodified linesdef 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 / ...)."""out: Dict = {}for kv in os.environ.get("DEPTHPRO2_MK_ENC_OPTS", "").split(","):if "=" not in kv:7 unmodified linesout["fc1p_ok"] = bool(int(v))elif k == "fid":out["fidelity"] = velse:raise ValueError(f"DEPTHPRO2_MK_ENC_OPTS: unknown key {k!r}")return out90 unmodified linesmt32 = geo.Mt * 32self.xd = z(mt32, ttnn.float32)self.q, self.k, self.v, self.o = (z(mt32, ttnn.bfloat16) for _ in range(4))tap_rows = T * (geo.Np + 32) if mode == "fov" else T * geo.Npself.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)14 unmodified linesdef 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]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 >= n37 unmodified linesc[G.K_PROBE] = self.prb.buffer_address()c[G.K_PROF] = self.prof.buffer_address()c[G.K_VF] = self.vf.buffer_address()return cdef program(self, patches, nl: Optional[int] = None, dump: bool = False):51 unmodified lines525354555657587 unmodified lines66676869707172737475767790 unmodified lines16816917017117217317414 unmodified lines18919019119219319419537 unmodified lines23323423523623723823951 unmodified linesdef 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 / ...), ``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:7 unmodified linesout["fc1p_ok"] = bool(int(v))elif k == "fid":out["fidelity"] = velif 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 out90 unmodified linesmt32 = geo.Mt * 32self.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 tiletap_rows = T * (geo.Np + 32) if mode == "fov" else T * geo.Npself.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)14 unmodified linesdef 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.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 >= n37 unmodified linesc[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 cdef program(self, patches, nl: Optional[int] = None, dump: bool = False):
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"]}}12345678910111213141516171819202122232425262728{ "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" } } ]}123version https://git-lfs.github.com/spec/v1oid sha256:4a09a953b77760f9bc21e019efd2b7c955acbb3da411924422eb1dc152d42cb5size 63873701123version https://git-lfs.github.com/spec/v1oid sha256:5e8d5690a24c1c2dd08c724768ff8dfb3cde06d235dc412ea25b99c03cecb0e9size 41059882123version https://git-lfs.github.com/spec/v1oid sha256:62b690ec2bb305674142733157a0c3f23492989a04d9029dc5edfdcad69fb6bfsize 808527123version https://git-lfs.github.com/spec/v1oid sha256:6abcb58795a986f2819b59f5e6137beb717bbfb72085ac0cf67d65ffec4394f8size 139083839123version https://git-lfs.github.com/spec/v1oid sha256:7091da5027cb5b595a8e3a28218802237b707ac6788462fa784b679a64498a2csize 1950863123version https://git-lfs.github.com/spec/v1oid sha256:730e5c49f8c863df41fa025f30d1f6b326c7612e58826ce4b3040e91ee6ab6e8size 281700134123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126{ "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 } ]}123version https://git-lfs.github.com/spec/v1oid sha256:a25af6f70d283cd4531f41b6e80960e4f4f58169c01983ce52ce353c76a302fbsize 41059784123version https://git-lfs.github.com/spec/v1oid sha256:c1775688fd5d80d39eead952ffb71947d7c9372f0afab378cd209c7790aeddd9size 2679151{"_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}}}}}123version https://git-lfs.github.com/spec/v1oid sha256:dd4a48658276f0dc5d844c924df0ea916711b0afda94aa06db2a9463b6010cdbsize 13068082.gitattributes+9
PYTHON.md+1
README.md+39-35
SERVING.md+1
build_info.json+6-6
code/PYTHON.md+1
code/tt_depthpro2/__init__.py+1-1
code/tt_depthpro2/api.py+16-4
code/tt_depthpro2/config.py+38-4
code/tt_depthpro2/server/app.py+2-2
code/tt_depthpro2/server/smoke_test.py+3
code/tt_depthpro2/tests/baseline_helpers.py+52-5
code/tt_depthpro2/tests/mk_enc_ab.pyAdded+81
code/tt_depthpro2/tests/mk_enc_bench.py+1-3
code/tt_depthpro2/tests/mk_enc_e2e.py+2-3
code/tt_depthpro2/tests/mk_enc_heldout.pyAdded+110
code/tt_depthpro2/tests/mk_enc_ref.py+31-5
code/tt_depthpro2/tests/mk_enc_soak.py+1-3
code/tt_depthpro2/tests/mk_enc_sweep.py+5-6
code/tt_depthpro2/tests/mk_fov_check.py+1-3
code/tt_depthpro2/tests/test_device_mk_enc.py+3
code/tt_depthpro2/tests/test_host_api.py+38
code/tt_depthpro2/tests/test_host_config.py+18
code/tt_depthpro2/tests/test_host_server.py+6
code/tt_depthpro2/tt/mk_enc/geometry.py+52-9
code/tt_depthpro2/tt/mk_enc/kernels/me_brisc.cpp+27-5
code/tt_depthpro2/tt/mk_enc/kernels/me_defs.hpp+6-2
code/tt_depthpro2/tt/mk_enc/kernels/me_dm.hpp+1
code/tt_depthpro2/tt/mk_enc/kernels/me_sched.hpp+22
code/tt_depthpro2/tt/mk_enc/kernels/me_trisc.cpp+41-4
code/tt_depthpro2/tt/mk_enc/program.py+10-2
image/blobs/sha256/07068e507eb85eb19e2cba161776f09d9dfc409f076a75cb025e91c7a453cc0bAdded
image/blobs/sha256/0823fb4d68aa8cf2ae2c0570a0ec29008cc3731b4cf6824f19dec26f1752a595Added
image/blobs/sha256/199c5c69ff79909fafc6f7ce76f18d9190a126fb2e19b7008b1ea7e420e03143Added
image/blobs/sha256/2adcae1db077911ca2862dd02f273f1e9b4281fdf40b2883120a4f2cc0a62d1cAdded+1
image/blobs/sha256/2c086c85a6757d115d88f96d8a61d108d1672dbd93e11378f3e926c30a087721Added
image/blobs/sha256/33f737b5c90656461fe9bd146cb79535e86801e8ae6ff472fba02d98d642d96dAdded+28
image/blobs/sha256/4a09a953b77760f9bc21e019efd2b7c955acbb3da411924422eb1dc152d42cb5Added+3
image/blobs/sha256/4b312cf00d10f4cae911fa2d2f3ca94519ecc3af9e6f90613d423b7007a4b58aAdded
image/blobs/sha256/5e8d5690a24c1c2dd08c724768ff8dfb3cde06d235dc412ea25b99c03cecb0e9Added+3
image/blobs/sha256/62b690ec2bb305674142733157a0c3f23492989a04d9029dc5edfdcad69fb6bfAdded+3
image/blobs/sha256/682269e8787edd600b6b6f2153622e388f1aee04425e5d9840ee1c2669b62d53Added
image/blobs/sha256/6abcb58795a986f2819b59f5e6137beb717bbfb72085ac0cf67d65ffec4394f8Added+3
image/blobs/sha256/7091da5027cb5b595a8e3a28218802237b707ac6788462fa784b679a64498a2cAdded+3
image/blobs/sha256/730e5c49f8c863df41fa025f30d1f6b326c7612e58826ce4b3040e91ee6ab6e8Added+3
image/blobs/sha256/9b59c9e70282751d0475ad191c51fa4a6ecc35df69dc3eddbbf3b48e9d0bd0ceAdded+126
image/blobs/sha256/a25af6f70d283cd4531f41b6e80960e4f4f58169c01983ce52ce353c76a302fbAdded+3
image/blobs/sha256/c1775688fd5d80d39eead952ffb71947d7c9372f0afab378cd209c7790aeddd9Added+3
image/blobs/sha256/cd0c901565527f4b2fd02b95be2585a420745d065f007f7ede3e6b3cdc13c560Added+1
image/blobs/sha256/dd4a48658276f0dc5d844c924df0ea916711b0afda94aa06db2a9463b6010cdbAdded+3