Remove internal optimization/verification docs (not part of the card)
Browse filesFiles changed (4)
- OPT_BASELINE.mdDeleted-574
- OPT_REPORT.mdDeleted-647
- VERIFICATION_2026-10-08.mdDeleted-193
- VERIFICATION_OPT_2026-10-14.mdDeleted-98
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574# bevdet-p150 baseline on the p150 (before optimization)
> **Second release:** the optimized port is measured in the section ["After optimization"](#after-optimization-2026-10-14-the-second-release) at the end of this file (device frame 34.15 -> 9.99 ms, `model()` 173-342 -> 30-42 ms p50).
Date 2026-10-08. Code is the baseline commit `ad4de55`: the functional port `95a5d78` with ttaw 0.15.0 re-vendored and nooptimization. The bench and profile scripts used here (`code/scripts/bench.py`, `profile_ops.py`, `profile_summary.py`)were added on top of it without touching model code, and are committed together with this file.
- **Stack.** tt-metal `44d66500520` + `patches/tt-metal-eth-dispatch.patch` (sha256 `08d0ddf6…`, identical to the bundle's copy; the `single_chip_arch_1cq_no_dispatch_s` marker is present). ttaw 0.15.0 @ `105ff70` (`vendor.py --check`: 0 differences at the time). - Since then other ports moved `common/ttaw` to 0.18.1 (`6595b59`, 04:23 UTC). - The only change on BEVDet's path is C27's `identity_like` (0.17.2). It returns its input unchanged whenever the shapes agree, and they agree at every BEVDet residual: the stride-2 / projection blocks take the `downsample` branch. The `pack_outputs` fixes do not apply, since BEVDet reads TILE outputs directly (B16). - Re-vendor and re-run the gates before packaging (`check_bundle.py --stage publish` refuses drift). Done in the release step: ttaw 0.19.0 @ `a7fb8e7`, then 0.20.0 @ `89dec49` (they add `models/pillars.py` and `ops/segment.py`, unused here), gates and bench re-run in VERIFICATION_2026-10-08.md.- **Weights.** `AutowareFoundation/tensorrt_bevdet` @ `391466349a1` (tag `v1.0`). They run under the precision policy of PLAN §9.3: fp32 weights and biases, HiFi4, fp32 accumulation, packer L1 accumulation and bf16 activations (`BEVDET_PRECISION=HiFi4+fp32+l1acc:w=fp32`). Batch 1, six cameras.- **Configuration of every number** unless marked otherwise: - ETH dispatch, 1 CQ, 12×10 grid. Each log prints `"grid": "12x10"`, read with `device.compute_with_storage_grid_size()`, plus `"eth_patch": true` and `"fallback": null`. - Card p150b, FW bundle 19.13.1.0. - AICLK was sampled from sysfs `tt_aiclk` every 50 ms during every timed loop: median 1350 MHz, minimum 1343 MHz. Board power was 63–175 W.- **Host.** An AMD EPYC-Rome VM with 8 vCPUs, shared with up to 8 other agents: the load average was 5.7–9.1 during the timed loops. No cpufreq governor is exposed. `OMP_NUM_THREADS=4`.
Inputs. Each is a 3-frame sequence cycled through one stream after 6 warm frames. The images are decoded before timing,since Autoware hands the node decoded images.
| input | frames | images | stream semantics | redistribution ||---|---|---|---|---|| **synthetic** | `tt/warmup.synthetic_images` seeds 1–3, calibration preset `pandaset_019` | 6 × 1600×900 (the node's native size: no resize) | Autoware (identity ego pose: the AlignBEV grid never changes) | generated by us. Since the release (2026-10-08) `bench.py`'s `synthetic` defaults to the shipped sample's preset `synthetic_6cam`; `synthetic=pandaset_019` reproduces this row (the release re-check, VERIFICATION_2026-10-08.md) || **PandaSet 019 f38–40** | `samples/pandaset_019_f{38,39,40}.json` | 6 × 1920×1080 (the node's `cv::resize` runs on the host) | Autoware | CC BY 4.0 + PandaSet terms; in the git-ignored `staging_samples_pandaset/samples/` since the release (not shipped until the user approves) || **nuScenes mini_val scene-0103 kf00–02** | `research/bevdet/public_data/nuscenes/manifests/port2hz__scene-0103.json` | 6 × 1600×900 | ego poses (`stream.T_world_from_ego`): a new 1 MB AlignBEV grid every frame | CC BY-NC-SA 4.0: local measurement only, never shipped |
Device times do not depend on the input: the shapes are fixed and the traces are the same. The one exception is decode's`grid_sample`, which takes 0.3 ms more with ego motion.
## How to run
```bashROOT=/home/ubuntu/experiments/tt-models; cd $ROOT/bundles/bevdet-p150; source $ROOT/bin/tt-env.shexport PYTHONPATH=$PWD/code:$ROOT/tt-metal:$ROOT/tools/dev-overlay OMP_NUM_THREADS=4 HF_HUB_OFFLINE=1 HF_HUB_DISABLE_IMPLICIT_TOKEN=1L=$ROOT/logs/bevdet/baseline# accuracy gates (per-module PCC, end-to-end agreement, streams), frozen thresholds$ROOT/bin/devrun -t 1800 -- env TTAW_GATES_READONLY=1 python -m pytest -q -s -p no:cacheprovider \ code/tt_bevdet/tests/test_pcc_device.py code/tt_bevdet/tests/test_e2e_device.py code/tt_bevdet/tests/test_streams_device.py# stage bench of the shipped configuration (+ device-only replays, AICLK, PandaSet agreement check)$ROOT/bin/devrun -t 1800 -- python code/scripts/bench.py --iters 100 --inputs synthetic,pandaset,nuscenes --json $L/bench_eth-1cq.json# dispatch / CQ matrix: one process per configuration (eth 2 / worker 2 / worker 1, then eth 1 again for drift)$ROOT/bin/devrun -t 1800 -- python code/scripts/bench.py --iters 100 --inputs synthetic,nuscenes --dispatch worker --num-cqs 2 --json $L/bench_worker-2cq.json# device profile: two signposted rounds of the 4 traces + one eager run with module-stage signposts$ROOT/bin/devrun -t 3600 -- python -m tracy -r -p -v --no-web-server --op-support-count 4000 \ -o $ROOT/generated/profiler/bevdet_baseline code/scripts/profile_ops.py --rounds 2 --eager --json $L/profile_meta.jsonpython code/scripts/profile_summary.py $ROOT/generated/profiler/bevdet_baseline --json $L/profile_summary.json --md $L/profile_summary.mdtt-perf-report $ROOT/generated/profiler/bevdet_baseline/reports/2026_10_08_04_05_34/ops_perf_results_2026_10_08_04_05_34.csv \ --start-signpost encode --end-signpost encode_end --arch p150b # also decode, push, fill# ttnn-visualizer memory + graph report of one eager encode + decode (logging mode: slow, never used for timing)$ROOT/bin/devrun -t 3600 -- python code/scripts/profile_ops.py --graph-report $ROOT/generated/ttnn_reports/bevdet_baselinettnn-visualizer --profiler-path $ROOT/generated/ttnn_reports/bevdet_baseline \ --performance-path $ROOT/generated/profiler/bevdet_baseline/reports/2026_10_08_04_05_34```
Tool notes:- `tt-perf-report` 1.4.0 rejects `--arch blackhole/p150` and accepts `p150b`.- Tracy's `--no-web-server` keeps the post-capture WASM server from outliving the job.- `--op-support-count 4000` sizes the profiler's DRAM buffer above one round. In addition, `ReadDeviceProfiler` runs after every segment, and two rounds gave identical op lists.
## Accuracy (baseline)
Re-run after the ttaw 0.11.0 → 0.15.0 re-vendor (`logs/bevdet/baseline/device_suite_revendor.log`): **19 passed** in83 s, with the gates read-only and the gate files byte-identical. Every per-tap report is byte-identical to the port's,except its `timing_ms` (`reports_revendor/`). The host suite on the fake ttnn: 81 passed, 19 skipped.
| check (`tests/test_pcc_device.py`, `test_e2e_device.py`, `test_streams_device.py`) | gate | baseline ||---|---|---|| `depth` PCC, PandaSet f38 (fresh stream) / f40 (ego motion) | ≥ 0.999 | 0.999935 / 0.999941 || `feat` PCC | ≥ 0.999 | 0.999940 / 0.999943 || `bev.curr` PCC (device depth/feat → host BEVPool) | ≥ 0.999 | 0.999956 / 0.999953 || `bev.in` PCC (AlignBEV + GatherBEV, teacher-forced) | ≥ 0.999 | 0.999999 / 0.999995 || `aligned.moving` PCC (slots with ego motion) | ≥ 0.9999 | 0.999995 || chained head maps, min of 6 (reg, height, dim, rot, vel, heatmap) | ≥ 0.998 | 0.999517 (vel, f38) / 0.999873 (reg, f40) || replay == eager, ring `push` / `fill`, AlignBEV identity / outside slots | bit-exact | bit-exact || sample0 boxes at score ≥ 0.2 (nuScenes key-frame, reset frame) | ≥ 50 / 52 | 51 / 52 || PandaSet f38 / f39 / f40: recall / precision / max \|Δscore\| | ≥ 0.95 / ≥ 0.95 / ≤ 0.05 | 1.000 / 1.000 / 0.0059; 0.9958 / 0.9956 / 0.0080; 0.9953 / 0.9859 / 0.0079 || nuScenes mini_val `port2hz` scene-0103 / scene-0916: recall / precision / p99 \|Δscore\| | ≥ 0.95 / ≥ 0.95 / ≤ 0.05 | 0.9897 / 0.9899 / 0.0083; 0.9897 / 0.9902 / 0.0089 || interleaved streams == the same streams alone (D16 banks) | bit-identical | bit-identical || CPU reference vs ONNX Runtime on the deployed sub-graphs (PORT_LOG 3.1; reference code unchanged) | ≥ 0.9999 | 1.0000000000 (61 PCCs) |
Every bench process in the dispatch matrix also re-checked PandaSet f38–40 against the stored CPU boxes(`bench_*.json`, `agreement_pandaset_f38_40`). ETH and WORKER, with 1 and 2 CQs, all gave the same counts as the gate run.
## Performance (warm, batch 1, p50 (p99) of 100 iterations)
`code/scripts/bench.py`, ETH-1CQ (`logs/bevdet/baseline/bench_eth-1cq.json`).- The **stage rows** come from the instrumented loop, which synchronizes the device after every stage by wrapping the model's host hooks and the `TraceRunner` I/O.- The **e2e row** comes from a separate loop of plain `model(...)` calls.- The **bevpool row** is the API's own `timing_ms.bevpool` from the plain loop.
| stage | synthetic | PandaSet | nuScenes ||---|---:|---:|---:|| host preprocess (`_prepare`: node transport / resize, Preprocess gather, fp32 normalise, NHWC rows, calibration cache, temporal plan) | 43.0 (59.5) | 209.4 (252.7) | 34.6 (47.1) || host → ttnn host tensor (`img` bf16 rows) | 4.7 (12.5) | 3.7 (28.1) | 4.3 (33.1) || **H2D `img`** (6.5 MB bf16 ROW_MAJOR, 6-byte pages) | **32.8 (61.6)** | **27.2 (43.0)** | **27.1 (44.0)** || **trace `encode`**, one blocking replay | **24.29 (27.98)** | **24.28 (26.38)** | **24.27 (24.69)** || D2H depth \| feat (1.9 MB bf16 TILE) | 0.39 (1.93) | 0.36 (0.87) | 0.34 (0.75) || TILE → numpy on the host (untilize, bf16 → fp32) | 4.9 (16.5) | 4.5 (27.2) | 3.6 (11.9) || host BEVPool + pad + AlignBEV grid + plan (`timing_ms.bevpool`) | 30.0 (50.3) | 15.3 (38.0) | 35.8 (60.0) || host → ttnn host tensors (`curr`; `grid` when it changed) | 4.0 (12.9) | 2.7 (12.4) | 3.4 (15.1) || H2D `curr` 3.1 MB (+ `grid` 1 MB with ego poses) | 0.65 (4.51) | 0.57 (4.28) | 3.84 (11.56) || **trace `decode`**, one blocking replay | **8.73 (12.84)** | **8.72 (11.87)** | **9.01 (9.96)** || D2H head maps (16384 × 20 fp32 TILE) | 0.37 (2.57) | 0.36 (1.76) | 0.35 (0.70) || TILE → numpy | 0.90 (3.00) | 0.89 (1.91) | 0.73 (2.03) || **trace `push`** (ring update) | **1.30 (4.99)** | **1.30 (2.66)** | **1.30 (3.38)** || host postprocess (decode, top-500, scale-NMS, node filter) | 9.7 (17.3) | 49.5 (64.7) | 52.2 (70.3) || sum of the instrumented call | 174.6 (228.7) | 367.0 (447.9) | 198.2 (255.0) || **e2e `model()`** (no extra synchronization) | **173.3 (217.5)**, min 124.1 | **341.9 (370.5)**, min 326.3 | **220.3 (262.5)**, min 174.8 || detections per frame (score ≥ 0.2) | 6–7 | 258–279 | 168–196 |
Device only: replays with no host work in between (`device_only` in the JSON). The AlignBEV grid is the identity of a fullhistory, then the nuScenes frame's moving grid.
| | `encode` | `decode` (identity grid) | `decode` (ego-motion grid) | `push` | `fill` | **frame** = encode + decode + push ||---|---:|---:|---:|---:|---:|---:|| one blocking replay, p50 | 24.30 | 8.73 | 9.03 | 1.29 | 0.93 | || back-to-back, per replay | 24.24 | 8.68 | 8.98 | 1.26 | 0.90 | **34.15** (identity) / **34.45** (ego motion) |
- **Throughput.** Device-bound throughput is **29.3 frames/s** in Autoware mode and 29.0 frames/s with ego poses. A single stream reaches 5.8 frames/s end to end (synthetic, p50), 4.5 (nuScenes) and 2.9 (PandaSet, which pays for the 1920×1080 resize path).- **Device share of e2e.** The device traces are 34.3 ms of the 174.6 ms instrumented synthetic call, i.e. 20 %. The e2e time is bound by host work and the image upload, not by the device.- **Stability.** - The device numbers are identical across the three ETH-1CQ processes to ±0.01 ms: a 5-iteration smoke (`bench_smoke.json`), the main run, and the repeat at the end of the matrix. - Host stages move with the shared host's load. The e2e p50 of the synthetic input was 147.9 ms (smoke, load average ≈ 4), 173.3 ms (main run, 7–8) and 155.2 ms (repeat, 5.7–7.7). - The host BEVPool (torch sparse matmul, 4 threads) is the most load-sensitive stage: p50 11–36 ms, min 9.8–12.3 ms.- **Load.** - `from_pretrained` takes 15.2–16.9 s with a warm JIT cache: weights 0.29 s, build 1.0 s, then 9.3–10.0 s for warm-up, capture and the synthetic warm frame. The captures themselves take 73 ms (encode) and 27 ms (decode). - The program cache holds 214 entries. - Both WORKER processes took 165–174 s to load, because the 11×10 programs were compiled anew each time.
### Dispatch / CQ matrix (D14)
One process per configuration, run consecutively in one devrun job (`matrix.rcs`). All values in ms. The e2e values arethe plain loop's p50 / p99.
| config | grid | replay encode | replay decode | b2b encode | b2b decode | b2b push | **b2b frame** | b2b decode / frame (ego motion) | e2e synthetic | e2e nuScenes | PandaSet min recall / precision ||---|---|---:|---:|---:|---:|---:|---:|---:|---:|---:|---|| **ETH-1CQ** (shipped) | 12×10 | 24.30 | 8.73 | 24.24 | 8.68 | 1.26 | **34.15** | 8.98 / 34.45 | 173.3 / 217.5 | 220.3 / 262.5 | 0.9953 / 0.9859 || ETH-2CQ | 12×10 | 24.61 | 9.00 | 24.51 | 8.91 | 1.26 | 34.64 | 9.21 / 34.94 | 137.1 / 232.5 | 211.7 / 266.8 | 0.9953 / 0.9859 || WORKER-2CQ | 11×10 | 25.36 | 8.43 | 25.25 | 8.34 | 1.27 | 34.84 | 8.77 / 35.28 | 155.3 / 232.1 | 205.7 / 285.1 | 0.9953 / 0.9859 || WORKER-1CQ | 11×10 | 25.29 | 8.38 | 25.24 | 8.33 | 1.26 | 34.83 | 8.76 / 35.27 | 148.2 / 222.5 | 177.2 / 249.5 | 0.9953 / 0.9859 || ETH-1CQ repeat | 12×10 | 24.31 | 8.72 | 24.24 | 8.68 | 1.26 | 34.15 | 8.97 / 34.45 | 155.2 / 211.0 | 221.3 / 295.8 | 0.9953 / 0.9859 |
- **ETH-1CQ is the fastest configuration on the device.** - ETH-2CQ is 0.49 ms per frame slower: +0.26 ms in encode and +0.23 ms in decode per replay. In 2-CQ mode the runner records an event after every replay and uploads on CQ1. This configuration was not profiled, so the cost is not attributed further. - WORKER is 0.69 ms per frame slower. Encode loses 1.0 ms on 110 cores. Decode gains 0.34 ms: its convs on the 64²–16² maps use 50–90 cores under either dispatch, and WORKER dispatches a program faster (5.19 vs 5.72 µs, PR:P1).- **The e2e differences are inside the host noise.** The same build gave e2e p50 of 137–173 ms (synthetic) and 177–221 ms (nuScenes) in consecutive processes. For a single synchronous request, 2 CQs do not overlap anything: every upload still waits for the previous replay.- **Decision (D14): ETH dispatch, 1 CQ.** These are the existing `serve.env` pins (`BEVDET_DISPATCH=eth`, `BEVDET_NUM_CQS=1`). The 2-CQ path stays selectable and gate-tested (VERIFY_PORT #5). WORKER would win only if the model became dispatch-bound, and it is not: the op-to-op gaps are 0.27 ms of a 34 ms frame (see the profile below).
## Host vs device, and every host<->device transfer per forward
| dir | tensor | bytes | pages | when | measured (p50) ||---|---|---:|---|---|---|| H2D | `img` [1, 1, 1081344, 3] bf16 ROW_MAJOR (host-normalised NHWC rows of the 6 crops) | 6,488,064 | 1,081,344 × 6 B | every frame | **27.1 ms** (min 27.06) || H2D | `g_ctx`, `g_depth` [6, 1, 1, 512] bf16 TILE (camera gates) | 2 × 196,608 | tiles | new calibration only | not in the loop || H2D | `curr` [1, 128, 128, 96] bf16 ROW_MAJOR (host BEVPool output + 16 zero channels) | 3,145,728 | 16,384 × 192 B | every frame | 0.57 ms || H2D | `grid` [8, 128, 128, 2] fp32 ROW_MAJOR (AlignBEV) | 1,048,576 | 131,072 × 8 B | only when it changes: every frame with ego poses, never in Autoware mode | ≈ 3.3 ms (3.84 − 0.57) || D2H | `encode` output [1, 1, 4224, 224] bf16 TILE (depth 128 \| feat 96) | 1,892,352 | tiles | every frame | 0.34–0.39 ms + 1.0 ms host untilize (min) || D2H | `decode` output [1, 1, 16384, 20] fp32 TILE (32 columns physically) | 2,097,152 | tiles | every frame | 0.35–0.37 ms + 0.7–0.9 ms |
- **Uploads are bound by the page count, not the bytes.** - The `img` upload runs at 240 MB/s, about 25 ns per 6-byte page. The `grid` upload shows the same ≈ 25 ns per page. - The 192-byte-page `curr` upload runs at 5.5 GB/s. - So the `img` H2D costs as much as the whole `encode` trace.- **The mid-graph host round trip** is the one PLAN 2.10 documents: D2H depth | feat → host BEVPool → H2D `curr` → decode. Each steady frame makes 3 replays (encode, decode, push).- **Host work.** Every host stage below is documented in PLAN 2.10 / SPEC 8: - node transport, Preprocess gather and fp32 normalisation; - the camera gates and BEVPool tables per calibration (tables 75–153 ms, cached per calibration); - the BEVPool and the AlignBEV grid per frame; - per-cell decode, top-500, scale-NMS and the node filter.- **Host-stage composition**, CPU only and indicative (shared host; `host_stage_profile.json`, `resize_path_micro.log`): - 1920×1080 camera: the numpy channel flip `ascontiguousarray(img[:, :, ::-1])` costs 16–45 ms and the plane transpose 4–15 ms. The OpenCV resize itself costs only 1.3–4.5 ms, and `cv2.cvtColor` does the flip in 0.18 ms. - 1600×900 camera: the LUT gather costs 3.3–3.6 ms. - Per frame: normalisation 5.0–10.3 ms and NHWC rows 8.5–10.5 ms. - Host BEVPool 11.7–23 ms per frame. The operator is built once per calibration (35 ms). - Vendor-IoU scale-NMS over 500 candidates: 66–118 ms (golden f38 heads, heavy load); `decode_heads` 1.0 ms.
## Grid usage
Share of traced kernel time by the core count of the op (`profile_summary.json` + CSV):
| segment | 120 cores | 110–119 | 80–109 | 33–79 | ≤ 32 ||---|---:|---:|---:|---:|---:|| encode (24.1 ms) | 52 % (114 ops) | 18 % (37) | 26 % (130) | 5 % (28) | 0.3 % (5) || decode (8.6 ms) | 55 % (28) | 10 % (8) | 32 % (78) | 4 % (24) | 0.3 % (2) || push / fill | 100 % | | | | |
- **Encode, 16×44 / 8×22 tail.** The block-sharded 3×3 convs run on 72–108 cores and the DRAM-interleaved 1×1 matmuls on 66–110 (e.g. layer3's 4224×1024×256 matmuls on 66 cores). The GAP-branch linears (b = 6, M = 32) run on 3 and 16 cores, 55 µs.- **Decode.** The CustomResNet / FPN_LSS convs run on 50–90 cores block-sharded. The first convs on 864 channels use 90 cores and the 64×64×160 convs 50. The 128² neck and head convs use 108–120. `grid_sample`, concat, permute and the ring copies use all 120 cores.- **No hard-coded grid** (VERIFY_PORT 2(b)). ttaw's conv builders let ttnn choose the shard grids from `compute_with_storage_grid_size()`. The same code runs on 11×10 under WORKER dispatch, with the same accuracy (matrix).
## What is already fused / traced
- **The whole device graph is in 4 traces captured at load:** `encode` 314 programs, `decode` 140, `push` 3, `fill` 2. - A steady frame is 3 replays and 457 programs. A first or reset frame runs `fill` instead of `push` (456). - Traced op-to-op gaps total 0.27 ms per frame (0.58 µs per program), against 75 µs per op in the eager run of the same ops. Dispatch is not the bottleneck.- **Folded at export:** BatchNorm into the conv weights.- **Fused epilogues:** - ReLU in the epilogue of every conv that runs as `Conv2dDeviceOperation` (7×7, 3×3, the strided ones); - residual add + ReLU as one `ttnn.add(..., activations=[RELU])`; - the ASPP output add + ReLU with the per-camera GAP bias.- **Exact rewrites from the port (B6/B7):** - the camera MLP/SE branch folded into two per-calibration gate vectors, which removes 4 Gemm, 4 1×1 convs, 2 sigmoids and the BN1d per frame; - ASPP's dilation-18 branch as a 1×3 conv; - the GAP branch as a per-camera bias; - the depth softmax padded to 128 with a −1e4 bias (one softmax); - the merged CenterHead (12 convs → 2).- **Temporal block:** - AlignBEV for all 8 slots is one `grid_sample` with an fp32 grid; - the FPN_LSS align-corners resizes are `grid_sample`s with static grids; - GatherBEV's flag and the ring's init are variant selection (B10); - the outputs are read as TILE tensors, with no pack ops.- **Not fused or not resident:** - every activation goes back to DRAM-interleaved TILE after every op; - every 3×3 or stride-2 conv of the image encoder, on maps 176 … 22 wide, re-tiles its input to 4-D and back (ReshapeView, below). So do the 16×16 BEV stage's convs; - 18 ReLUs run as separate unary ops: after the 16 bottleneck conv1 1×1 convs and the ASPP's 1×1 / GAP linear, which run as matmuls; - the residual adds read and write DRAM; - an interleaved→sharded / sharded→interleaved pair surrounds most convs (50 pairs per frame). The DRAM-sliced convs use PaddedSlice / SliceWrite instead. - There are no custom kernels and no megakernel.
## Device profile (traced replay; kernel sum vs span, op-to-op gaps)
`ops_perf_results_2026_10_08_04_05_34.csv`, summarized by `code/scripts/profile_summary.py` (`profile_summary.{json,md}`)and `tt-perf-report --arch p150b` (`perf_report/*`). Round 2 matches round 1 within ±0.1 %: encode 24,153.6 µs, decode8,641.9 µs.
| segment | programs | kernel sum µs | op-to-op µs | span µs ||---|---:|---:|---:|---:|| `encode` | 314 | 24,147.9 | 177.8 | 24,326.8 || `decode` | 140 | 8,648.7 | 86.6 | 8,737.1 || `push` | 3 | 1,248.4 | 1.0 | 1,249.9 || `fill` (first / reset frames) | 2 | 888.4 | 0.5 | 889.4 || **steady frame** (encode + decode + push) | **457** | **34,045.0** | **265.4** | **34,313.8** |
The kernel sum is 99.2 % of the span, so the device is kernel-bound. The spans agree with the bench's back-to-backreplays (24.24 / 8.68 / 1.26 ms).
Per stage. The labels come from the `--eager` run's module signposts, whose op sequence matched the traced one op forop. The kernel times are the traced ones. GMAC is from SPEC 4.4 (original graph).
| stage | ops | kernel µs | GMAC | TFLOP/s | what dominates ||---|---:|---:|---:|---:|---|| enc.stem (7×7 s2 + max pool) | 15 | 3,408.6 | 2.54 | 1.5 | 2 PaddedSlice 2,793 µs: DRAM slicing of the 6-byte-stick input into 8-channel L1 shards || enc.layer1 (3 bottlenecks, 64×176) | 34 | 3,602.4 | 14.40 | 8.0 | 7 DRAM-bound 1×1 matmuls 1,431; 6 ReshapeView 1,018; 3 adds 693 || enc.layer2 (4, 32×88) | 51 | 4,949.5 | 22.15 | 9.0 | 10 ReshapeView 2,576; 8 matmuls 1,132 || enc.layer3 (6, 16×44) | 73 | 4,036.0 | 31.56 | 15.6 | 14 ReshapeView 1,697; 12 matmuls 914; 7 convs 727 || enc.layer4 (3, 8×22) | 40 | 1,792.7 | 17.44 | 19.5 | 8 ReshapeView 801 || enc.neck (CustomFPN) | 13 | 805.1 | 13.29 | 33.0 | || enc.depthnet.reduce (+ gates, context) | 10 | 645.6 | 10.15 | 31.4 | || enc.depthnet.blocks (3 BasicBlocks) | 45 | 3,383.8 | 59.8 | 35.3 | 6 convs 1,763; 12 ReshapeView 1,350 || enc.depthnet.aspp (+ GAP bias, conv1) | 30 | 1,461.7 | ≤ 6.8 | | 6 ReshapeView 675 || enc.depthnet.head (logits + softmax) | 2 | 50.7 | | | || enc.out (depth \| feat concat) | 1 | 11.8 | | | || dec.gather (AlignBEV + GatherBEV) | 5 | 3,484.0 | | | grid_sample 2,046; concat 506; permute 484; reshape 319; tilize 129 || dec.layer1 (864 → 160, 64²) | 27 | 1,041.6 | ≈ 20.7 (3 stages) | 23.5 (3 stages) | conv1 and downsample each 281 µs on the same input (+ 2 × 77 µs I2S) || dec.layer2 / dec.layer3 | 27 / 33 | 305.6 / 409.9 | | | || dec.neck (FPN_LSS) | 28 | 2,451.2 | 45.16 | 36.8 | 3×3 800 → 512 at 64² 443 (59 % of the FLOP model); 3×3 512 → 512 276; 3×3 512 → 256 at 128² as 2 DRAM slices 2 × 384; 2 grid_sample upsamples 519 || dec.head (shared + merged) | 20 | 956.4 | ≈ 7.2 | 15.0 | block-diagonal 384 → 20 conv (fp32 out) as 2 DRAM slices: 2 × 322 µs at 3.4 % of the FLOP model || push (ring shift) | 3 | 1,248.4 | | | slice 301 + concat 455 + copy 493 (25 MB) |
The whole frame (≈ 501 GFLOP) runs at 14.7 TFLOP/s. tt-perf-report's FLOPs % column implies a HiFi4 peak of about166 TFLOP/s on 120 cores. On that model:- the encoder's 3×3 convs run at 40–62 % (time-weighted about 51 %). The eight 3×3 512 → 512 convs at 16×44 are at 61 %, 294 µs each. The ASPP's 96-output dilated branches are at 15–16 % (2 × 211 + 73 µs);- the decoder's convs run at 19–63 % (time-weighted 32 %);- the encoder's 1×1 matmuls (DRAM in and out) are flagged "SLOW" at 5–39 % (time-weighted 16 %), with DRAM at 25–50 % of peak.
The profiler's performance model puts the ideal time of the 97 conv/matmul programs at 3.6 ms; they measured 12.5 ms.
Sinks by op type (steady frame, 34,045 µs):
| sink (op type) | µs | % | where ||---|---:|---:|---|| ReshapeView (TILE re-tiling to 4-D and back) | 8,948 | 26.3 | encode 60 ops: two per 3×3 / stride-2 conv on 64×176 … 8×22 maps (W not a multiple of 32); decode 7 || Conv2d | 8,164 | 24.0 | encode 32 (incl. the stem's 2 slices), decode 23 || Matmul (1×1 convs, DRAM in/out) | 4,344 | 12.8 | encode 41 ("SLOW": DRAM-bound) || PaddedSlice (conv DRAM slicing) | 2,899 | 8.5 | stem 2,793; neck / head 106 || GridSample | 2,565 | 7.5 | AlignBEV 2,046; FPN_LSS ×4 / ×2 519 || BinaryNg (residual adds, gates, GAP bias) | 1,870 | 5.5 | encode 23 (layer1 adds 230 µs each) || I2S + S2I | 1,413 | 4.2 | 100 programs, around every conv || Concat + Copy + Slice + Permute | 2,303 | 6.8 | gather concat 506 + permute 484; push 1,248 (slice + concat + copy); neck / encode concats 64 || Unary (ReLU after the convs / linears that run as matmuls) | 429 | 1.3 | 18 ops || Halo + Move + Tilize + SliceWrite + Untilize | 912 | 2.7 | || Pool2D, Upsample, Softmax, Reduce | 197 | 0.6 | |
Pure data movement and relayout account for 16.5 ms (48 %) of the frame: ReshapeView, PaddedSlice, Concat, Copy, Slice,Permute, I2S / S2I, Halo, Move, Tilize, SliceWrite and Untilize.
Kernel durations in the CSV are per execution. The tensor shapes of programs that repeat (e.g. the unary ReLUs) cancome from Tracy's op-info cache: re-run with `--no-op-info-cache` before relying on them. The stage labels do notdepend on shapes, because they are matched op by op against the eager run's op codes.
Top 10 device ops of a steady frame (traced kernel time):
| # | op | stage | µs | cores | shape ||---:|---|---|---:|---:|---|| 1 | GridSample (AlignBEV, 8 slots) | dec.gather | 2,046 | 120 | ring [8, 128, 128, 96] bf16 RM + grid [8, 128, 128, 2] fp32 || 2 | PaddedSlice (stem conv DRAM slice 1) | enc.stem | 1,523 | 119 | [6, 256, 704, 3] RM DRAM → [1, 1, 592896, 8] L1 height-sharded || 3 | PaddedSlice (slice 2) | enc.stem | 1,269 | 120 | → [1, 1, 496128, 8] || 4 | ReshapeView | enc.layer2 | 672 | 120 | [1, 1, 67584, 256] → [1, 384, 176, 256] TILE || 5 | ReshapeView (back) | enc.layer2 | 654 | 120 | [1, 384, 176, 256] → [1, 1, 67584, 256] || 6 | Concat (curr + 8 aligned slots) | dec.gather | 506 | 120 | → [9, 128, 128, 96] RM || 7 | Copy (ring write) | push | 493 | 120 | [8, 128, 128, 96] RM || 8 | Permute | dec.gather | 484 | 120 | [9, 128, 128, 96] → [128, 128, 9, 96] RM || 9 | Concat cat(curr, ring[0:7]) | push | 455 | 120 | → [8, 128, 128, 96] RM || 10 | Conv2d 3×3 800 → 512 (FPN_LSS) | dec.neck | 443 | 90 | 64×64, 59 % of the FLOP model |
The first conv appears only at rank 10. The top 9 are data movement or gather, 8.1 ms together (24 % of the frame).
ttnn-visualizer report: `generated/ttnn_reports/bevdet_baseline/`, written by `profile_ops.py --graph-report`(device job 5, 04:28–04:34 UTC, `graph_report.log`). It holds `db.sqlite` (10.7 MB), `config.json` and`cluster_descriptor.yaml`. One eager encode + decode under `ttnn.graph.full_graph_capture`, imported with`ttnn.graph_report.import_report`, gave:- 304 ttnn operations with stack traces;- 947 tensors;- 182,771 buffer records (L1 / DRAM per op).
The 4.1 GB raw `graph_capture.json` was deleted after the import, as the pytest fixture does. Pair the directory withthe Tracy reports directory above as the performance report (commands in "How to run"). The capture took 204 s:logging mode, never used for timing.
## Ranked optimization opportunities
Gains are estimated on the device frame (34.15 ms b2b) unless marked **e2e** (the plain `model()` p50: 173 / 342 / 220ms). Every item keeps the accuracy gates above. "Exact" means the outputs are bit-identical or the change is pure layout.
1. **Image input path: upload uint8 crops and normalise on the device, into a stem-ready layout (e2e −35..−40 ms; device −2.5 ms; exact).** - The `img` upload is 27.1 ms of 1,081,344 six-byte pages. - The host fp32 normalisation, NHWC rows and bf16 host tensor cost about 15 ms (5–10 + 8.5–10.5 + 1.6–4.7 ms). - The stem's two PaddedSlice ops re-read the 6-byte sticks: 2.79 ms on the device. - Proposal: - Upload the 3.2 MB uint8 crops as 2112-byte HWC rows (≈ 0.6 ms at the measured 5.5 GB/s). - On the device: typecast, then (x − mean)·(1/std) in fp32 → bf16. For all 768 (channel, value) inputs this is bf16-identical to the host's true division (`check_device_normalize.log`: 0 / 768 differ; the device's fp32 → bf16 rounding still needs a bit-identity test against the current `img` buffer). - Write the stem conv's input in the padded, sharded layout it slices into today. - This is K9-lite (PORT_LOG I5, B14).2. **Host preprocessing of non-native image sizes (e2e −160 ms on 1920×1080 inputs; exact).** - The PandaSet host_pre is 209 ms. Per camera: - the numpy channel flip copy: 16–45 ms; - the 900×1600 plane transpose: 4–15 ms; - the resize itself: 1.3–4.5 ms. - Proposal: resize the RGB image with OpenCV (channel-independent: `resize(RGB)[..., ::-1] == resize(BGR)`, verified in `resize_path_micro.log`), then take the 256×704 LUT gather from the resized HWC image. Flip and transpose only that crop, or use `cv2.cvtColor` (0.18 ms). - Add one thread per camera for any size (est. −10..−20 ms on 1600×900).3. **Encoder conv chain: drop the 4-D re-tiling and keep activations in L1 (device −10..−12 ms of 24.1; layout only).** - The cost today: - 60 ReshapeView programs (8.57 ms, 35.5 % of encode). They come in pairs around every 3×3 and stride-2 conv that takes a DRAM-interleaved TILE input on a map whose width (176 / 88 / 44 / 22) is not a multiple of 32. - 62 I2S/S2I conversions, 1.04 ms. - 41 DRAM-bound 1×1 matmuls, 4.24 ms. - 23 DRAM residual adds and gate multiplies, 1.83 ms. - 18 unfused ReLUs after matmul-path convs, 0.43 ms. - Proposal: 1. A/B C17's `slicing="l1"` (L1FullSliceConfig) per conv. 2. Keep the bottleneck chains height- or block-sharded in L1. Layer1's 34.6 MB fits the ≈ 167 MiB of aggregate L1. The Blackhole ResNet-50 demo in `tt-metal/models/demos/vision/classification/resnet50/blackhole` is the config reference. 3. Fuse the ReLU into the 1×1 matmul. 4. Run the residual adds sharded. 5. Reconsider the ASPP's 96-output dilated 3×3 branches (2 × 211 µs at 16 % of the FLOP model). - This is the largest device item. It also raises the math share, which changes what item 6 is worth.4. **Scale-NMS on the host (e2e −30..−45 ms on real scenes; exact).** - The postprocess is 49.5–52.2 ms on PandaSet and nuScenes (9.7 ms with 7 boxes), almost all of it the vectorised vendor polygon IoU over the pre-filtered pairs of 500 candidates. - Proposal: - a lazy greedy pass that only evaluates pairs against kept boxes; - a tighter exact pre-reject (circumcircle, then separating axes), so that most pairs skip the polygon; - a faster implementation shared through C15 (PORT_LOG §9 lists `rotated_iou_vendor` / `nms_rotated` as promotion candidates). - The keep list stays identical, because the pre-reject only drops IoU = 0 pairs.5. **Device BEVPool and one trace per frame: the MK-2 "BEVBuilder" megakernel attempt (e2e −20..−45 ms; device −3 ms; the D19 attempt).** - It replaces: - the host BEVPool (p50 15–36 ms, min 10–12 ms, the most load-sensitive stage); - the D2H of depth | feat and its host untilize (1.3–5.3 ms); - the `curr` host tensor and H2D (1.6–4.7 ms); - the second replay. - If AlignBEV (4-tap, fp32 weights), GatherBEV and the slot write go into the same persistent kernel, it also removes the 3.48 ms gather block and the 1.25 ms ring shift. The device cost is SPEC 8.2's segment-matmul estimate of 0.2–0.4 ms (UNVERIFIED) plus the fused AlignBEV. - This is where a megakernel can pay off: the cost here is data movement and a host round trip, while dispatch is only 0.27 ms per frame. - Compile-time arguments: C = 80, `adj_num` 8, BEV 128², M_max / N_max 370k / 14k, block 32, core grid. Runtime inputs: the tables, partition, transforms and flag in device buffers, so a new calibration needs no re-capture (SPEC 9).6. **Precision (the cost the port measured; device −2.2 ms; gate-checked per module, PLAN §9.3).** - HiFi2 instead of HiFi4, with fp32 weights and L1 accumulation kept, measured during the port (`logs/bevdet/timing_experiment1.log`): encode 24.25 → 22.89 ms, decode 8.74 → 7.94 ms. That is −2.2 ms per frame (−6.3 %). Its accuracy was never gated, and tt-perf-report suggests HiFi2 for most matmuls. The most compute-bound programs gain most: the eight 3×3 512 → 512 convs at 61 % of the HiFi4 model. - bf16 instead of fp32 weights saves only 0.13 + 0.16 ms, and fails the sample0 gate: 48 / 52 < 50 (B11). Not worth it. - Re-measure HiFi2 after item 3, when compute is a larger share.7. **AlignBEV identity fast path in Autoware mode (device −2.0 ms; exact).** - With identity transforms and a full history, which is the default node's steady state, AlignBEV is a bit-exact copy (`test_alignbev_exact_cases`). - A `decode` variant without the 2.05 ms `grid_sample`, chosen by the host plan like `fill` / `push`, removes it from every steady Autoware frame. Ego-pose frames keep the full variant.8. **GatherBEV and ring layout (device −1.5..−2.2 ms; exact).** - The cost today: concat 0.51 + permute 0.48 + reshape 0.32 + tilize 0.13 ms build the [16384, 864] TILE input, and `push` shifts 25 MB (1.25 ms). - Proposal: store the ring per pixel, slots in channels, so that GatherBEV is one concat/tilize. Write one slot per frame, through per-slot write variants or a rotating head, instead of shifting all eight. - Partly subsumed by item 5.9. **BEV decoder convs (device −1.0..−1.5 ms; exact rewrites).** - Peer-merge conv1 and downsample of each CustomResNet stage: same input and stride, one 2×Cout conv, then split. In dec.layer1 they are 2 × 281 µs plus 2 × 77 µs of I2S (SPEC 8.1). - Remove the 2-slice DRAM slicing of the 128² neck / head convs (PaddedSlice + SliceWrite 0.16 ms). - Give the 384 → 20 block-diagonal head conv a better form: grouped, or K-blocked. Today it runs as 2 DRAM slices of 322 µs at 3.4 % of the FLOP model, with fp32 output. - Retune the 50–90-core block shardings.10. **FPN_LSS align-corners upsampling as interpolation matmuls (C18 `Resize2d`) (device ±0.3 ms; accuracy).** - The two `grid_sample`s take 0.52 ms plus 0.13 ms of tilize/untilize. - The fp32 interpolation weights would also remove the small negative score bias of VERIFY_PORT L3 (bf16-truncated bilinear weights).11. **Host conversions (e2e −5..−15 ms under load).** - Four numpy ↔ ttnn host conversions per frame cost 1.0–1.6 ms each at minimum and 3–5 ms at p50 on the shared host. - Proposal: preallocated host tensors (`ttaw.tensors.HostStaging`), untilize on the device before the readback, and no `curr` pad copy.12. **MK-1: image-encoder tail megakernel (D19 candidate; decide after item 3).** - The 16×44 / 8×22 tail costs 12.2 ms today, about 5.0 ms of it re-tiling: layer3, layer4, CustomFPN, depth trunk and ASPP, about 20 matmul-like convs on 4224 rows with activations ≤ 4.3 MB. - Only what remains after item 3 can justify a persistent conv-chain kernel. None of the reference bundles shipped a megakernel (RP:173-180), and dispatch here is 0.8 % of the frame.13. **Cross-frame pipelining (throughput only).** - The device needs 34 ms per frame and the host more than 90 ms, so the throughput ceiling is host-bound until items 1, 2, 4 and 5 land. - Proposal: overlap a frame's host preprocessing with the previous frame's device work, using host threads, and 2 CQs with `stage_inputs` only for large pipelined uploads (D14). - Latency is unchanged.
Fusion candidates, collected from the items above:- the ReLU into the 1×1-conv matmuls: 18 ops, 0.43 ms (item 3);- the residual add (+ ReLU) into sharded chains: 23 DRAM adds, 1.83 ms (item 3);- conv1 + downsample peer merges in the CustomResNet: 3 pairs (item 9);- the image normalisation into the input path: K9-lite (item 1);- AlignBEV + GatherBEV + the ring write into one op (items 7, 8 and 5).
Megakernel candidates (D19):- **MK-2 BEVBuilder** (item 5), first: it removes the host round trip and the temporal block's data movement;- **MK-1 image-encoder tail** (item 12), only after item 3;- **MK-3 BEV decoder**: its convs are 3.5 ms at 32 % of the FLOP model;- **MK-4 device decode / top-k**: low value, since the host decode is 1 ms and the scale-NMS stays on the host.
Indicative sum: items 1, 3, 6, 7, 8 and 9 would take the device frame from 34 ms to roughly 12–17 ms. The itemsinteract, so this is not a straight sum. Items 1, 2, 4, 5 and 11, plus those device gains, would take the e2e of anative 1600×900 stream from about 173–220 ms to about 60–90 ms. Every number here is anestimate, to be measured step by step (PLAN §5.1).
## Raw logs, CSVs and scripts
All paths are under `/home/ubuntu/experiments/tt-models/`.
- **`logs/bevdet/baseline/`:** - `device_suite_revendor.{log,rc}` and `reports_revendor/`: the gate run after the re-vendor. - `host_suite.log`, `VENDORED_0.11.0.json`. - `bench_{smoke,eth-1cq,eth-2cq,worker-2cq,worker-1cq,eth-1cq-repeat}.{log,json}`, `matrix.rcs`. - `profile_tracy.log`, `profile_meta.json`, `profile_summary.{json,md}`. - `perf_report/{encode,decode,push,fill}_perf_report.{txt,csv,console.log}`, plus the stacked CSV and PNG. - `host_stage_profile.json`, `resize_path_micro.log`, `check_device_normalize.log`. - `graph_report.log`, `graph_report_meta.json`. - `bench_final_smoke.{log,json}`: a 5-iteration smoke of the committed `bench.py` (`--inputs synthetic,sample=…/pandaset_019_f38.json`). Its device numbers are the same: b2b frame 34.18 ms, encode 24.26, decode 8.70. - `job{1,2,3,5}.log`; `scripts/`, with the job scripts, `bench_tables.py`, `host_stage_profile.py`, `resize_path_micro.py` and `check_device_normalize.py`. The profile ran inside job 3, not as the standalone `job4_profile.sh`.- **`generated/profiler/bevdet_baseline/reports/2026_10_08_04_05_34/`:** `ops_perf_results_2026_10_08_04_05_34.csv`, `profile_log_device.csv`, `tracy_profile_log_host.tracy`. - The Tracy output directory is 2.4 GB, mostly the 744 MB `profile_log_device.csv`, which is stored twice, and `.logs/tracy_ops_times.csv` (900 MB). - `python -m tracy` tried to copy the host trace into the WASM viewer's `traces/` under `tt-metal/build/profiler/build_wasm/`. The copy failed ("Could not copy"), but Tracy still re-pointed that directory's `embed.tracy` symlink at the missing file. Every Tracy run does this (the YOLOX baseline did at 03:23). Nothing else under `tt-metal/` was written.- **`generated/ttnn_reports/bevdet_baseline/`:** the ttnn-visualizer memory and graph report.- **Device jobs**, all through `bin/devrun` (`logs/devrun/history.log`): - the gate suite, 02:58:48–03:00:14 UTC; - the bench smoke, 03:33:55–03:34:28; - the bench matrix plus the Tracy profile, 03:45:24–04:05:39; - the graph report plus the final bench smoke, 04:28:37–04:35:03. - All four ended with rc 0: no hang, no reset, no `.device.FAULT`.
## After optimization (2026-10-14, the second release)
The same measurement on the optimized port: bundle `3efa0f5` code (rounds 1-6 of [`OPT_REPORT.md`](OPT_REPORT.md) attheir defaults, ttaw 0.23.4, tt-metal `44d66500520` + the ETH-dispatch and the SYS-1419 reshape patches), therepublish card job `logs/bevdet/republish/job_card.sh` (one `devrun` window; `bench_eth.json`, host load average9-10 while a package build ran next to it). The ETH numbers were measured on `a04770a`; `3efa0f5` only adds a gridcheck to `tt.linear1x1` that is a no-op on the 12×10 grid. Same inputs, iterations and stage split as above;`synthetic` uses the shipped sample's preset `synthetic_6cam` (the bench default since the release).
| stage, p50 (p99) | synthetic | PandaSet | nuScenes (ego poses) ||---|---:|---:|---:|| host preprocess (numba: resize at the crop's pixels, gather into uint8 crop rows) | 3.86 (7.54) | 7.87 (14.41) | 3.26 (5.94) || host → ttnn host tensor + H2D `img` (3.2 MB uint8 crop rows) | 0.96 + 0.49 | 1.00 + 0.52 | 0.71 + 0.48 || **trace `encode`**, one blocking replay | **6.79 (7.11)** | **6.80 (7.59)** | **6.79 (6.92)** || D2H + host BEVPool hand-over (`d2h.encode` + `host_out.encode`) | 0.32 + 1.34 | 0.34 + 1.34 | 0.33 + 1.10 || host → ttnn + H2D `curr` (+ `grid` with ego poses) | 1.07 + 0.57 | 1.14 + 0.59 | 1.24 + 3.83 || **trace `decode`** (`decode_move` with ego poses) | **2.91 (5.08)** | **2.91 (4.24)** | **7.59 (7.79)** || D2H + TILE → numpy | 0.35 + 0.88 | 0.38 + 0.89 | 0.35 + 0.75 || **ring update** (`push_x` after an identity decode, `push` otherwise) | **0.30** | **0.31** | **0.45** || host postprocess (numba Scale-NMS) | 3.26 (7.05) | 3.59 (7.82) | 4.46 (5.55) || `timing_ms.bevpool` of the plain loop (host BEVPool + AlignBEV grid) | 8.29 | 7.82 | 8.81 || **e2e `model()`** | **34.6 (52.9)** | **39.7 (86.7)** | **42.4 (53.5)** || e2e p50 in the same-day verification (load 5-7, `logs/bevdet/verify_opt1/ab_{2,4,6}_head.json`) | 30.4-31.0 | 34.3-35.3 | 39.1-40.3 || first release (above) | 173.3 (217.5) | 341.9 (370.5) | 220.3 (262.5) |
Device only (`device_only`, back to back): `encode` 6.842, `decode` 2.967, `decode` with the moving grid 7.556,`push` 0.413, `push_x` 0.266, `fill` 0.303 ms; **frame 9.988 ms** (identity) / **14.712 ms** (ego motion), against34.15 / 34.45 ms above: **3.42× / 2.34×**. Device-bound throughput 100 frames/s (68 with ego poses). The verificationmeasured 9.954-9.997 ms in three processes. The moving-grid decode is now the largest single trace after `encode`:its AlignBEV `grid_sample` was not optimized (OPT_REPORT.md lists it).
- **Programs.** Round-6 profile (`logs/bevdet/opt_r6/profile_r6_summary.txt`): `encode` 189 programs, kernel sum 6,713 µs; `decode` 104 programs, 2,826 µs; `push_x` 1 program. 294 programs per steady frame (457 before); the program cache holds 194 entries (214).- **Load.** `from_pretrained` 14.8 s in the bench process (weights 0.31, build 1.42, warm-up / capture / warm frame 8.77 s), 17.2 s in `load_times.py`; the first call on a new calibration or image size 0.18-1.6 s (`first_calls.json`).- **WORKER (11×10).** 10.343 ms per frame back to back after the republish fix (OPT_REPORT.md "Republish"; `bench_worker_try2.log`), the first load 133 s (compile for the 11×10 grid); 34.83 ms in the first release.- **Served.** Host uvicorn, the shipped sample, 40 requests: `timing_ms.model_call` 28.8 ms p50, `total` 393.5 ms, client round trip 490.6 ms (the base64 + PNG decode of the 9.6 MB request dominates; `served.log`).- **Accuracy.** The device suite at these defaults, read-only: 34 passed, 2 skipped (`suite.log`, gate md5 unchanged), printed values identical to the round-6 final run and the verification. nuScenes mini_val mAP / NDS 0.3658 / 0.4354 (ego poses) and 0.2533 / 0.2742 (node semantics) against 0.3670 / 0.4362 and 0.2530 / 0.2739 in the first release (`eval_republish.log`).123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647# bevdet-p150 optimization report (p150, ETH dispatch, 12×10 grid)
**Status (2026-10-14): rounds 1-6 kept, round 7 (the D19 megakernel attempt, device BEVPool) measured and not kept(one kernel hang, see "Round 7"); the second release (the optimized port) is packaged and smoke / stress tested, notpushed (see "Republish"). Device frame 34.15 -> 9.99 ms back to back, `model()` p50 131-342 -> 30-42 ms, every frozengate green read-only.** Round 6 (below) re-gridded the largeblock-sharded 3x3 convs COL_MAJOR over the whole grid width (the eight 512 -> 512 CustomFPN / DepthNet convs, ResNet-50layer 3, the BEV neck and the CustomResNet stage 0), chained the CustomResNet BasicBlocks on L1 shards and moved theresize of non-1600x900 images to the crop's pixels only (OpenCV's fixed point, self-checked). Same-session A/B againstthe round-5 configuration (`ab_fin`, load 6.7-7.3): **device frame 10.575 / 10.580 -> 9.970 / 9.977 ms b2b (-5.7 %;14.69 ms with ego motion, was 15.36); one encode replay 7.29 -> 6.79 ms; e2e `model()` p50 PandaSet 1920x108042.4 / 41.9 -> 36.4 / 36.4 ms (host_pre 12.7 -> 7.2), synthetic 31.7 / 31.1 -> 31.1 / 30.9 ms, nuScenes with ego poses41.3 / 38.6 -> 38.8 / 40.4 ms** (the 1600x900 e2e moves within the host-load noise). Every device change isbit-identical (frozen gates read-only print identical values; 34 passed), the host resize is bit-exact with cv2.Round 5 replaced the FPN_LSS`grid_sample` up-samplings by a TILE-layout custom kernel (`upk`: W direction as FPU matmuls, H lerp on the SFPU,fp32 weights), multicast the `mmres_k` weights along the grid rows, and kept the layers 1-2 conv2 outputs / next conv1inputs in their L1 shards. Same-session A/B against the round-4 configuration (`ab_fin`, load 6.9-8.7): **deviceframe 11.962 / 11.968 -> 10.573 / 10.843 ms b2b (-11.6 %; 15.36 ms with ego motion, was 16.77); one encode replay8.20 -> 7.29 ms**; e2e `model()` p50 not resolvable in that session (host pre-processing of the same frames swung3.6-31.8 ms with other agents' host load): synthetic 58.2 / 53.3 -> 40.9 / 46.2 ms, PandaSet 65.7 / 67.7 -> 70.5 /74.9, nuScenes with ego poses 62.1 / 68.0 -> 59.9 / 69.6. R5.2 / R5.3 bit-identical; R5.1 not bit-identical (fp32instead of bf16-truncated interpolation weights), every frozen gate green read-only, sample0 at its gate (50 / 52).Round 4 kept the image encoder'slayer-3 / layer-4 bottlenecks and the DepthNet BasicBlocks in L1 shards (2D-multicast linears on the shards, shardedresidual adds) and made the ring push one slice of the decode input. Same-session A/B against the round-3configuration (`ab_a2`, load 6.0-8.7): **device frame 13.486 / 13.484 -> 11.975 / 11.972 ms b2b (-11.2 %; 16.77 mswith ego motion, was 18.16); e2e `model()` p50 32.5 / 33.9 -> 31.7 / 32.4 ms (1600×900), 43.0 / 44.1 -> 42.4 / 43.2 ms(PandaSet), 42.4 / 42.7 -> 42.2 / 39.0 ms (nuScenes with ego poses)**, every output bit-identical (frozen gatesread-only print identical values). Round 3 tuned the conv configs:activation + weight double buffering on every kxk conv, the remaining stock 1x1 convs as `ttnn.linear` with explicitconfigs and the ReLU fused, and the 384 -> 20 head conv height-sharded on L1. Same-session A/B against the round-2configuration (`ab_r1`, load 6.4-8.2): **device frame 16.262 -> 13.484 ms b2b (-17.1 %; 18.15 ms with ego motion, was20.93); e2e `model()` p50 35.8 / 37.3 -> 34.6 / 34.7 ms (1600×900), 47.9 / 46.9 -> 43.6 / 43.8 ms (PandaSet), 45.8 /45.1 -> 42.9 / 43.1 ms (nuScenes with ego poses)**; R3.1 and R3.2 bit-identical, R3.3 not bit-identical (fp32 K-blockorder) with every frozen gate value printed unchanged. Round 2 (below) moved the image encoder'sand decoder's kxk convs to ttnn's L1 path where that is bit-identical, fused the layer-1/2 bottleneck tails into onecustom program each, stored the BEV history as the decoder input's own tile columns and merged the decoder stages'first convs. Final same-session A/B against the round-1 configuration (`ab_fin`, load 5.9-8.9): **device frame31.635 -> 16.264 ms b2b (-48.6 %; 20.94 ms with ego motion, was 31.91); e2e `model()` p50 50.6 / 50.8 -> 34.9 /36.3 ms (1600×900), 59.7 / 59.2 -> 45.0 / 49.8 ms (PandaSet 1920×1080), 55.8 / 57.6 -> 44.7 / 47.8 ms (nuScenes withego poses)**, every output bit-identical to round 1 (frozen gates read-only print identical values). Round 1: The published first release is thefunctional port, measured in [`OPT_BASELINE.md`](OPT_BASELINE.md) (fp32 weights and biases, HiFi4, fp32 and packerL1 accumulation, bf16 activations; 34.15 ms per steady device frame, `model()` 132-220 ms p50 on 1600×900 inputs).Round 1 (below) moved the host hot spots to bit-identical numba twins and the image input to uint8 crops normalisedon the device: **device frame 34.35 -> 31.64 ms b2b; e2e `model()` p50 147.0 -> 49.0-53.2 ms (1600×900),353.4 -> 60.1-61.0 ms (PandaSet 1920×1080), 172.2 -> 54.9-55.2 ms (nuScenes with ego poses)**, every outputbit-identical to the release path. Rounds are added newest first, with commits, numbers and gates.
All numbers: `code/scripts/bench.py` (warm, batch 1, p50 of 100 iterations unless marked), ETH dispatch, 1 CQ, 12×10grid, tt-metal `44d66500520` + `patches/tt-metal-eth-dispatch.patch`, measured 2026-10-08 on the baseline commit`ad4de55` (ttaw 0.15.0). Device profile: `code/scripts/profile_ops.py` under the Tracy device profiler (the last tracereplay). Accuracy gates: `OPT_BASELINE.md` "How to run".
## Summary
| | baseline `ad4de55` | first release (`c8a3ef8`) | **second release** (rounds 1-6, republish card job) ||---|---|---|---|| device, one steady frame (encode + decode + ring update, back to back) | 34.15 ms (34.45 with ego poses) | same graph: 34.15 ms (34.45) | **9.99 ms (14.71)**; 9.95-10.00 in the verification || one blocking replay: encode / decode / ring update / fill | 24.30 / 8.73 / 1.29 / 0.93 ms | 24.29 / 8.72 / 1.30 / 0.94 ms | 6.79 / 3.00 / 0.30 (`push_x`) / 0.34 ms || e2e `model()` p50 (p99): synthetic 1600×900 / nuScenes 1600×900 with ego poses / PandaSet 1920×1080 | 173.3 (217.5) / 220.3 (262.5) / 341.9 (370.5) ms | 131.8 (187.1) / 172.7 (244.8) / 348.2 (373.7) ms (host load 6.6-10.8; VERIFICATION_2026-10-08.md) | **34.6 (52.9) / 42.4 (53.5) / 39.7 (86.7) ms** at load 9-10; 30.4-31.0 / 39.1-40.3 / 34.3-35.3 ms at load 5-7 (VERIFICATION_OPT_2026-10-14.md) || host preprocess / H2D image / host BEVPool / postprocess (synthetic) | 43.0 / 32.8 / 30.0 / 9.7 ms | | 3.9 / 0.5 / 8.3 / 3.3 ms || device programs per steady frame | 457 (encode 314, decode 140, push 3) | 457 (214 program-cache entries) | 294 (encode 189, decode 104, `push_x` 1; 194 entries) || kernel sum / span (profile) | 34,045 / 34,314 µs; 265 µs of op-to-op gaps | | 9,539 µs + `push_x` (round-6 profile) || accuracy gates (PCC / agreement) | all pass (OPT_BASELINE.md "Accuracy") | all pass, unchanged values | all 34 pass read-only; values identical to round 6; nuScenes mini_val mAP / NDS 0.3658 / 0.4354 (ego) and 0.2533 / 0.2742 (node) vs 0.3670 / 0.4362 and 0.2530 / 0.2739 |
## Steps (chronological; each row is one commit)
| step | commit | what | b2b frame | e2e (synthetic p50) | accuracy | revert switch ||---|---|---|---|---|---|---|| baseline | `ad4de55` | the functional port with ttaw 0.15.0 (from `95a5d78`, verified in VERIFY_PORT.md) | 34.15 ms | 173.3 ms | every gate green, frozen values | || release | `d856d8c`, `aa70bfe`, `5accb85`, `c8a3ef8` | host-side release changes: network class names as `label` + `autoware_label`, the node's `twist`, `nms_rescale_factor` as a request parameter, 4 stream histories (LRU), stream restart on a failed ring update, the synthetic shipped sample, OpenCV declared for the image, ttaw 0.19.0 then 0.20.0, the stage timing `bev_decode` | 34.15 ms (re-measured; no device change) | 131.8 ms (re-check; host load) | gates unchanged; 3 new gates on the shipped sample | || R1.1-R1.4 | `8b64add` … `b1added` | round 1: numba host twins (Scale-NMS, pre-processing, BEVPool) and the K-IN u8 stem (uint8 crops up, normalised on the device); details in "Round 1" | **31.64 ms** | **49.0-53.2 ms** (base arm of the same sessions 147.0 ms) | bit-identical; gates read-only, values identical | `BEVDET_HOST_*`, `BEVDET_STEM_IN=slice` || R2.1-R2.3 | `453138e` | round 2: encoder kxk convs on ttnn's L1 path, `mmres_k` bottleneck tails on layers 1-2, the tile-column BEV history ring | 16.71 ms | 37.1-37.6 ms (load 7.5-8.4) | bit-identical; gates read-only, values identical | `BEVDET_CONV_L1=none`, `BEVDET_BACKBONE_RES=stock`, `BEVDET_RING=rm` || R2.4b, R2.5 | `9d07c04` | the decoder convs that are bit-identical on L1; peer-merged stage-first convs of the CustomResNet | **16.26 ms** | **34.9-36.3 ms** (`ab_fin`; round-1 arms 50.6 / 50.8 ms in the same session) | bit-identical; 34 gate / kernel / equality tests read-only, values identical | `BEVDET_CONV_L1=all`, `BEVDET_DEC_MERGE=0` || R3.1-R3.3 | `8db2320` | round 3: activation + weight double buffering of the kxk convs, the stock 1x1 convs as `ttnn.linear` (ReLU fused), the head conv height-sharded on L1; details in "Round 3" | **13.48 ms** | **34.6-34.7 ms** (`ab_r1`; round-2 arms 35.8 / 37.3 ms in the same session) | R3.1 / R3.2 bit-identical; R3.3 fp32 K order, gate values unchanged; 34 gate / kernel / equality tests read-only | `BEVDET_CONV_TUNE=0`, `BEVDET_MM1X1=0`, `BEVDET_HEAD2=dram` || R4.1-R4.3 | `8f65bb4` | round 4: layers 3-4 L1-resident (`tt.l1res`), the DepthNet chain on L1 shards, the ring push as one slice of the decode input; details in "Round 4" | **11.97 ms** | **31.7-32.4 ms** (`ab_a2`; round-3 arms 32.5 / 33.9 ms in the same session) | bit-identical; 34 gate / kernel / equality tests read-only, values identical | `BEVDET_L1RES=0`, `BEVDET_DN_L1=0`, `BEVDET_PUSH_X=0` || R5.1-R5.3 | `ce50487` | round 5: the `upk` TILE up-sampling kernel (FPN_LSS), `mmres_k` weight multicast, layers 1-2 conv2 <-> `mmres_k` on L1 shards; details in "Round 5" | **10.57 ms** | not resolvable (host load; `ab_fin`) | R5.2 / R5.3 bit-identical; R5.1 fp32 weights, 34 gate / kernel / equality tests read-only green, sample0 50 / 52 (gate 50) | `BEVDET_UPSAMPLE=grid`, `BEVDET_MMRES_MCAST=0`, `BEVDET_RES_L1=0` || R6.1-R6.4 | `269a7e8`, `e24f24f`, `bcef9d9`, `edcb968` | round 6: transposed (COL_MAJOR) block sharding of the 512 -> 512 encoder convs and the BEV neck, CustomResNet conv1 -> conv2 on L1 (stage 0 transposed), layer 3 transposed, the host resize at the crop's pixels; details in "Round 6" | **9.97 ms** | 30.9-31.1 ms (PandaSet 36.4 ms, was 41.9-42.4; `ab_fin`) | device bit-identical, 34 gate / kernel / equality tests read-only, values identical; host resize bit-exact | `BEVDET_TSHARD=none`, `BEVDET_DEC_CHAIN=0`, `BEVDET_L3T=0`, `BEVDET_HOST_RESIZE=cv2` || republish | `3efa0f5` | WORKER dispatch fix: `tt.linear1x1` runs a probed 12×10 config only where it is valid on the device grid (stock `conv2d` otherwise); see "Republish" | 9.99 ms (ETH unchanged); WORKER 10.34 ms (failed to load before) | 34.6 ms (load 9-10) | ETH: no-op; WORKER gates 20 passed read-only, ETH values | none (a fix) |
## Republish (2026-10-14): the second release
Evidence: `logs/bevdet/republish/`. No push, no HF token.
| step | result ||---|---|| ttaw 0.23.4 re-vendored (`6abfb81`) | common `9dd4abf`. Only `ops/segment.py` and its kernel changed, which BEVDet does not use. `patches/` gains `tt-metal-reshape-rm-sys1419.patch`, which the tree, every round and the image carry. Verify lines were added for the reshape patch, the `bpk` kernel files and the knob defaults. || card job (`a04770a`, one `devrun` window, `job_card.sh`) | Device suite read-only: **34 passed**, 2 skipped (`BEVPOOL=device` only), gate md5 unchanged, values identical to round 6. Quickstart, host server smoke and served timing passed. The public runs (PandaSet 019, nuScenes scene-0103 / 0916, both modes) give mini_val mAP / NDS **0.3658 / 0.4354** (ego) and **0.2533 / 0.2742** (node), against 0.3670 / 0.4362 and 0.2530 / 0.2739 in the first release. Bench at host load 9-10: b2b frame **9.988 ms** (14.712 with ego motion); `model()` p50 34.6 / 39.7 / 42.4 ms (synthetic / PandaSet / nuScenes). || **finding: WORKER dispatch broken** | `bench --dispatch worker` failed at trace capture: `TT_FATAL per_core_M (20) must be divisible by out_block_h (6)`. The cause is R3.2's layer1.0 conv1 1D config, which was probed on 12×10 and is invalid on 11×10. ETH was not affected. This also broke the documented fallback for a tt-metal without the ETH patch. || fix `3efa0f5` | `tt.linear1x1.fits()`: a probed config runs only where it is valid on the device grid, and the stock `conv2d` (bit-identical) runs otherwise. Host test added. WORKER: **10.343 ms** b2b (was 34.83 ms in the first release), gates `test_pcc` + `test_e2e` + `test_streams` read-only **20 passed** with the ETH values (`worker_gates.log`). On 12×10 the fix is a no-op. || first-call cost | Measured on a new calibration and image size, in a fresh process (`first_calls.json`): 176 ms (nuScenes), 542 ms (the shipped sample, PNG files), 1,579 ms (PandaSet 1920×1080 JPEG files, including the one-time resize self-check). Later calls take 30-81 ms. The README and PYTHON now say so (the first release claimed no first-call penalty). || package (`3d2082f`) | `tt-model package` rc 0 in 10 min 18 s. 20 / 20 verify lines passed in the image. Image `tt-model/bevdet-p150:71921c4fdcbc`, code digest `434224b18fba83a3`. Build base digest `422ce20f…`, which differs from the first release's `df9d279c…` because the local tag moved (`build_info.json`). || container smoke, profile `default` (the only one) | **PASS**: eth, 12×10, 1 CQ, 10 / 10 against `synthetic_6cam.reference.json`, max score difference 0.0038, max centre difference 0.005 m. Cold JIT (0 / 501 hits): the app was ready in 158.1 s, 2 min 40 s with the launcher (first release: 171.6 s). Clean stop. || in-container ETH stress (same `devrun -t 3600 -k 150` window) | **PASS, 2,100 requests** over the served `/predict`, run inside the container. Three streams were fed round-robin: nuScenes scene-0103 kf0-2 with ego poses, PandaSet 019 f38-40, and the shipped sample. 0 errors, 0 mismatches: after the stream histories filled (8 calls per input), all 292 later responses of each input (minus `timing_ms` and the frame counter) were byte-identical. `/info`: eth / 12×10 / 120 cores. 413.7 s. Server `timing_ms.total` p50: 113-115 ms (nuScenes JPEG), 165-172 ms (PandaSet JPEG), 397 ms (the sample's PNGs); the request decode dominates. |
## Round 7 (2026-10-14): the D19 megakernel attempt, MK-2 BEVBuilder module 1 (device BEVPool), not kept
**What was built** (`BEVDET_BEVPOOL=host|device`, default `host`; `tt/bevpool_k.py`, `tt/kernels/bpk_{reader,writer,compute}.cpp`, one `ttnn.generic_op` appended to the `encode` trace): BEVPool v2 on the device, so the frame needs nodepth / feature read-back, no host BEVPool and no `curr` upload (the e2e item that OPT_PLAN 0.6 ranks first:`host_out.encode` 1.1 + host BEVPool ~7 + `host_in.decode` 1.0 + `h2d.decode` 0.6 ms of the 31 ms synthetic e2e).The encode output `cat(depth, feat)` is untilized into L1 (448 B per pixel); per output group of 32 BEV cells thereader RISC builds a bf16 A tile `A[cell, k] = depth[pix_k, bin_k]` from 16 B L1 reads, the writer RISC gathers the32 feature rows (192 B each), compute tilizes them and accumulates `A @ F` into 3 fp32 DEST tiles (chunks of 16blocks with an exact fp32 spill / reload), casts RNE to bf16 and pack-untilizes the 32 rows, which the writer storesas the cells' pages of the existing ROW_MAJOR `curr` input. The decode traces are unchanged; `_forward_device` replays`encode` and the decode / ring variants back to back with one upload and one read (no host round trip).
**Parameter split (D19 taxonomy):** COMPILE = core count / grid width (from `compute_with_storage_grid_size`), chunkG, batch NB, table geometry (header, group list, cell pages, first block page), source row geometry (448 B rows,depth / feature offsets, 16 B L1 or 64 B DRAM read granule), 3 channel tiles, TensorAccessor args. RT-dev percalibration = `bp_tab` (uint32 [1, 1, P, 32] ROW_MAJOR in DRAM, 128 B pages: per core {group list start, count,first block}; group list {group, blocks}; per group its 32 cell ids; per block 32 entries `pix | bin << 13 | lane <<20 | valid << 25`), built on the host in 55 ms (`BEVPoolK.table`, cached with the calibration) and uploaded only whenthe calibration changes (no re-capture). Common RT args = the 3 buffer addresses. No per-core RT args (P3). Per frame:nothing from the host.
**Bring-up and measurements** (`logs/bevdet/opt_r7/`; hang protocol: smallest shape under `TT_METAL_WATCHER=2`, eagerx2, then the model shape, then a 2-call trace):
| step | result ||---|---|| `bring1_small_watcher*.log` (96 cells, 64 pixels, 2 cores, watcher) | runs, deterministic, no watcher finding || `bring2.log`, `probe1.log`, `probe2.log` (first form: any 32 contributions of a 32-consecutive-cell group per block) | 22 / 546 values off the float64 model by more than 1 bf16 ulp; the error is **~2^-11 of the summed terms' magnitude (5.5e-4)**, identical for chunk 1 / 8 / 16 / 64 (the fp32 spill / reload is exact) and larger at HiFi3 (1e-3) / HiFi2 (6e-3) / LoFi (5e-2): the FPU's 32-term inner sum of a matmul tile is not an exact fp32 sum of the exact bf16 products || `bring3.log` (first form, model shape, L1 and DRAM source, 2-call trace) | runs; vs the host twin 87,354 of 1,572,864 values differ (76,739 by 1 ulp, long tail) || `gates_dev1.log` (first form, `BEVDET_BEVPOOL=device`, frozen gates read-only) | **fails two frozen gates**: sample0 49 / 52 (gate 50), PandaSet f40 `score_abs_err` 0.190 (gate 0.05); `bev.curr` PCC 0.999956 passes. Not usable || `probe3.log` (exact form: at most ONE contribution per cell and block, so every output element gets one product per matmul and the sum happens in the fp32 DEST accumulation) | **0 values off the float64 model** on the random case (was 546) || `time1.log` (model shape, one 10-call trace, best of 3) | first form 331.6 us per call (11,368 blocks, max 126 per core); exact form 700.2 us (31,909 blocks with consecutive groups, max 512 per core); exact form without the depth reads 513 us (reader-bound) || `gates_dev2.log` (exact form, consecutive groups, frozen gates read-only) | **every frozen gate green**: `bev.curr` 0.999956 / 0.999953, sample0 **51 / 52** (host path 50), PandaSet f38-40 recall 1.0 / 0.996 / 0.995 and score error <= 0.0079, nuScenes scene-0103 / 0916 recall 0.9915 / 0.9887; device `curr` vs the host twin: 39 of 1,572,864 values differ (fp32 summation order). 21 of 22 passed: my own new device-vs-twin check had a relative bound too tight for cancelling sums (rewritten as <= 4 ulp in <= 0.01 % of the values) || `bring4.log` (exact form + cells grouped by contribution count (any 32 cells per group, rows written to their pages) + blocks in batches of NB = 4: one barrier per batch) | small shapes under the watcher pass (0 values off the model); **the model shape hung** in its first eager call (`faulthandler` in `_read`, devrun timeout 900 s at 09:50 UTC, `.device.FAULT`). Not root-caused: the table walk was emulated on the host for the model shape (permutation of the cell pages, one entry per cell and block, result 1e-13 from float64) and the CB protocol reviewed; the remaining suspects are the 128 outstanding 16 B L1 reads per RISC on 120 cores (NB = 4; NB = 1 ran at this shape in `time1`) and the grouped heavy cells (32 heavy cells per group: 512 blocks of 32 valid entries). The device stayed faulted for the 2 h polling window, so no further device run, no A/B |
**Decision: not kept** (default `BEVDET_BEVPOOL=host`; SERVING.md marks `device` experimental). The only gated form(exact, consecutive groups, NB = 1) costs 0.70 ms on the device per frame against ~9-10 ms of host work it removes,so it would likely win e2e by ~8 ms, but no same-session A/B could be run before the hang, and the faster form hung.`BEVPoolK` now defaults to NB = 1 (the batch that ran at the model shape). Next steps, in order: re-run the exact format NB = 1 with the grouped cells under the watcher (does the grouping alone hang?), then NB = 2; a same-session A/B`BEVPOOL=host` vs `device` (b2b frame + e2e); then the heavy-cell problem: the 32 heaviest cells (up to 512-731contributions, near the ego car) bound the kernel at one core, so either split them into segments whose fp32partials are combined exactly (hi / mid / lo bf16 terms, one product per matmul, as above) or prefetch the blockpages to hide the per-block latency (~1.4 us now).
## Round 6 (2026-10-14): transposed block sharding of the large convs, CustomResNet chaining, host resize at the crop
Measured first: the round-5 profile put the eight 512 -> 512 3x3 convs of the CustomFPN / DepthNet at 8 x 222.7 us(17 % of the frame) on 8 x 10 of the 12 x 10 cores: ttnn block-shards a conv ROW_MAJOR (rows over the grid rows,channels over the grid columns) and 16 channel tiles do not split over 12 columns, so 14 tile rows of 132 per core.`transpose_shards` (COL_MAJOR) puts the rows over the 12 columns (11 tile rows each) and the channels over 8 grid rows(2 tiles each). The per-core input-channel shard (64) and the K loop are the same, so the outputs stay bit-identical.Probe `code/scripts/probe_conv512.py` (real weights, random inputs, one trace of 8 calls, best of 3; logs`logs/bevdet/opt_r6/c512_*`, `dec_*`):
| conv (model shape) | base (ttnn's grid) | transposed | bits | used ||---|---|---|---|---|| DepthNet / FPN 512 -> 512 3x3 [6, 16, 44] | 258 us DRAM in / out, 232 chained (8 x 10) | **215 / 187** (12 x 8) | identical | R6.1 || BEV neck conv.3 512 -> 512 [64, 64] | 242 / 217 (8 x 10) | **216 / 188** (ttnn's own transposed grid = 12 x 8) | identical | R6.1 || BEV neck conv.0 800 -> 512 [64, 64] | 384 | **334** (ttnn's transposed grid) | identical | R6.1 || layer-3 conv2 256 -> 256 [6, 16, 44] | 98 / 80 | **82 / 68** (12 x 8) | identical | R6.3 || layer-4 conv2 512 -> 512 [6, 8, 22] | 88 / 79 | 108 / 98 (33 tile rows: 3 per column on 11 columns vs 4 on 9 rows) | identical | no || CustomResNet stage 0 160 -> 160 [64, 64] | 67 / 56 (5 x 10) | **60 / 48** (12 x 5) | identical | R6.2 || CustomResNet stage 0 first conv 864 -> 160 / s2 | 288 | **252** | identical | R6.2 (merged with the projection) || CustomResNet stages 1-2 | 51 / 63 | 51 / 142 | identical | no || FPN_LSS `up2.1` 512 -> 256 [128, 128] (DRAM-sliced) | 613 | 566 | **57 values differ** | no (would need the gates) |
**Same-session alternating A/Bs** (`job_ab.sh`; one `bench.py` process per arm, 60 iterations; ETH, 1 CQ, 12x10;b2b device ms, e2e `model()` p50 ms):
| A/B (load) | arms | b2b frame (encode / decode) | e2e synthetic / PandaSet / nuScenes + poses ||---|---|---|---|| `ts` R6.1 (7.6-8.3) | `TSHARD=none` x2 | 10.574 / 10.577 (7.264 / 3.069; 7.278 / 3.082) | 31.7 / 41.7 / 39.8; 31.4 / 41.0 / 39.3 || | `TSHARD=enc` | 10.227 (6.944 / 3.117) | 30.5 / 40.6 / 40.3 || | `TSHARD=all` x2 | **10.136 / 10.117** (6.931 / 3.030; 6.927 / 2.990) | 29.4 / 40.7 / 39.1; 30.4 / 40.9 / 39.7 || `ch` R6.2 + R6.3 (5.7-6.7) | `DEC_CHAIN=0 L3T=0` x2 | 10.114 / 10.127 (6.961 / 2.976; 6.926 / 2.997) | 30.0 / 41.6 / 40.9; 31.7 / 41.9 / 39.4 || | `DEC_CHAIN=0` | 9.989 (6.790 / 3.015) | 30.8 / 41.0 / 39.3 || | `L3T=0` | 10.052 (6.929 / 2.950) | 30.8 / 42.1 / 41.1 || | both on x2 | **9.992 / 10.013** (6.791 / 2.946; 6.802 / 2.959) | 30.2 / 40.5 / 39.6; 28.6 / 40.5 / 37.7 || `rs` R6.4 (6.9-7.9; PandaSet + synthetic) | `HOST_RESIZE=cv2` x3 | 9.965 / 9.899 / 9.899 | PandaSet 41.0 / 41.7 / 40.0 (host_pre 13.2 / 13.0 / 12.9); synthetic 31.4 / 29.2 / 30.1 || | `HOST_RESIZE=gather` x3 | 9.930 / 9.912 / 9.950 | PandaSet **35.4 / 36.8 / 35.7** (host_pre **7.3 / 7.2 / 7.2**); synthetic 30.2 / 31.7 / 31.3 || `fin` round 5 vs round 6 (6.7-7.3) | round 5 (`TSHARD=none DEC_CHAIN=0 L3T=0 HOST_RESIZE=cv2`) x2 | 10.575 / 10.580 (7.264 / 3.081; 7.285 / 3.096); with ego motion 15.36 | 31.7 / 42.4 / 41.3; 31.1 / 41.9 / 38.6 || | round 6 defaults x2 | **9.970 / 9.977** (6.807 / 2.967; 6.793 / 2.949); with ego motion **14.69** | 31.1 / **36.4** / 38.8; 30.9 / **36.4** / 40.4 |
| step | what | measured | accuracy | knob (revert) ||---|---|---|---|---|| R6.1 | **Transposed block sharding of the large 3x3 convs** (`tt/tshard.py`; `BEVDET_TSHARD=all`): the eight 512 -> 512 convs (CustomFPN fpn conv, DepthNet reduce, the 3 BasicBlocks) with `override_sharding_config` + `transpose_shards` on (grid columns) x (largest divisor of the channel tiles that fits the grid rows) = 12 x 8; the DN_L1 stream `d` and the sharded adds follow the convs' COL_MAJOR shards (`t_mc`), the ASPP branches get the stream back in its ROW_MAJOR sharding (one reshard, 4.9 us); the BEV neck conv.0 / conv.3 with ttnn's own transposed grid, conv.0 -> conv.3 chained on L1 (no S2I / I2S). The grid comes from `compute_with_storage_grid_size` (WORKER dispatch: 11 x 8) | A/B b2b **10.574 / 10.577 -> 10.136 / 10.117 ms** (`enc` alone 10.227); profile: the 512 -> 512 convs **222.7 -> 178.1 us** each | **bit-identical**: encoder + decoder taps 0 differing values (`eq_tshard.log`) | `BEVDET_TSHARD=none` (or `enc`) || R6.2 | **CustomResNet chaining** (`BEVDET_DEC_CHAIN=1`, `tt/bev_decoder.py`): every BasicBlock's conv1 leaves its output in its L1 shards and conv2 reads them (`ChainedConv`: L1 path on the input's own sharding), stage 0 (128 tile rows x 160 channels: 5 x 10 cores) transposed to 12 x 5 incl. the merged first conv | decode b2b 3.015 -> **2.946 / 2.959 ms** (-0.06) | **bit-identical** (`eq_chain.log`) | `BEVDET_DEC_CHAIN=0` || R6.3 | **ResNet-50 layer 3 transposed** (`BEVDET_L3T=1`, `tt/l1res.py`): the L1-resident stream in `t_mc` shards, the conv1 / conv3 2D-multicast linears with `transpose_mcast` (M over the 12 columns, N over 8 rows, the same K block `STOCK_KB`), conv2 COL_MAJOR 12 x 8; the last block's output moved back to the 8 x 10 ROW_MAJOR sharding that layer 4 and the FPN lateral read (one reshard, 9.1 us) | encode b2b 6.93 -> **6.79 ms** (-0.14); per block conv1 29.2 -> 24.6, conv2 70.3 -> 58.5, conv3 34.4 -> 28.8 us | **bit-identical** (`eq_l3t.log`, 36 encoder taps) | `BEVDET_L3T=0` || R6.4 | **Host resize at the crop's pixels** (`BEVDET_HOST_RESIZE=gather`, `host/fast.py`): for images that are not 1600x900 the twin no longer runs the whole `cv2.resize` (1.44 M pixels) and then gathers the 256 x 704 crop: `_resize_gather_kernel` (numba, parallel) computes `cv::resize` INTER_LINEAR at the crop's pixels only with OpenCV's 8-bit fixed point (float32 source coordinates, 11-bit weights, horizontal sums exact in int32, the vertical step as OpenCV's SIMD path `((S0 >> 4) * b0 >> 16) + ((S1 >> 4) * b1 >> 16) + 2 >> 2`; the scalar rounding `(.. + 2^21) >> 22` differs in ~0.5 M values). The plan of each source size is self-checked once against cv2 on a random image (every crop pixel; on a mismatch that size keeps the cv2 path), and the 1920x1080 plan is built at model load (`warm_up`) | PandaSet host_pre **13.0 -> 7.2 ms**, e2e p50 **40.0-41.7 -> 35.4-36.8 ms** (`rs`); per camera 0.73 ms (8 threads) instead of ~1.8 ms resize + gather | **bit-exact**: host tests vs the cv2 / numpy oracle on 1080x1920, 1200x1920, 720x1280, 901x1599, 1080x1440 x RGB / BGR (`test_fast_host.py`) | `BEVDET_HOST_RESIZE=cv2` || R6.5 | **K-IN stem for all cameras at once** (one K-IN program with N = 6 x 256 x 704 and ROW0 = 0, one stem conv and one max pool with batch 6, no concat): bit-identical (watcher run clean, `sb_watcher.log`, `eq_sb.log`) | `sb`: encode b2b 6.780 / 6.797 (per camera) vs 6.789 / 6.799 (batched): **no gain** | bit-identical | **not kept** (code removed; `stem_batch_attempt.patch`) |
**`mmres_k` anatomy** (`anat`, the kernel's debug defines on all 7 layer-1 / layer-2 programs, outputs wrong; b2bencode): default 6.760 ms; without the matmuls 6.653 (-0.11), without the activation reads 6.627 (-0.13), withoutthe output writes **6.394 (-0.37)**, without the weight reads 6.617 (-0.14). The programs are bound by the residualstream's DRAM traffic (layer 1: 34.6 MB read + 34.6 MB written per block), not by the FPU; only an L1-resident streamremoves it, which does not fit next to layer 1's conv2 buffers (R5.4) and needs streamed weights on layer 2.
**Profile at the round-6 defaults** (Tracy, `profile_r6_reports.tar.zst`, `profile_r6_summary.txt`):- `encode`: 189 programs, kernel sum **6,713 us** (7,212): Conv2d 3,042 (the 512 -> 512 convs 8 x 178.1, the ASPP dilated convs 2 x 144), `mmres_k` + `kin_u8` 1,347, Matmul 1,123 (layer3.0 conv1 150 from DRAM), I2S 257, halo 254, pool 161, S2I 156, binary 151, concat 75, reshard 28.- `decode`: 104 programs (116), **2,826 us** (3,020): Conv2d 1,775 (`up2.1` 2 x 245 DRAM-sliced), concat 181 (`bev_in` 145), I2S 167, `upk` 160, S2I 108, `out_conv` 100, halo 83, padded slices 71.- `push_x` 0.26 ms (unchanged).
**Final gates at the new defaults** (`job_final6.sh`): `test_pcc_device.py`, `test_e2e_device.py`,`test_streams_device.py` read-only (`TTAW_GATES_READONLY=1`), plus `test_kin_device.py`, `test_mmres_k_device.py`,`test_conv_l1_device.py` (with every encoder knob incl. TSHARD / L3T) and `test_dec_l1_device.py` (TSHARD + DEC_CHAIN):**34 passed**, the gate files' md5 unchanged, every printed accuracy value identical to round 5 (`gates_final6.log`against `opt_r5/gates_final5.log`: only the timing fields differ).
## Round 5 (2026-10-14): TILE up-sampling kernel, weight multicast in `mmres_k`, layers 1-2 conv2 <-> `mmres_k` on L1
Measured first: the round-4 profile (`opt_r4/profile_r4_reports.tar.zst`) put the FPN_LSS up-samplings at 0.65 ms(x2 of the 64² x 512 neck output: untilize 21 + `grid_sample` 391 + tilize 77 us; x4 of the 16² x 640 F2: 3 + 127 +27 us) and the layers 1-2 `mmres_k` programs at 1.95 ms (245-310 / 125-296 us each). Per program the `mmres_k`weights were read from DRAM by every one of the 120 cores (layer 2: 0.5-1 MB of fp32 weights per core, 61-123 MBper program, more than its activations), and the layer 1-2 conv2 outputs went to DRAM (S2I) only for `mmres_k` toread them back, while the next conv1 (computed inside `mmres_k`) went to DRAM only to be re-sharded (I2S) for thenext conv2. Logs: `logs/bevdet/opt_r5/`.
**Same-session alternating A/B** (`job_ab.sh fin`; one `bench.py` process per arm, 60 iterations, 3 inputs; ETH, 1 CQ,12×10; host load 6.9-8.7). Device b2b and e2e `model()` p50 in ms; the e2e column also gives `host_pre` p50 becauseother agents' host jobs moved it between 3.6 and 31.8 ms within the session:
| arm | knobs | b2b frame (encode / decode) | frame with ego motion | one encode replay | synthetic e2e / host_pre | PandaSet | nuScenes + poses ||---|---|---|---:|---:|---|---|---|| 1 / 7 (round 4) | `UPSAMPLE=grid MMRES_MCAST=0 RES_L1=0` | 11.962 / 11.968 (8.166 / 3.532) | 16.77 | 8.20 / 8.21 | 58.2 / 18.3, 53.3 / 17.1 | 65.7 / 31.8, 67.7 / 30.9 | 62.1 / 21.1, 68.0 / 13.3 || 3 | `UPSAMPLE=grid` | 11.052 (7.278 / 3.579) | 15.85 | 7.29 | 52.8 / 18.3 | 76.3 / 26.3 | 69.0 / 3.9 || 4 | `MMRES_MCAST=0` | 11.114 (7.793 / 3.062) | 15.89 | 7.81 | 52.5 / 4.8 | 64.1 / 14.9 | 58.6 / 3.6 || 5 | `RES_L1=0` | 10.991 (7.629 / 3.068) | 15.86 | 7.65 | 41.0 / 17.9 | 63.9 / 14.9 | 63.1 / 3.7 || 2 / 6 | all on (now default) | **10.573 / 10.843** (7.273 / 3.082; 7.469 / 3.156) | **15.36 / 15.44** | **7.28 / 7.30** | 40.9 / 4.1, 46.2 / 17.4 | 70.5 / 31.5, 74.9 / 29.5 | 59.9 / 16.6, 69.6 / 21.6 |
Attribution (each knob off against arm 2): **R5.1 -0.48 ms (decode 3.58 -> 3.08), R5.2 -0.54 ms (encode 7.79 ->7.27), R5.3 -0.42 ms (encode 7.63 -> 7.27)**; the round: **11.96 -> 10.57 ms b2b (-11.6 %; the second default arm10.84: its b2b encode 7.47 against a single-replay encode of 7.30 as in arm 2, a b2b sampling outlier), 16.77 ->15.36 ms with ego motion**. The e2e p50 cannot resolve a ~1.4 ms change in this session: the host pre-processing ofthe same frames swung by 28 ms between arms (host load from other agents' jobs). The device part of the e2e (theencode replay) moved 8.20 -> 7.29 ms.
| step | what | b2b frame | accuracy | knob (revert) ||---|---|---|---|---|| R5.1 | **FPN_LSS up-sampling in TILE** (`tt/upsample_k.py`, kernels `upk_{reader,compute,writer}.cpp`, `BEVDET_UPSAMPLE=kernel`): one `generic_op` per resize, work unit (channel tile, output row): the reader fetches the two input rows as whole bf16 tiles (or, when w < 32, the tile holding the row: R = 32 / w rows per tile and the interpolation tile of that row slot); the compute kernel runs the W direction as FPU matmuls `A_w[wt, k] @ x_k` into two fp32 DEST tiles (HiFi4; x bf16 is exact in SrcA), then the H lerp `D0 * a0 + D1 * a1` on the SFPU in fp32 and an RNE typecast to bf16. Row table (h0, h1, a0, a1 bits) as CT args (`kernel_compile_time_args[]` indexed at run time), `A_w` fp32 tiles resident per core, no per-core RT args (P3). Probe (`probe_upk.py`, random maps, traced): **x2 0.496 -> 0.119 ms, x4 0.164 -> 0.046 ms**; in the model profile 126.5 + 39.0 us replace 489 + 157 us (no untilize / tilize / RM reshape) | 11.052 -> **10.573 ms** (decode 3.58 -> 3.08) | **not bit-identical** (fp32 instead of bf16-truncated weights): max error against the float64 interpolation 0.016-0.026 (grid_sample 0.057-0.066), mean error ~1e-6 (grid_sample +2e-5); every frozen gate green read-only, every head PCC up (e.g. f38 `head.reg_0` 0.999785 -> 0.999799), sample0 51 -> **50 / 52** (gate 50), nuScenes scene-0103 recall 0.9897 -> 0.9919, scene-0916 0.9897 -> 0.9892, PandaSet f39 0.9958 -> 0.9915 | `BEVDET_UPSAMPLE=grid` || R5.1 (terms) | the `A_w` weights as **one TF32 term** (`BEVDET_UPK_TERMS=1`, default) instead of two (fp32-exact): with two terms and the x4 kernel, sample0 gives 49 / 52 (**FAIL**, gate 50; `gates_final5` of try 1 and `gvar_up4_t2.log`); the x2 kernel alone with two terms 50 / 52 (`gvar_up2_t2.log`), both kernels with one term 50 / 52 (`gvar_kernel_t1.log`, and the final gates) | -0.48 ms with either (two terms: `ab_a1`, 11.416 -> 10.935; one term: `ab_fin`) | sample0 sits at its gate: more exact interpolation (higher PCC everywhere) moves boxes across the 0.2 score threshold both ways | `BEVDET_UPK_TERMS=2` || R5.2 | **`mmres_k` weight multicast** (`BEVDET_MMRES_MCAST=1`, the vendored kernel's `MMRES_MCAST` path, bevformer-p150 D20): the first core of each grid row reads the resident weights / biases once and multicasts them along the row (ready / valid semaphore handshake), instead of 120 cores each reading all of them from DRAM. Brought up with the hang protocol: `test_mmres_k_device.py -k tiny` under `TT_METAL_WATCHER=2`, then every model shape | 11.114 -> **10.573 ms** (`mmres_k` 2.03 -> 1.46 ms in the profile) | **bit-identical**: all 9 `test_mmres_k_device.py` cases (incl. MODE 1 and the next conv1) with multicast against the stock tail (`mc_all.log`), encoder taps 0 differing values (`eq5_mcast.log`) | `BEVDET_MMRES_MCAST=0` || R5.3 | **Layers 1-2: conv2 <-> `mmres_k` on L1 shards** (`BEVDET_RES_L1=1`, `tt/backbone.py`): conv2 leaves its output in its L1 height shards (`output_memory_config=None`) and `mmres_k` reads them through its tensor accessor (no S2I); when the next block's conv2 is a stride-1 conv of the same stage, the next conv1 (computed inside `mmres_k`) is written straight into a tensor with this conv2's output shard spec, which is exactly the next conv2's input spec (no I2S). Removes 7 S2I (29 / 16 us) and 5 I2S (22 / 12 us) | 10.991 -> **10.573 ms** (encode 7.63 -> 7.27) | **bit-identical**: encoder taps eager x2, 36 / 36 with 0 differing values (`eq_resl1.log`; watcher run `eq_resl1_watcher.log` clean) | `BEVDET_RES_L1=0` |
**Profile at the round-5 defaults** (Tracy, `profile_r5_reports.tar.zst`, `profile_r5_summary.txt`):- `encode`: 187 programs (204), kernel sum **7,212 us** (8,123): Conv2d 3,473 (the eight 512 -> 512 3x3 DepthNet / FPN convs 8 x 222.7 at 54 % FPU on 80 cores), `mmres_k` + `kin_u8` 1,356 (layer 1: 202 / 197 / 259 us, layer 2: 150 / 148 / 150 / 116 us), Matmul 1,173 (layer3.0 conv1 148 us from DRAM), I2S 268 (layer2.0: 43 + its projection's 86), halo 266, pool 162, S2I 155, binary 153, concat 74.- `decode`: 116 programs (120), **3,020 us** (3,500): Conv2d 1,901, I2S 201, concat 179 (`bev_in` 144), `upk` 166, S2I 128, `out_conv` matmul 100, halo 85, padded slices 71.- `push_x` 0.26 ms (unchanged).
**Final gates at the new defaults** (`job_final5.sh`): `test_pcc_device.py`, `test_e2e_device.py`,`test_streams_device.py` read-only (`TTAW_GATES_READONLY=1`), plus `test_kin_device.py`, `test_mmres_k_device.py`(multicast), `test_conv_l1_device.py` (with MM1X1, the tuning, L1RES, DN_L1, MCAST, RES_L1) and`test_dec_l1_device.py`: **34 passed**; the gate files' md5 is unchanged. The values that moved (all R5.1; R5.2 / R5.3are bit-identical) are listed in the R5.1 row; `gates_final5.log` against `opt_r4/gates_final4.log`. The first gaterun (`try1/gates_final5.log`, two TF32 terms) failed `sample0.recall` (49 / 52, gate 50).
**Bring-up:** `upk` smallest shapes first under `TT_METAL_WATCHER=2` (1 core, then the grid; R = 1 and R = 2), eager x2and a 2-call trace equal (`upk_small*.log`), then the model shapes (`upk_model*.log`); `mmres_k` multicast tiny underthe watcher, then all shapes; `RES_L1` encoder equality under the watcher, then plain. No hang, timeout or reset.
## Round 4 (2026-10-14): L1-resident layers 3-4, the DepthNet chain on L1 shards, the ring push as one slice
Measured first: the round-3 profile (`opt_r3/profile_r3_reports.tar.zst`, per-op listing) showed every layer-3 /layer-4 bottleneck spending more than half of its time outside the 3x3 conv: a layer-3 identity block was conv1`linear` 69.6 us (DRAM in / out) + I2S 7.4 + halo / move 5.5 + conv2 70.4 + S2I 7.5 + conv3 62.4 (stock 1x1 on DRAM)+ a DRAM `add` + ReLU of 4224 x 1024 bf16 60.5 us (DRAM bound) = 283 us. A probe (`code/scripts/probe_l1res.py`,random weights, real shapes) ran one identity block both ways: **layer 3 288.5 -> 144.0 us, layer 4 238.2 -> 175.3us, 0 differing values in conv1 / conv2 / conv3 / output** (`probe_l1res_l3.log`). Logs: `logs/bevdet/opt_r4/`.
**Same-session alternating A/B** (`job_ab.sh a2`; one `bench.py` process per arm, 60 iterations, 3 inputs; ETH, 1 CQ,12×10; load 6.0-8.7). Device b2b and e2e `model()` p50 (p99) in ms:
| arm | knobs | b2b frame (encode / decode / push) | frame with ego motion | synthetic | PandaSet | nuScenes + poses ||---|---|---|---:|---:|---:|---:|| 1 / 7 (round 3) | `L1RES=0 DN_L1=0 PUSH_X=0` | 13.486 / 13.484 (9.545 / 3.534 / 0.409) | 18.16 | 32.5 / 33.9 | 43.0 / 44.1 | 42.4 / 42.7 || 3 | `L1RES=0` | 13.050 (9.256 / 3.532 / push_x 0.263) | 17.87 | 33.9 | 43.3 | 43.2 || 4 | `DN_L1=0` | 12.250 (8.463 / 3.534 / 0.263) | 17.06 | 32.7 | 43.5 | 42.1 || 5 | `PUSH_X=0` | 12.110 (8.171 / 3.534 / push 0.410) | 16.77 | 32.1 | 43.0 | 41.4 || 2 / 6 | all on (now default) | **11.975 / 11.972** (8.167 / 3.535 / push_x 0.263) | **16.77** | **31.7 / 32.4** (40.1 / 36.8) | **42.4 / 43.2** | **42.2 / 39.0** |
Attribution (each knob off against the default, same session): **R4.1 -1.08 ms, R4.2 -0.28 ms, R4.3 -0.14 ms**. Thee2e moves by ~1 ms only: the host BEVPool round trip (~10 ms) and the host stages dominate it (MK-2).
| step | what | b2b frame | e2e p50 | accuracy | knob (revert) ||---|---|---|---|---|---|| R4.1 | **ResNet-50 layers 3-4 L1-resident** (`tt/l1res.py`, `BEVDET_L1RES=1`): each bottleneck keeps its maps block-sharded in L1 on 8 x gy cores (gy = the rows ttnn's own conv grid uses: 10 for 4224 rows, 9 for 1056), i.e. exactly the shards ttnn's block-sharded conv2 picks. conv1 / conv3 run as 2D-multicast `ttnn.linear` on the sharded activations with sharded outputs and the ReLU in the packer, each with ttnn's K block for the shape (`STOCK_KB`); conv2 reads conv1's shards and leaves its output sharded; `relu(conv3 + identity)` is one sharded `add` (60.5 -> 2.5 us). The FPN laterals read the stage outputs' shards (`Linear1x1`, sharded in0). The strided layer-4.0 projection reads a DRAM copy: from the stream's 4-tile channel shards it picks another K split than from DRAM (3-tile shards of 1056 padded channels) and **changed 71 values** (`debug_l1res.log`, the only difference found); with the copy everything is bit-identical. Profile: a layer-3 identity block **283 -> 140 us** (conv1 34.3, halo 3.3, conv2 70.3, conv3 29.2, add 2.5), a layer-4 one 238 -> 161 us | 13.050 -> **11.975 ms** (encode 9.26 -> 8.17) | within noise | **bit-identical**: per-block check on the real weights (`debug_l1res.log`), encoder taps eager ×2 0 differing values (`eq4_enc2.log`) | `BEVDET_L1RES=0` || R4.2 | **The neck's fpn conv -> DepthNet reduce and the 3 BasicBlocks on L1 shards** (`tt/image_encoder.py`, `BEVDET_DN_L1=1`): the fpn conv's output stays in its L1 shards for the reduce conv; the gated map `d` is sharded once, then conv1 -> conv2 -> sharded `add` + ReLU -> the next conv1 without a DRAM round trip; the ASPP 3x3 branches read the last block's shards, the 1x1 branch and the GAP mean a DRAM copy. Removes 7 I2S + 7 S2I (~12 us each) and the 3 DRAM adds (30 -> 2 us) | 12.250 -> **11.975 ms** (encode 8.46 -> 8.17) | within noise | **bit-identical** (`eq4_dn.log`: every DepthNet tap, depth, feat, eager ×2) | `BEVDET_DN_L1=0` || R4.3 | **Ring push as one slice of the decode input** (`tt/model.py`, `BEVDET_PUSH_X=1`): after an identity `decode` the new ring is `bev_in[..., :768]` = cat(curr, ring[..., :672]), which the decode trace has just built. The decode input of the captured identity `decode` stays allocated (`_x_hold`; every replay rewrites the same buffer), and the new variant `push_x` is one `ttnn.slice(..., output_tensor=<ring>)`: no tilize, concat or copy program. The host picks `push_x` only right after an identity `decode` (`TtBEVDet.after_variant`); fresh / moving frames keep `push` / `fill`. (`ttnn.concat` does not take an output tensor in this tt-metal: `TT_FATAL optional output tensor currently unsupported`, the first try, `ab_a1`) | push 0.410 -> **0.263 ms**; frame 12.110 -> 11.975 | within noise | **bit-exact** by construction (the same bf16 values; the streams / e2e gates replay it through the API) | `BEVDET_PUSH_X=0` |
**Profile at the round-4 defaults** (Tracy, `profile_r4_reports.tar.zst`, `profile_r4_summary.txt`):- `encode`: 204 programs (252), kernel sum **8,123 us** (9,502): Conv2d 3,470, `mmres_k` + `kin_u8` 2,028, Matmul 1,176 (1,707), I2S / S2I 649 (952), halo 265, pool 161, binary 153 (671), concat 74, move 55, reshard 12.- `decode`: unchanged, 3,500 us: Conv2d 1,900, the FPN_LSS `grid_sample`s 518, I2S / S2I 330, concat 180, tilize / untilize 164, the `out_conv` 1x1 matmul 101.- `push_x`: one slice, 0.263 ms b2b (push 0.409).
**Final gates at the new defaults** (`job_final4.sh`): `test_pcc_device.py`, `test_e2e_device.py`,`test_streams_device.py` read-only (`TTAW_GATES_READONLY=1`), plus `test_kin_device.py`, `test_mmres_k_device.py`,`test_conv_l1_device.py` (with MM1X1, the tuning, L1RES and DN_L1) and `test_dec_l1_device.py`: **34 passed**. Everyprinted PCC / agreement value and every equality count is identical to round 3 (`gates_final4.log` vs`opt_r3/gates_final3.log`; only the timing fields differ), and the gate files' md5 is unchanged. The first gate run(`gates_final4_try1.log`) errored in `test_pcc_device.py`'s setup: its debug-tap variant held the L1-sharded taps(layer 3 / 4, neck, DepthNet blocks) and the later convs' circular buffers clashed with them (`TT_THROW ... clash withL1 buffers`, at program creation, nothing enqueued). The encoder now records sharded taps as DRAM copies.
**Bring-up:** stock ttnn ops only, no new kernel, no hang, timeout or reset.
## Round 3 (2026-10-14): conv configs (double buffering, explicit 1x1 configs, height-sharded head conv)
Measured first, per conv: `code/scripts/probe_conv.py` rebuilds every kxk conv of the model at its real shape andsettled config (hooked from one eager run of the encoder / decoder) and sweeps `Conv2dConfig` candidates on randominputs: activation / weight double buffering, shard layouts, activation block heights, `full_inner_dim`, splitreader, activation reuse; per candidate the output bit for bit against the settled config and the device time percall (trace of 8 calls incl. the conv's I2S / halo / S2I; `logs/bevdet/opt_r3/probe_conv_{enc,dec1,dec2}.{log,json}`).Nothing in the port had double buffering on. Over the 30 distinct convs (49 calls), the sum of standalone times wentfrom 9.70 ms (settled) to 7.53 ms with both double buffers, which was within 0.1 % of the best bit-identical candidateper conv. Two convs were exceptions:- layer2.0's 1x1 / stride-2 projection: weight DB **changed the output** (2.6 M values) and DB on both did not build. It is excluded.- `head.merged2`: the height-sharded L1 form was 4.7× faster but not bit-identical (R3.3).
Logs: `logs/bevdet/opt_r3/`.
**Same-session alternating A/B** (`job_ab.sh r1`; one `bench.py` process per arm, 60 iterations, 3 inputs; ETH, 1 CQ,12×10; load 6.4-8.2). Device b2b, e2e `model()` p50 (p99) in ms:
| arm | knobs | b2b frame (encode / decode / push) | frame with ego motion | synthetic | PandaSet | nuScenes + poses ||---|---|---|---:|---:|---:|---:|| 1 / 6 (round 2) | `CONV_TUNE=0 MM1X1=0 HEAD2=dram` | 16.261 / 16.262 (10.935 / 4.922 / 0.408) | 20.93 | 35.8 / 37.3 | 47.9 / 46.9 | 45.8 / 45.1 || 2 / 5 | `CONV_TUNE=1 MM1X1=1 HEAD2=dram` | 13.834 / 13.832 (9.547 / 3.882 / 0.410) | 18.50 | 34.8 / 34.5 | 45.0 / 44.9 | 43.3 / 43.3 || 3 / 4 | `CONV_TUNE=1 MM1X1=1 HEAD2=hs` (now default) | **13.485 / 13.484** (9.548 / 3.533 / 0.410) | **18.15** | **34.7 / 34.6** (42.9 / 40.4) | **43.6 / 43.8** | **43.1 / 42.9** |
Attribution session (`job_ab.sh r2`, arms around the new default, load 6.4-7.8): default **13.482**; `MM1X1=0`13.736 / 13.734 (so R3.2 is -0.25 ms, all in `encode`); `CONV_TUNE=0` 15.458 / 15.454 (so R3.1 is -1.97 ms: encode10.69 -> 9.55, decode 4.36 -> 3.53).
| step | what | b2b frame | e2e p50 | accuracy | knob (revert) ||---|---|---|---|---|---|| R3.1 | **Conv double buffering** (`tt/conv_tune.py`, `BEVDET_CONV_TUNE=1`): `enable_act_double_buffer` + `enable_weights_double_buffer` on every kxk conv (36 encoder + 19 decoder programs), so the reader fetches the next activation / weight block while the compute kernel multiplies the current one. The blocking and the K order are unchanged. Excluded: the K-IN stem conv (its own L1 shards) and layer2.0's projection (above). On the L1 path, `L1Fallback` drops the overrides first if a conv's larger circular buffers do not fit L1 (none did). Standalone per conv: e.g. the 8 DepthNet / FPN 512 -> 512 3x3 convs 329 -> 258 us, FPN_LSS `up2.1` 888 -> 611, `neck.conv.0` 487 -> 383, layer-3 3x3 138 -> 97 | 15.456 -> **13.482 ms** (attribution session) | within host noise (-1 to -2 ms) | **bit-identical**: encoder taps (stem, layers 1-4, neck, every DepthNet tap, depth, feat) and decoder taps + fp32 heads, eager ×2, 0 differing values (`eq3_{enc,dec}.log`) | `BEVDET_CONV_TUNE=0` || R3.2 | **Stock 1x1 convs as `ttnn.linear`** (`tt/linear1x1.py`, `BEVDET_MM1X1=1`): layer1.0 conv1, layer3.0-5 conv1, layer4.0-2 conv1 and both FPN laterals. Each uses the fastest bit-identical `probe_mm.py` config (round 2: same K block as ttnn's conv, ReLU in the packer instead of a separate unary program). The layer-3/4 conv3 shapes are faster stock and keep `ttnn.conv2d` | 13.735 -> **13.482 ms** | within noise | **bit-identical** (`mmeq.log`, `eq3_enc.log`: all 12 run `linear`, every tap 0 differing values) | `BEVDET_MM1X1=0` || R3.3 | **`head.merged2` height-sharded on L1** (`BEVDET_HEAD2=hs`, `tt/bev_decoder.py`): the block-diagonal 3x3 384 -> 20 (32 padded) conv ran DRAM-sliced and block-sharded: 2 slices, 12 output-column groups for one tile of outputs, 2 × 322 us at ~5.6 TFLOP/s, plus slice / slice-write programs. It now runs on the L1 path, height-sharded with 64-row activation blocks: the whole 3,456-long K row on each core, standalone 718 -> 153 us (`probe_conv_dec2.log`). With DB on the DRAM path (R3.1 alone) it is 501 us, bit-identical | 13.833 -> **13.484 ms** (decode 3.88 -> 3.53) | within noise | **not bit-identical**: 62 of 524k fp32 head values differ in the last bits (fp32 partial sums over a different K split). Frozen gates read-only with `HEAD2=hs`: **20 passed, every printed PCC / agreement / recall value identical** to round 2 (`gates_head2hs.log`); gate files' md5 unchanged | `BEVDET_HEAD2=dram` |
**Profile at the round-3 defaults** (Tracy, `profile_r3_reports.tar.zst`, `profile_r3_summary.txt`):- `encode`: 252 programs, kernel sum **9,502 µs** (10,869 in round 2): - Conv2d 3,469 (4,614); - `mmres_k` + `kin_u8` 2,019; - Matmul 1,707 (now incl. the 12 `linear`s; the separate ReLU programs are gone: Unary 187 -> 7); - adds 671; - I2S / S2I 952; - halo 270; - pool 162.- `decode`: 120 programs, **3,502 µs** (4,890): - Conv2d 1,900 (3,284); - the FPN_LSS `grid_sample`s 518; - I2S / S2I 330; - concat 180; - tilize / untilize 167; - `up2.1`'s slices 130.- `push`: 286 µs.
**Final gates at the new defaults** (`job_final3.sh`): `test_pcc_device.py`, `test_e2e_device.py`,`test_streams_device.py` read-only (`TTAW_GATES_READONLY=1`), plus `test_kin_device.py`, `test_mmres_k_device.py`,`test_conv_l1_device.py` (with `MM1X1` and the tuning) and `test_dec_l1_device.py` (with the tuning): **34 passed**.Every printed PCC / agreement value and every equality count is identical to round 2 (`gates_final3.log` vs`opt_r2/gates_final2.log`), and the gate files' md5 is unchanged. The revert paths ran in the A/B arms.
**Bring-up:** stock ttnn ops only, no new kernel. Rejected configs failed at program creation (CB / L1 clash), neveron the device. The probe's first decoder run exhausted L1_SMALL: cached programs kept their config tensors, whichstarved the later candidates. It now clears the program cache after each candidate. No hang, timeout or reset.
## Round 2 (2026-10-13): the image encoder on L1, fused bottleneck tails, the tile-column history ring
Plan items 3, 7 and 4 of [`OPT_PLAN.md`](OPT_PLAN.md). Every kept change is **bit-identical** (encoder taps anddecoder input compared bit for bit on the device; the frozen gates read-only print the same values as round 1).Logs: `logs/bevdet/opt_r2/`.
**Same-session alternating A/B** (`job_ab.sh`; one `bench.py` process per arm, 60 iterations, 3 inputs; ETH, 1 CQ,12×10). Device b2b per frame (encode / decode / push) and e2e `model()` p50 (p99) in ms. Session `r2` (load5.8-7.5, arm 8 18.9):
| arm | `CONV_L1` | `BACKBONE_RES` | b2b frame | encode | synthetic | PandaSet | nuScenes + poses ||---|---|---|---:|---:|---:|---:|---:|| 1 / 8 (round 1) | none | stock | 31.633 / 31.633 | 21.551 | 50.3 / 52.5 | 61.3 / 97.9 | 55.5 / 104.7 || 2 / 7 | all | stock | **23.097 / 23.096** | 12.942 | 42.5 / 43.5 | 51.8 / 53.7 | 47.7 / 49.9 || 3 / 6 | all | fused (all stages) | 22.899 / 22.901 | 12.751 | 41.8 / 42.3 | 52.2 / 51.6 | 47.3 / 45.6 || 4 / 5 | all | next (all stages) | 22.094 / 22.095 | 11.979 | 41.2 / 40.6 | 51.4 / 51.8 | 46.6 / 46.0 |
Session `r3` (load 6.9-10.2; e2e of arms 1-3 under the heaviest load):
| arm | `CONV_L1` | `BACKBONE_RES` | `RING` | b2b frame | encode / decode / push | frame with ego motion | synthetic | PandaSet | nuScenes + poses ||---|---|---|---|---:|---|---:|---:|---:|---:|| 1 / 8 | all | next | rm | 22.093 / 22.096 | 11.980 / 8.877 / 1.248 | 22.372 | 42.9 / 42.8 | 52.5 / 52.7 | 46.5 / 46.6 || 2 / 7 | all | next12 | rm | **21.041 / 21.043** | 10.939 / 8.871 / 1.246 | 21.324 | 45.1 / 40.1 | 61.3 / 50.3 | 47.3 / 44.5 || 3 / 6 | all | next12 | tile | **16.710 / 16.711** | 10.936 / **5.371 / 0.408** | 21.385 | 50.9 / **37.1** | 57.7 / **46.4** | 46.8 / 46.5 || 4 / 5 | all,dec | next12 | tile | 16.999 / 16.998 | 10.935 / 5.659 / 0.409 | 21.676 | 37.6 / 37.4 | 49.7 / 47.7 | 47.1 / 46.7 |
| step | what | b2b frame | e2e p50 | accuracy | knob (revert) ||---|---|---|---|---|---|| R2.1 | **Encoder kxk convs on ttnn's L1 path** (`tt/placement.py`, the yolox / streampetr `L1Fallback`: `Conv2dL1FullSliceConfig`, the op shards the DRAM input into L1 itself, output back to DRAM; activation-block retries, DRAM slicing as the first-call fallback). Groups `s1`-`s4` (the bottleneck 3x3 convs), `ds` (the stride-2 1x1 projections), `neck` (FPN 3x3), `dn` (DepthNet reduce / BasicBlocks / ASPP); `all` = these. All 30 convs settle on L1 at ttnn's own blocks. The DRAM-sliced path started every conv with `ttnn::reshape(x, [N, H, W, C])` and back (W = 176 / 88 / 44 / 22 are not tile multiples: real copies): 60 ReshapeView programs, 8.57 ms | **31.633 -> 23.097 ms** (encode 21.55 -> 12.94) | 50.3 -> 42.5 ms (synthetic), 61.3 -> 51.8 (PandaSet), 55.5 -> 47.7 (nuScenes) | **bit-identical**: every encoder tap (stem, layers 1-4, neck, DepthNet reduce / blocks / ASPP branches / logits, depth, feat) 0 differing values, eager ×2 (`test_conv_l1_device.py`, `l1eq_all.log`) | `BEVDET_CONV_L1=none` || R2.2 | **Fused bottleneck tails, `mmres_k`** (`tt/backbone.py`; `tt/mmres_k.py` + `kernels/mmres_k_{dm,compute}.cpp` vendored unchanged from bevformer-p150 `2313e77`): `relu(conv3(z) + idt)` in one `generic_op` per block, the stride-1 projection of layer1.0 inside it (MODE 1) and, with `next`, the following block's `relu(conv1(out))` from the rows just computed. The K block of each product equals the one ttnn's own 1x1 conv uses for that shape (`STOCK_KB`, from the round-1 profile: 2 on the 1D configs of layers 1-2, 1 on the 2D configs of layers 3-4). Profile (`profile_r2_summary.txt`): a layer-1 tail 246-311 µs against ~720 µs of stock conv3 + add + next conv1 + ReLU; a layer-2 tail ~292 µs against ~383; but layers 3 / 4 (fp32 conv3 weights split over 2 / 8 core groups, no multicast) 230 / 214 µs against 122 / 76 µs stock. `next12` (layers 1-2 only) keeps 3-4 stock | `all` (all stages) 23.097 -> 22.899 (fused) -> **22.094** (next); `next12` 22.093 -> **21.041** | within host noise (41-45 ms synthetic) | **bit-identical**: kernel vs the stock chain at every model shape eager ×2 + 2-call trace (`test_mmres_k_device.py`: tiny cases under `TT_METAL_WATCHER=2` first, then layers 1-4; 9 passed), encoder taps 0 differing values for `fused`, `next` and `next12` | `BEVDET_BACKBONE_RES=stock` || R2.3 | **History ring as the decoder input's tile columns** (`tt/bev_fusion.TtTileRing`, OPT_PLAN item 4): state `ring` [1, 1, 16384, 8·96] bf16 TILE, age j in channels [96 j, 96 j + 96), i.e. exactly GatherBEV's history columns when every AlignBEV transform is the identity (the Autoware node: no ego pose). Variants: `decode` (`bev_in = cat(tile(curr), ring)`), `decode_fresh` (zero history: a stream's first frame), `decode_move` (ego motion: the ring back to [8, H, W, C] ROW_MAJOR, then the old `grid_sample` gather), `push` = `cat(tile(curr), ring[..., :672])` (a 3-tile-column shift), `fill`. The host picks the decode variant per frame (`tile_decode_variant`); multi-stream banks swap the same state | **21.041 -> 16.710 ms** (decode 8.87 -> 5.37, push 1.25 -> 0.41); with ego motion 21.32 -> 21.39 (`decode_move` 9.15 -> 10.04: +0.89 for the re-layout, -0.84 on push) | synthetic 40.1 -> 37.1, PandaSet 50.3 -> 46.4 (second half of the session, load ~7) | **bit-identical**: frozen gates read-only with `RING=tile` 20 passed, every printed value equal to the `rm` run (incl. the PandaSet f40 moving-history frame through `decode_move`, the exact identity / fresh / reset slot checks of `test_alignbev_exact_cases`, push / fill exactness on the device state, replay == eager; `gates_tile.log`) | `BEVDET_RING=rm` || R2.4 | (not kept) **every BEV decoder conv on the L1 path** (`CONV_L1` group `decall`, session r3 arms 4 / 5) | 16.710 -> 16.999 ms (+0.29: decode 5.37 -> 5.66) | - | **not bit-identical**: `img_bev_encoder_neck.up2.1` and `head.merged2` only fit L1 with 256-row activation blocks and then change the outputs (864 / 5,297 values of `bev.neck` / heads, `deceq.log`); every other decoder conv is bit-identical on L1 | `decall` stays opt-in || R2.4b | **The 19 decoder convs that are bit-identical on L1** (`CONV_L1` group `dec`: CustomResNet, FPN_LSS conv.0 / conv.3, shared conv, head.merged1; `up2.1` and `head.merged2` stay DRAM-sliced). Session r4 (load 6.5-7.2): `all` / `all,dec` / `all,dec` / `all` | 16.710 / 16.709 -> **16.648 / 16.646 ms** (decode 5.37 -> 5.31) | within noise (35.9-37.1 ms synthetic) | **bit-identical** (`deceq_exact.log`: every decoder tap and the fp32 heads, eager ×2) | `BEVDET_CONV_L1=all` || R2.5 | **Peer-merged first convs of the CustomResNet stages** (`tt/bev_decoder.MergedFirstBlock`, `BEVDET_DEC_MERGE=1`): each stage's `conv1` (ReLU) and `downsample` (both 3x3 / stride 2 on the same input) as one conv with stacked output channels; the output split at the tile-aligned channel boundary and ReLU applied to the conv1 half (`relu(bf16(x)) == bf16(relu(x))`). Stage 0 reads the 864-channel `bev_in` once instead of twice (I2S 76 µs + conv 281 µs each). Session r5 (load 6.6-8.3): `0 / 1 / 1 / 0` | 16.648 / 16.647 -> **16.265 / 16.261 ms** (decode 5.31 -> 4.92) | 37.2 / 35.6 -> 42.2 / 35.0 ms synthetic (host noise) | **bit-identical** (`deceq_merge.log`: merged + `dec` L1 decoder vs the stock decoder, every tap and the heads, eager ×2) | `BEVDET_DEC_MERGE=0` || R2.6 | (not kept) **HiFi2** for every conv / linear (`BEVDET_PRECISION=HiFi2+fp32+l1acc:w=fp32`, OPT_PLAN item 8), session r5 arms 3 / 4 | 16.648 -> 14.393 / 14.391 ms (encode 10.93 -> 9.55, decode 5.31 -> 4.44) | 33.2-34.8 ms synthetic | **fails 2 frozen gates** (read-only, `gates_hifi2.log`): `head.reg_0` on the chained PandaSet f38 frame PCC 0.99753 < 0.998, sample0 recall 0.846 < 0.9615 (44 of 52 boxes) | rejected; per-segment variants below |
**Device profile at the new encoder** (Tracy, `CONV_L1=all BACKBONE_RES=next`, before `next12` / `tile`;`profile_r2_reports.tar.zst`, `profile_r2_summary.txt`): `encode` 253 programs (342 in round 1), kernel sum**11,933 µs** (21,440): Conv2d 4,617 (the 36 convs themselves), `mmres_k` + `kin_u8` 4,045, Matmul 1,237 (theremaining 1x1 convs), I2S / S2I 953, halo 268, adds 217, ReLU 188; **no ReshapeView left**. `decode` 140 programs,8,247 µs: AlignBEV `grid_sample` 1,452 (after a `fill`; 2,050 steady) + the 9-slot concat / permute / reshape /tilize 1,635 (the part R2.3 removes), decoder convs 3,603, the FPN_LSS upsampling `grid_sample` 517.
**Round-2 end, same session** (`ab_fin`: round-1 knobs `r1` / defaults / defaults / `r1`; load 5.9-8.9; p50 ms):
| arm | b2b frame (encode / decode / push) | frame with ego motion | synthetic e2e | PandaSet e2e | nuScenes + poses e2e | stages (synthetic): host_pre / encode replay / `api.bevpool` / decode replay / push / host_post ||---|---|---:|---:|---:|---:|---|| r1 | 31.635 (21.554 / 8.876 / 1.227) | 31.912 | 50.6 (54.7) | 59.7 (66.0) | 55.8 (70.6) | 3.3 / 21.6 / 7.3 / 8.9 / 1.3 / 3.2 || default | **16.264 (10.935 / 4.921 / 0.408)** | **20.935** | **34.9 (38.1)** | **45.0 (60.9)** | **44.7 (49.9)** | 3.5 / 11.0 / 6.7 / 5.0 / 0.45 / 1.6 || default | 16.263 | 20.937 | 36.3 (43.8) | 49.8 (67.8) | 47.8 (61.5) | || r1 | 31.635 | 31.914 | 50.8 (63.1) | 59.2 (69.5) | 57.6 (82.0) | |
**Profile at the round-2 end** (Tracy, defaults; `profile_r2final_reports.tar.zst`, `profile_r2final_summary.txt`):`encode` 262 programs, kernel sum **10,869 µs**: Conv2d 4,614 (36 convs), Matmul 1,751 (27 stock 1x1 convs incl. thelayer-3/4 tails), `mmres_k` + `kin_u8` 2,022, I2S / S2I 949 (around the L1 convs), adds 668, halo 269, ReLU 187,pool 161. `decode` 125 programs, **4,890 µs**: Conv2d 3,284, the two FPN_LSS upsampling `grid_sample`s 518, concat178, I2S / S2I 288, tilize 140. `push` 284 µs.
**Final gates at the defaults** (no `BEVDET_*` override, `job_r27.sh`): `test_pcc_device.py`, `test_e2e_device.py`,`test_streams_device.py` read-only (`TTAW_GATES_READONLY=1`) plus `test_kin_device.py`, `test_mmres_k_device.py`,`test_conv_l1_device.py`, `test_dec_l1_device.py`: **34 passed, every printed PCC / agreement value identical** toround 1 (`gates_final2.log` vs `gates_final.log`); gate files' md5 unchanged. Earlier in the round: `RING=tile`20 passed identical (`gates_tile.log`); `CONV_L1=all BACKBONE_RES=next` 33 passed identical (`gates_final.log`). Therevert paths ran in the A/B arms (`r1`: `CONV_L1=none BACKBONE_RES=stock RING=rm DEC_MERGE=0`).
**Measured, not kept (≤ 2 % or failing a gate):**- HiFi2 everywhere (R2.6): -2.26 ms, fails 2 gates; encoder-only HiFi2 fails `head.reg_0` (0.997787) and sample0 recall (0.923); decoder-only HiFi2 fails sample0 recall (0.904) (`gates_hifi2_{ENC,DEC}.log`).- HiFi3 everywhere: 16.261 -> 15.151 / 15.153 ms (`ab_r6`), fails `pandaset.score_abs_err` (0.189 > 0.05, `gates_hifi3.log`).- The remaining stock 1x1 convs as `ttnn.linear` with explicit bit-identical configs (same K block, ReLU fused; `code/scripts/probe_mm.py`, `probe_mm.log`): per shape 0.116 -> 0.071 ms (layer1.0 conv1), 0.197 -> 0.151 (layer3.0 conv1), 0.093 -> 0.072 (layer-3 conv1 ×5), 0.130 -> 0.108 (layer4.0 conv1), 0.085 -> 0.074 (layer-4 conv1 ×2); the conv3 shapes of layers 3-4 are faster stock. In total about -0.24 ms (1.5 % of the frame): left for a later round.
**Bring-up** (hang protocol): `mmres_k` is a vendored kernel but new shapes: the tiny cases (240 tile rows) under`TT_METAL_WATCHER=2` first (3 passed, no watcher finding), then the model shapes eager ×2 + 2-call trace, then thetraced graph in the gates. The L1 placement and the tile ring are stock ops. No hang, timeout or reset.
## Round 1 (2026-10-13): host twins and the uint8 image input
Plan items 2, 6 and 1 of [`OPT_PLAN.md`](OPT_PLAN.md), plus a host BEVPool twin (R1.4, not in the plan's list: theBEVPool moves to the device only with MK-2). Every change is **bit-identical**: the twins reproduce their oracles'float32 arithmetic step for step, and the K-IN u8 stem writes the host path's bf16 stem input bit for bit. Logs:`logs/bevdet/opt_r1/`.
**Same-session alternating A/B** (`job_ab.sh r1`: arms base, host, kin, kin, host, base; one `bench.py` process perarm, 60 iterations, 3 inputs; ETH, 1 CQ, 12×10; host load average 6.3-7.6). Device b2b per frame, e2e `model()` p50(p99) in ms:
| arm | knobs | b2b frame | encode b2b | synthetic 1600×900 | PandaSet 1920×1080 | nuScenes + ego poses ||---|---|---:|---:|---:|---:|---:|| base | `HOST_PRE=numpy HOST_POST=numpy HOST_BEVPOOL=torch STEM_IN=slice` | 34.349 | 24.242 | 147.0 (186.7) | 353.4 (380.5) | 172.2 (192.8) || host (R1.1 + R1.2 + R1.4 v1) | `numba numba numba slice` | 34.345 / 34.344 | 24.242 | 94.9 / 93.5 | 104.6 / 103.3 | 98.6 / 100.4 || kin (+ R1.3) | `numba numba numba kin` | **31.634 / 31.637** | **21.552** | **61.9 / 61.7** (69.6 / 76.3) | **72.9 / 71.2** (93.0 / 86.5) | **67.9 / 66.0** (77.4 / 73.1) |
Stage split (instrumented loop, p50 ms, synthetic / PandaSet / nuScenes):
| stage | base | host | kin ||---|---|---|---|| host_pre (gather, normalise, NHWC rows, calibration cache, plan) | 35.6 / 225.0 / 36.0 | 6.6 / 15.4 / 6.7 | 3.2 / 11.8 / 3.1 || host_in + H2D of the image | 28.8 / 28.7 / 28.7 | 28.8 / 28.9 / 28.8 | **1.1 / 1.1 / 1.5** || trace `encode` (one blocking replay) | 24.29 | 24.28 | **21.59** || `api.bevpool` (read-back views, BEVPool, curr pad, grid, plan; plain loop) | 12.1 / 11.7 / 12.2 | 16.5 / 15.9 / 17.5 | 16.9 / 16.3 / 18.0 || host_post (decode, top-500, Scale-NMS, node filter) | 27.7 / 49.1 / 50.9 | 3.2 / 4.9 / 2.9 | 3.2 / 4.8 / 4.5 |
The host BEVPool row went the wrong way in this A/B: the first twin (R1.4 v1) took 15-17 ms in the serving processagainst 12 ms for torch. Its inner loop indexed a 1-D feature array with a computed offset, which numba does notvectorise (wrap-around checks), and it read the read-back's strided views. The kept version (R1.4 v2 below) copies the80 feature channels into one C-contiguous block and accumulates per cell in a local array (in-process microbenchnext to a live model: see the R1.4 row).
| step | commit | what | b2b frame | e2e p50 (synthetic / PandaSet / nuScenes) | accuracy | knob (revert) ||---|---|---|---|---|---|---|| R1.1 | `8b64add` | **Scale-NMS numba twin**: lazy greedy pass with the oracle's candidate pre-reject plus an exact circumcircle pre-reject (an edge crossing lies within both circumradii, a corner counted inside within its circumradius + 1.5 cm), per-pair vendor polygon IoU in float32 step for step (no FMA, the oracle's centroid summation order, stable angle sort; the oracle's own numpy corners / cos / sin) | unchanged | host_post 27.7 / 49.1 / 50.9 -> **3.2 / 4.9 / 2.9 ms** (CPU: NMS 46-117 -> 1.9-2.4 ms on 68 golden frames) | pair IoU bit-identical on 220k random + degenerate pairs; same keep lists on 68 golden frames × thresholds 0 / 0.2 / 0.5 and random clustered scenes (`test_fast_host.py`) | `BEVDET_HOST_POST=numpy` || R1.2 | `1a47505` | **pre-processing numba twin**: `cv::resize` of the RGB image as is (per channel, so equal to the BGR resize swapped), the Preprocess crop gathered straight into HWC B, G, R rows (`prange` over rows), the normalised NHWC float32 rows through a 3 × 256 table of the oracle's own expression | unchanged | host_pre 35.6 / 225.0 / 36.0 -> **6.6 / 15.4 / 6.7 ms** (host arm; e2e 147.0 / 353.4 / 172.2 -> 94.9 / 104.6 / 98.6 with R1.1 + R1.4 v1) | crop and NHWC rows bit-identical at 1600×900, 1920×1080, 1280×720, 1599×901, RGB and BGR | `BEVDET_HOST_PRE=numpy` || R1.3 | `9d5ef74` | **K-IN u8 stem**: the uint8 crop rows go up (`[1, 1, 6·256, 2112]`, 3.2 MB in 2112-byte pages instead of 6.5 MB of bf16 in 6-byte pages); per camera `kin_u8.cpp` (`generic_op`, data movement only, both RISC-Vs, common RT args only) looks every byte up in a 3 × 256 bf16 table (the host path's float32 value and its torch RNE bf16 conversion) and writes the stem conv's height-sharded L1 input (16-byte pixel rows); the stem conv runs on ttnn's L1 path per camera (act_block_h 384), then the max pool per camera and one concat (bevformer-p150 `KinStem` pattern) | **34.35 -> 31.64 ms** (encode b2b 24.24 -> 21.55) | **94.9 / 104.6 / 98.6 -> 61.9 / 72.9 / 67.9 ms** (host_in + H2D 28.8 -> 1.1 ms) | stem input bit-identical (all 6 cameras, twice); the stem output bit-identical to the stock stem; frozen gates read-only **20 passed with every printed value identical** to the baseline run; gate files' md5 unchanged | `BEVDET_STEM_IN=slice` || R1.4 | `205a7c0`, v2 `e54225a` | **host BEVPool numba twin**: numpy `reduceat`'s order per (cell, pixel) pair (`a[0] + pairwise_sum(a[1:])`) and the CSR product's per-cell order in one `prange` over cells, depth read in place from the read-back, the 80 feature channels copied into one C-contiguous block (v2: the channel loop vectorises; v1 indexed a flat array and was slower than torch in the serving process), the padded `curr` written directly. `BEVDET_HOST_THREADS` (numba threads; 0 = all) | unchanged (31.633-31.638 ms in all arms) | `api.bevpool` 11.5 / 12.1 / 13.5 and 12.3 / 11.8 / 13.1 (torch arms) -> **7.1-8.9 / 6.5-7.1 / 7.1-8.8 ms**; e2e 53.3 / 66.0 / 63.2 and 56.0 / 68.1 / 60.8 -> **53.2 / 61.0 / 55.2 and 49.0 / 60.1 / 54.9** (`job_ab.sh r14`: kintorch, kin, kin4, kin4, kin, kintorch; load 5.9-6.7). In-process microbench next to a live model: torch 11.8 ms, twin 6.6 (1 thread) / 3.9 (2) / 3.0 (6-8) ms (`probe_threads.log`). 4 threads (kin4) were not better than 8: the default stays 0 (all cores) | bit-identical to numpy + torch (random, softmax-like and scaled inputs on 2 golden calibrations, read-back views, padded out) | `BEVDET_HOST_BEVPOOL=torch` |
**Device profile** (Tracy, one replay per segment, `STEM_IN=kin`; `profile_r1_reports.tar.zst`, raw directorydeleted): `encode` 342 programs, kernel sum **21,440 µs** (24,184 at the re-baseline). The stem is now 43 programsand **712 µs** (3,409 µs before: two PaddedSlices of 6-byte sticks 2,793 µs): per camera `kin_u8` 22.7 µs, halo8.2 + move 2.4, conv 37.1, halo 9.0, max pool 26.8, sharded-to-interleaved 5.0; one concat 44 µs. The rest of theencoder is unchanged (20,729 µs against 20,775 µs). `decode` 140 programs as before.
**Final gates at the new defaults** (no `BEVDET_*` override; `job_final_gates.sh`): `test_pcc_device.py`,`test_e2e_device.py`, `test_streams_device.py` with `TTAW_GATES_READONLY=1` plus `test_kin_device.py`: **23 passed**;every printed PCC and agreement value is identical to the re-baseline run (`gates_final.log` vs`opt_plan/gates_rebase.log`), gate files' md5 unchanged. The revert paths were built and run in the A/B arms (`base`:`STEM_IN=slice` and the three oracles; `kintorch`: `HOST_BEVPOOL=torch`).
**Bring-up** (hang protocol): `test_kin_device.py -k small` (1 camera, 8 rows) under `TT_METAL_WATCHER=2` first(0 / 16,896 values differ, no watcher finding), then the full shape eager ×2 and the stem equality, then the tracedgraph in the gate run (`test_replay_equals_eager` green). No hang, timeout or reset.
## Known hangs (all rounds)
| when (UTC) | command | cause | status ||---|---|---|---|| | | none: no device job of the port, the verification, the baseline or this release hung, timed out or needed a reset (the few failed port jobs were Python errors, PORT_LOG.md section 8) | || 2026-10-14 09:35-09:50 (round 7) | `bin/devrun -t 900 -- bash logs/bevdet/opt_r7/job_bring4.sh` (`test_bevpool_k_device.py`, model shape, eager) | the device BEVPool kernel `bpk` in its grouped + batched (NB = 4) form; small shapes under the watcher had passed. devrun timeout, `.device.FAULT` written, chip left for the orchestrator | not root-caused; form not kept (Round 7) || round 6 | | none on the device. One probe (`probe_c512.log`, first version) hit a TT_FATAL ("Cannot load new binaries during trace capture") inside its own trace capture after a candidate's L1 clash; the process then spun in device close. It was killed by hand (SIGTERM) before the devrun timeout: no `.device.FAULT`, no reset, the next agents' jobs ran normally. The probe's timing helper now always ends the capture. Every other job (conv probes, 5 equality runs incl. the K-IN watcher run, 6 A/B sessions, the gates, the profile) finished without a hang, timeout or reset | || round 5 | | none: the `upk` bring-up (watcher, 1 core then the grid, R = 1 / 2, traced), the model-shape probes, the `mmres_k` multicast bring-up (tiny under the watcher, then all shapes), the RES_L1 / STREAM_L1 equality runs (watcher first), three A/B sessions, two gate runs (the first failed the sample0 gate with two TF32 terms), four gate-variant runs and two profiles finished without a hang, timeout or reset. The STREAM_L1 attempts stopped at program creation (`TT_THROW ... clash with L1 buffers`, nothing enqueued) | || round 4 | | none: the L1-residency probe (2 runs; the first stopped on a matmul subblock check), the per-block debug, three equality runs, two A/B sessions (in the first, the `PUSH_X` arms stopped on `ttnn.concat(output_tensor=...)`, a host-side TT_FATAL), the PCC and final gate runs (one setup error: L1 clash of the debug taps, fixed) and the profile finished without a hang, timeout or reset | || round 3 | | none: the conv-config probes (3 jobs), the equality tests, two A/B sessions, the HEAD2 gate run, the final gates and the profile finished without a hang, timeout or reset | || round 2 | | none: the `mmres_k` bring-up (tiny shapes under the watcher, model shapes, traced), the encoder / decoder equality tests, three A/B jobs, the profile and two gate runs finished without a hang, timeout or reset | || round 1 | | none: the K-IN u8 bring-up (smallest shape under `TT_METAL_WATCHER=2`, full shape eager ×2, stem equality, traced in the gate runs), both A/B jobs, the profile and the gate runs finished without a hang, timeout or reset. One probe script failed with a Python error (`probe_threads.py` argument clash) and was re-run | |
## Rejected / not kept
- **Round 7 `BEVDET_BEVPOOL=device`** (MK-2 module 1): the inexact form fails the sample0 / PandaSet gates (FPU inner sums ~2^-11); the exact form passes every gate at 0.70 ms but its faster grouped / batched form hung; no A/B. Kept behind the knob (default `host`), see "Round 7".
- **R6.5 `STEM_BATCH`: the K-IN stem for all six cameras in one K-IN / conv / max-pool program each** (bit-identical): encode b2b 6.789 / 6.799 against 6.780 / 6.797 per camera (`ab_sb`): the per-camera programs were not overhead-bound. Code removed (`logs/bevdet/opt_r6/stem_batch_attempt.patch`).- **Transposed sharding of layer 4** (33 tile rows) and of the CustomResNet stages 1-2: slower in the probe (layer-4 conv2 79 -> 98 us chained; stage 2 63 -> 142 us).- **FPN_LSS `up2.1` transposed on its DRAM-sliced path**: 613 -> 566 us, but 57 output values differ (another K split); not taken without a gate run for 47 us.
- **R5.4 `STREAM_L1`: the layers 1-2 residual stream in L1 height shards, `mmres_k` updating it in place** (out = r: each core reads its r rows before writing the same rows; layer 2's last block writing DRAM for layer 3): does not fit. Layers 1-2 (`eq_stream` first try): the 34.6 MB layer-1 stream (295 KB per core) leaves no room for layer-1 conv2's circular buffers (`clash with L1 buffers ... L1 buffer allocated at 648704 and static circular buffer region ends at 652352`, also with ttnn's DRAM-sliced fallback). Layer 2 only (`eq_stream_l2_clash.log`): `mmres_k`'s own static CBs (resident fp32 weights, 0.5 MB on layer 2, + the row CBs) end at 1,029,120 B, the stream and the conv2 / out2 shards start at 978,688 B. Needs streamed (not resident) weights in `mmres_k`; code removed, not kept.- **R5.1 with two TF32 terms and the x4 kernel** (fp32-exact weights): sample0 49 / 52, below its frozen gate (50); the default is one term (`BEVDET_UPK_TERMS=1`), 50 / 52.- **x4 up-sampling as a Kron interpolation matmul** (`KronUpsample`, `kron(A_h, A_w) [4096, 256] @ x`, two fp32 terms + add + typecast): 0.290 ms against grid_sample's 0.161 and the `upk` kernel's 0.046 (`upk_model2.log`); kept only as the fallback for shapes the kernel does not take.- **`out_conv` (16384 x 256 -> 256, 1x1) with an explicit matmul config** (`probe_mm.py --only 12`): the best bit-identical config 98.6 us against the stock 105.2 us (`probe_mm_outconv.log`): 6 us, not applied.
- **R4.1 with the layer-4.0 projection on the stream's shards**: 71 values of its output differ (another K split than from DRAM); it reads a DRAM copy instead (+29 us S2I).- **R4.3 with `ttnn.concat(..., output_tensor=<state>)`** for push / fill / the decode input: unsupported in this tt-metal (`concat.cpp:272`); push_x slices the held decode input instead.
- **R3.1 on layer2.0's 1x1 / stride-2 projection**: weight double buffering changes its output (2.6 M of 34.6 M values; `probe_conv_enc.log`), activation DB gains nothing (214.6 vs 214.7 µs) and both together do not build: excluded from `CONV_TUNE` (`conv_tune.SKIP`).- **Other `Conv2dConfig` candidates** (`probe_conv_*.log`): height sharding (does not build at most shapes; no gain where it builds, e.g. the shared head conv 103.7 vs 103.9 us, except `head.merged2` = R3.3), `full_inner_dim` (within 1 %), 128 / 64-row activation blocks (slower; on `up2.1` also not bit-identical), split reader / activation reuse (do not build at most shapes): double buffering alone was within 0.1 % of the best bit-identical candidate.
- **R2.4 `CONV_L1` group `dec`** (every BEV decoder conv on the L1 path): +0.29 ms and not bit-identical (two convs need 256-row activation blocks on L1, which changes their outputs). The bit-identical subset is a candidate for a later round (the 864-channel first convs, I2S 76 µs each).- **`BACKBONE_RES=next` on layers 3-4** (`mmres_k` with column groups): 230 / 214 µs per block against 122 / 76 µs of stock conv3 + add; `next12` keeps them stock (-1.05 ms).
- **R1.4 v1** (host BEVPool twin indexing a flat feature array): bit-identical but 15-17 ms in the serving process against torch's 12 ms (A/B `r1`, host arms); replaced by v2 (contiguous feature block, vectorised channel loop).- **`BEVDET_HOST_THREADS=4`**: no gain over all 8 cores in the A/B `r14` (e2e within noise, `api.bevpool` 6.5-8.8 against 7.1-8.9 ms); the default stays 0.
From the port (PORT_LOG.md decisions B11, B15), kept here so the optimization rounds do not repeat them blindly:
- **bf16 weights** (instead of fp32): 0.13 + 0.16 ms faster per frame, but the nuScenes key-frame gate fails (48 of 52 boxes against a gate of 50), because ttnn rounds the BatchNorm-folded conv biases to the weight dtype. The release keeps fp32 weights (PLAN.md 9.3 precision policy). Two-term bf16 weights (C17 `weight_terms=2`) are untested here.- **HiFi2** (with fp32 weights and L1 accumulation): encode 24.25 -> 22.89 ms and decode 8.74 -> 7.94 ms (-2.2 ms per frame), never gated. Re-measure after the layout work of item 3, when compute is a larger share.- **C18 `Resize2d`** (interpolation matmuls with fp32 weights) for the FPN_LSS upsamplings instead of `grid_sample` with static grids: not used, since the grids pass their gates with margin; it would remove the small negative score bias of VERIFY_PORT.md L3 (bf16-truncated bilinear weights). Item 10 below.
## Profile at the baseline (trace replay)
From `OPT_BASELINE.md` (Tracy, `ops_perf_results_2026_10_08_04_05_34.csv`):
- The device is **kernel-bound**: kernel time 34,045 µs against a 34,314 µs span; only 265 µs of op-to-op gaps (0.58 µs per program). Dispatch is not the bottleneck, so a megakernel pays off only where it removes data movement or a host round trip.- **48 % of the device time is data movement**: re-tiling around every encoder 3×3 conv (ReshapeView, 8.95 ms, 26 %), the stem's DRAM slicing of the 6-byte-stick image (2.79 ms), the AlignBEV `grid_sample` (2.05 ms), GatherBEV's concat / permute (0.99 ms) and the ring shift (1.25 ms).- Top 5 ops: the AlignBEV `grid_sample` (2.05 ms), two stem input slices (1.52 and 1.27 ms), a layer2 re-tiling pair (0.67 + 0.65 ms). The first conv appears at rank 10.- Encoder 3×3 convs run at 40-62 % of the HiFi4 FLOP model, decoder convs at 19-63 %, the encoder's 1×1 matmuls (DRAM in and out) at 5-39 %.
## Remaining backlog (ranked; gains estimated on the 34.15 ms device frame unless marked e2e)
The full analysis is `OPT_BASELINE.md` "Ranked optimization opportunities". Every item keeps the frozen gates; "exact"means bit-identical outputs or a pure layout change.
1. **Upload uint8 crops and normalise on the device** (e2e -35..-40 ms; device -2.5 ms; exact). The 6.5 MB bf16 image goes up in 1,081,344 six-byte pages (27.1 ms); 3.2 MB of uint8 crops in 2112-byte rows would take about 0.6 ms, and the device normalisation `(x - mean) * (1/std)` gives bf16-identical inputs for all 768 values (CPU check). The stem would read a padded, sharded layout instead of slicing 6-byte sticks (2.79 ms).2. **Host path for non-native image sizes** (e2e -160 ms on 1920×1080). Almost all of the 209 ms is a numpy channel flip (16-45 ms per camera) and a plane transpose; OpenCV does the flip in 0.18 ms and the resize is channel-independent. Also one thread per camera (est. -10..-20 ms at 1600×900).3. **Encoder activations in L1 without the 4-D re-tiling** (device -10..-12 ms of 24.1; layout only): 60 ReshapeView programs (8.57 ms), 62 I2S / S2I (1.04 ms), 41 DRAM-bound 1×1 matmuls (4.24 ms), 23 DRAM residual adds (1.83 ms), 18 unfused ReLUs (0.43 ms). Height- / block-sharded bottleneck chains (the Blackhole ResNet-50 demo is the config reference), ReLU fused into the 1×1 matmuls, sharded residual adds.4. **Scale-NMS on the host** (e2e -30..-45 ms on real scenes; exact): a lazy greedy pass and an exact pre-reject (circumcircle, separating axes) before the vendor polygon IoU.5. **Device BEVPool and one trace per frame: the "BEVBuilder" megakernel attempt** (e2e -20..-45 ms; device -3 ms; the D19 megakernel attempt). It removes the host BEVPool (15-36 ms p50), the depth / feature read-back and the `curr` upload, and the second replay; with AlignBEV, GatherBEV and the slot write fused, also the 3.48 ms gather block and the 1.25 ms ring shift. Runtime inputs: the tables, partition, transforms and flag in device buffers (a new calibration needs no re-capture).6. **Precision** (device -2.2 ms; gate-checked per module): HiFi2 with fp32 weights (measured during the port, never gated); re-measure after item 3.7. **AlignBEV identity fast path in Autoware mode** (device -2.0 ms; exact): with identity transforms and a full history (the default node's steady state) AlignBEV is a bit-exact copy; a `decode` variant without the `grid_sample`, chosen by the host plan like `fill` / `push`.8. **GatherBEV and ring layout** (device -1.5..-2.2 ms; exact): ring stored per pixel (slots in channels), one slot written per frame through per-slot write variants or a rotating head instead of shifting 25 MB.9. **BEV decoder convs** (device -1.0..-1.5 ms; exact rewrites): peer-merged conv1 + downsample per CustomResNet stage, no DRAM slicing of the 128² neck / head convs, a better form for the 384 -> 20 block-diagonal head conv.10. **FPN_LSS upsampling as interpolation matmuls** (C18 `Resize2d`; device ±0.3 ms; removes the score bias L3).11. **Host conversions** (e2e -5..-15 ms under load): preallocated host tensors (`ttaw.tensors.HostStaging`), untilize on the device, no `curr` pad copy.12. **Image-encoder tail megakernel** (D19 candidate; decide after item 3): the 16×44 / 8×22 tail costs 12.2 ms, about 5.0 ms of it re-tiling.13. **Cross-frame pipelining** (throughput only): overlap a frame's host work with the previous frame's device work; 2 CQs with staged uploads only for large pipelined uploads (D14).
Indicative: items 1, 3, 6, 7, 8 and 9 would take the device frame from 34 ms to roughly 12-17 ms, and items 1, 2, 4, 5and 11 with those gains the e2e of a 1600×900 stream from 173-220 ms to roughly 60-90 ms. These are estimates, to bemeasured step by step (PLAN.md 5.1).123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193# bevdet-p150: verification of the first release, 2026-10-08
## Verdict
**PASS.** This is the light verification pass of the first publish (`research/PLAN.md` §6.3): the frozen gatesre-run on the release code, the baseline numbers re-checked, and every device-open path audited for ETH dispatch. Itwas made by the agent that wrote the release docs (neither the porter nor the independent verifier) on commit`c8a3ef8` (the `code/` of this repo, ttaw 0.20.0 vendored). Against the baseline commit `ad4de55`(OPT_BASELINE.md):
- **Accuracy:** device suite 20 passed (PCC, e2e and streams files, one devrun job, rc 0); every frozen gate value is reproduced exactly: the per-tap PCC reports and the box / score fields of every e2e report are identical to the port's run (only the timing fields differ); the shipped sample matches 10 of 10 reference boxes, max |score difference| 0.0056.- **Speed:** device frame 34.15 ms back to back (baseline 34.15), every trace replay within 0.01 ms of the baseline; e2e `model()` p50 synthetic 131.8 ms (baseline 173.3), PandaSet 348.2 (341.9), nuScenes 172.7 (220.3): host stages only, which move with the shared host's load.- **Audit:** ETH dispatch, 1 CQ and the 12×10 grid on every device-open path; no fallback in any run.- **No numerics change in the device graph.** The diff `ad4de55..c8a3ef8` changes host code only: the output rows (network class names as `label`, the node's `autoware_label` and `twist`), `nms_rescale_factor` as a request parameter (default bit-identical), 4 stream histories with LRU eviction (`BEVDET_MAX_STREAMS=4`; the bank swap was device-tested bit-exact by the port), a stream restart after a failed ring update, the synthetic shipped sample, OpenCV declared for the image, the ttaw re-vendor 0.15.0 -> 0.20.0 (nothing on BEVDet's device path) and documentation. No gate threshold moved; three new gates (the shipped sample) were frozen at their first green run.
The full adversarial verification of the port is `VERIFY_PORT.md` of the source repository (not published; round 1,2026-10-07/08, PASS, no high or medium issue, 15 low findings): it re-ran every suite in a clean clone, audited therequest path, the gates, the oracle chain and the Autoware fidelity line by line, and re-measured every PORT_LOGfigure. This pass resolves its findings as listed in "Review findings".
## Setup
| item | value ||---|---|| Hardware | one Blackhole p150b, ETH dispatch, 1 CQ, 12×10 compute grid (120 cores), as printed by every run (`dispatch eth`, `fallback null`, `eth_patch true`) || tt-metal | `44d66500520` with `patches/tt-metal-eth-dispatch.patch` (sha256 `08d0ddf6…`, byte-identical to the workspace copy) || Weights | `AutowareFoundation/tensorrt_bevdet` @ `391466349a1b39c93b9865364a8088110ca8d97b` (tag `v1.0`, `bevdet_one_lt_d.onnx` sha256 `47f156cb…0d77`), offline from the workspace copy (`BEVDET_WEIGHTS_DIR`, `HF_HUB_OFFLINE=1`) || Verified commit | `c8a3ef8` (ttaw 0.20.0 @ common `89dec49`, vendored as committed; `vendor.py --check` 0 differences); the release code commit `d856d8c` (ttaw 0.18.1) plus the re-vendor || Baseline commit | `ad4de55` (`OPT_BASELINE.md`, ttaw 0.15.0) || Workload | the shipped synthetic sample (`code/tt_bevdet/samples/synthetic_6cam.json`); the PandaSet 019 f38-40 sample (staged, not shipped); nuScenes v1.0-mini mini_val and the bevdet_vendor key-frame (local only, CC BY-NC-SA); batch 1, warm || Bench method | `code/scripts/bench.py --iters 100` (inputs synthetic, the shipped sample, PandaSet, nuScenes), one process || Served method | uvicorn on the host with the serve pins (the container's app and env), `server/smoke_test.py`, then 40 requests of the shipped sample from a loopback client after 3 warm ones || Accuracy reference | the fp32 CPU reference (`code/tt_bevdet/reference/`), equal to ONNX Runtime on the plugin-free sub-graphs of the deployed ONNX (re-run: `tests/test_reference_cpu.py` 8 passed, `logs/bevdet/release/test_reference_cpu.log`) || Host | AMD EPYC VM, 8 vCPUs, shared with other agents' jobs (load average 6.6-10.8 during the runs); host stages move with it || Logs | `logs/bevdet/release/` of the workspace (job scripts in `scripts/`) |
## Measured baseline vs re-check
| measurement | baseline `ad4de55` (OPT_BASELINE.md) | re-check `c8a3ef8` | change ||---|---:|---:|---:|| device, one steady frame b2b (encode + decode + push) | 34.15 ms | 34.15 ms | 0.00 ms || device, steady frame with ego poses | 34.45 ms | 34.45 ms | 0.00 ms || `encode` b2b / one blocking replay | 24.24 / 24.30 ms | 24.24 / 24.29 ms | 0.00 / -0.01 ms || `decode` b2b / replay (Autoware mode) | 8.68 / 8.73 ms | 8.68 / 8.72 ms | 0.00 / -0.01 ms || `decode` b2b / replay (ego poses) | 8.98 / 9.03 ms | 8.97 / 9.02 ms | -0.01 / -0.01 ms || `push` b2b / replay | 1.26 / 1.29 ms | 1.26 / 1.30 ms | 0.00 / +0.01 ms || `fill` b2b / replay | 0.90 / 0.93 ms | 0.90 / 0.94 ms | 0.00 / +0.01 ms || e2e `model()` p50 (p99), synthetic 1600×900, Autoware mode | 173.3 (217.5) ms | 131.8 (187.1) ms | -41.5 ms (host load; host-side only) || e2e `model()` p50 (p99), PandaSet 1920×1080 | 341.9 (370.5) ms | 348.2 (373.7) ms | +6.3 ms (host load) || e2e `model()` p50 (p99), nuScenes 1600×900 with ego poses | 220.3 (262.5) ms | 172.7 (244.8) ms | -47.6 ms (host load) || H2D image upload (`h2d.encode`, synthetic) | 27.1 ms | 27.1 ms | 0.0 ms || program-cache entries after warm-up | 214 | 214 | 0 || AICLK | 1343-1350 MHz | 1343-1350 MHz | |
Not in the baseline, measured for the card on `c8a3ef8`:
| measurement | value ||---|---:|| e2e `model()` p50 (p99), the shipped synthetic sample | 136.9 (179.5) ms || load (`from_pretrained`, warm kernel cache, local weights): build / warm-up / total | 1.2 / 9.7 / 16.1 s || served `/predict`, shipped sample, 40 requests after 3 warm: client round trip p50 (p90) | 623.9 (703.7) ms (9.6 MB request) || served `timing_ms.total` / `model_call` p50 | 538.2 / 156.7 ms || stream bank switch (save + load of a 25 MB ring bank) p50 | 1.07 ms || `model()` device stage p50: one stream / two alternating streams | 111.0 / 108.9 ms (host load dominates the difference) |
## Accuracy gate results
`test_pcc_device.py` + `test_e2e_device.py` + `test_streams_device.py` on `c8a3ef8`, one devrun job:**20 passed in 81.08s (0:01:21)** (rc 0; `logs/bevdet/release/jobR3_c8a3ef8/device_suite.log`).
| gate | threshold | value ||---|---:|---:|| `test_pcc_device` aligned.moving | >= 0.9999 | 0.999995 || `test_pcc_device` bev.curr | >= 0.999 | 0.999956 || `test_pcc_device` bev.in | >= 0.999 | 0.999999 || `test_pcc_device` depth | >= 0.999 | 0.999935 || `test_pcc_device` feat | >= 0.999 | 0.999940 || `test_pcc_device` head.dim_0 | >= 0.998 | 0.999904 || `test_pcc_device` head.heatmap_0 | >= 0.998 | 0.999929 || `test_pcc_device` head.height_0 | >= 0.998 | 0.999978 || `test_pcc_device` head.reg_0 | >= 0.998 | 0.999785 || `test_pcc_device` head.rot_0 | >= 0.998 | 0.999713 || `test_pcc_device` head.vel_0 | >= 0.998 | 0.999517 || `test_e2e_device` nuscenes.precision | >= 0.95 | 0.989897 || `test_e2e_device` nuscenes.recall | >= 0.95 | 0.989719 || `test_e2e_device` nuscenes.score_abs_err_p99 | <= 0.05 | 0.008301 || `test_e2e_device` pandaset.precision | >= 0.95 | 1.000000 || `test_e2e_device` pandaset.recall | >= 0.95 | 1.000000 || `test_e2e_device` pandaset.score_abs_err | <= 0.05 | 0.005924 || `test_e2e_device` sample0.recall | >= 0.9615 | 0.980769 || `test_e2e_device` synthetic.precision | >= 0.95 | 1.000000 || `test_e2e_device` synthetic.recall | >= 0.95 | 1.000000 || `test_e2e_device` synthetic.score_abs_err | <= 0.05 | 0.005596 |
Also re-run: the host suite on the fake ttnn (98 passed, 21 skipped with ttaw 0.20.0), the CPU reference against ONNX Runtime (`tests/test_reference_cpu.py` 8 passed, `logs/bevdet/release/test_reference_cpu.log`),the stored references (the shipped sample's and the staged PandaSet sample's, written by the current CPU reference;`tests/test_api_host.py` reproduces both from the reference head maps), the public-data runs of the demo media and thenuScenes mini_val metrics:
| run (TT through the API, every frame) | frames | agreement with the CPU run: recall / precision | mAP / NDS (TT; CPU) ||---|---:|---:|---:|| PandaSet 019, ego poses, 2 Hz key-frames | 9 | 0.9902 / 0.9863 | - || PandaSet 019 f30-40, Autoware semantics | 11 | 0.9914 / 0.9905 | - || PandaSet 019 f40, single frame | 1 | 0.9912 / 0.9912 | - || PandaSet 019 f40, single frame, raw K (node quirk) | 1 | 1.0000 / 1.0000 | - || nuScenes scene-0103, ego poses, key-frames | 40 | 0.9897 / 0.9899 | 0.3670 / 0.4362; 0.3673 / 0.4367 (both scenes) || nuScenes scene-0916, ego poses, key-frames | 41 | 0.9897 / 0.9902 | (with scene-0103) || nuScenes scene-0103, Autoware semantics, every camera frame | 229 | 0.9918 / 0.9923 | 0.2530 / 0.2739; 0.2535 / 0.2746 (both scenes) || nuScenes scene-0916, Autoware semantics, every camera frame | 240 | 0.9876 / 0.9878 | (with scene-0103) |
## Disclosed numerics changes
None in the device graph or in the default host post-processing:
- The device traces, the precision (`HiFi4+fp32+l1acc:w=fp32`) and the host pre-processing are those of the baseline; the per-tap reports of the gate run are byte-identical to the port's for both PCC reports, and identical in every field except `timing_ms` for the e2e reports (nuScenes, sample0: byte-identical; PandaSet and the synthetic sample: same boxes and scores, other timings and the renamed `bev_decode` key).- `nms_rescale_factor` defaults to the model yaml's factors, passed to the decode as the configuration's float32 array (bit-identical); only a request that sets it changes the Scale-NMS.- The output rows change their `label` (the network class instead of the Autoware label; `label_id` unchanged) and gain `autoware_label` and `twist`; the boxes, scores and velocities are unchanged.- The ttaw re-vendor 0.15.0 -> 0.20.0 touches one function on BEVDet's path, C27's `identity_like` (0.17.2), which returns the shortcut unchanged whenever the shapes agree, as at every BEVDet residual; 0.19.0 and 0.20.0 only add `models/pillars.py` and `ops/segment.py` (+ its kernel), which `tt_bevdet` never imports.
## Review findings
How the low findings of `VERIFY_PORT.md` were resolved:
| # | finding | resolution ||---|---|---|| L1 | SERVING / README documented `scale_intrinsics` and `history_stride` as request params; the README snippet lacked `load_sample` | rewritten: `scale_intrinsics` is a `calibration` key, `history_stride` the load-time `BEVDET_HISTORY_STRIDE`; the snippet imports `load_sample`; `tests/test_api_host.py` asserts both names are refused as params || L2 | vendored ttaw 0.11.0 behind `common` | re-vendored 0.15.0 (baseline), 0.18.1 (release code `d856d8c`), 0.19.0 (`a7fb8e7`, the first release job) and 0.20.0 (`89dec49`, as committed: the verified commit); gates re-run (above) || L3 | systematic score offset of about -0.0008 | disclosed on the card (Caveats); OPT_REPORT.md item 10 (fp32 interpolation weights for the FPN_LSS upsampling) || L4 | the container smoke's strict comparison passed by 2.3 %; `DEFAULT_EXPECT` was a placeholder | the smoke now uses the PLAN box agreement (a reference box >= 0.2 recalled by a same-class served box of any score > 0.1 within 0.5 m, and the reverse for precision) on a sample made for it: the synthetic pattern's ten boxes all score >= 0.43, so no box sits near a threshold; `DEFAULT_EXPECT` = the pattern's eight objects; the strict recall is printed too. Measured: recall / precision 1.000 / 1.000 (10 of 10), strict recall 1.000, max |score difference| 0.0056 against the 0.05 limit, centres within 0.005 m against 0.5 m; the weakest reference box scores 0.43 || L5 | template placeholders and contradictions (README "no nuScenes evaluation", yaml risks "bf16 / bfp8", yaml quickstart `--points`, the `host/preprocess.py` docstring) | docs written; the four contradictions fixed (the mini_val metrics are on the card; the risks state fp32 weights / bf16 activations; the quickstart builds a six-camera request; the docstring says the normalisation runs on the host) || L6 | stale PORT_LOG figures | fixed: f40 teacher-forced heads min 0.999930, alloc tracking 17 passed with the streams file, the ttaw line || L7 | the node's `twist` unreachable from `/predict`; `nms_rescale_factor` a config constant | every row carries `twist` (`linear_x`, `angular_z`, the node's formula) and `autoware_label`; `nms_rescale_factor` is a request param (10 factors or a `{class: factor}` mapping, validated); host tests || L8 | documented plan deviations (variant-selected flag / init, physical ring shift, bf16 image upload, stride as LOAD, the METEOR gate replaced) | unchanged and documented; OPT_REPORT.md items 1, 7, 8 || L9 | no host test of `plan_ops`, `history_grid`, `expand_history_channels`; sample0 heads not gated | `tests/test_tt_host.py` (3 tests, the verifier's suggestion): the replay plan of reset, fresh, steady and stride frames and of a real stream; the AlignBEV grid (identity, never-written slots, reset frames); the zero pad columns of the history convs. sample0 keeps its box gate (`sample0.recall`); its head PCC stays a reported value (the verifier measured >= 0.99966), no new PCC gate || L10 | `BEVDET_HISTORY_STRIDE` > 1 never run on the device | still open; the docs say "host-tested plan, not yet device-validated" and `serve.env` pins 1 || L11 | an exception after `fill` left the device ring and the host plan inconsistent | fixed in `api._forward`: before any ring update a failure drops only the frame, after it the stream is forgotten and restarts fresh (its next frame never reads the ring); `_activate_stream` marks the ring unowned while a bank loads. Host tests with a failing fake runner (`test_failed_frame_keeps_device_ring_and_host_plan_consistent`, `test_bank_switch_failure_reloads_on_the_next_frame`) || L12 | `ttaw.api_base` downloads without `token=False` | shared code (C08, not owned here): reported; the container sets `HF_HUB_DISABLE_IMPLICIT_TOKEN=1`, PYTHON.md tells Python users to set it || L13 | bring-up scripts outside the bundle | unchanged (optional); the release job scripts are in `logs/bevdet/release/scripts/` || L14 | the benign "active trace" allocation warning | unchanged (harmless) || L15 | the device tests overwrite the port's per-tap reports | `BEVDET_REPORT_DIR` redirects them; this pass also backed up and restored the port's reports |
Found by this pass:
- **The image lacked OpenCV.** The node's resize of images that are not 1600×900 (`host.preprocess`) imports `cv2`, which the tt-metal `python_env` provides on the host but the container's runtime stage does not install (the packaging pilot's frozen `requirements.lock` has no OpenCV): every 1920×1080 request would have failed with HTTP 500 in the container, while the smoke (a 1600×900 sample) passed. Fixed: `opencv-python-headless>=4.9,<4.12` in `tt-model.yaml` `runtime.packages` and the pip project, a `verify:` import, and a host test that the two lists agree. No device numerics involved (OpenCV 4.8.1 and 4.11 give the same pixels on the validation images, PORT_LOG I3).- **The served `timing_ms.decode` was overwritten.** `ttaw.server` merges its own `decode` (base64 + image decode), `model_call` and `total` into the model's `timing_ms`, so the model's BEV decoder stage, also called `decode`, never reached a `/predict` client. Fixed in `5accb85`: the stage is `bev_decode`, and a host test asserts that the model's stage names never collide with the server's keys. Host-only; the outputs are unchanged.- **ttaw drift after the first release job.** `common/ttaw` moved to 0.20.0 (`89dec49`, adds `ops/segment.py` for another port) while the docs were written; `check_bundle.py` warned. Re-vendored as committed (`c8a3ef8`) and the whole device job re-run on it (this document's numbers).
No test threshold was loosened, no output is cached or replayed, and the timing loops measure what they claim (thebench and the served timing are separate processes from the gate run). No hang, timeout or device reset in any job of this pass (every devrun job ended with rc 0; the server's rc 143 is its SIGTERM at the end of the step). The host rebooted unexpectedly while a re-run job (`jobR2`) was still waiting for the device lock; it never touched the device, and its steps were re-run as `jobR3` on `c8a3ef8`.
## p150 ETH-dispatch compliance
| path | dispatch / CQs / grid ||---|---|| Python API `BEVDet.from_pretrained()` | `DeviceConfig(dispatch="eth")` from `DEVICE_DEFAULTS` (1 CQ, L1_SMALL 32 KiB, trace region 256 MiB); grid read with `compute_with_storage_grid_size()`; a failed ETH open warns and falls back to WORKER (`fallback` reported in `device_info` / `/info`) || HTTP server (`BEVDET_DISPATCH` default) | `config_from_env`: `eth` unless the variable says otherwise; `/info` and `/health` report dispatch, grid, CQs and the fallback || `tt-model.yaml` serve env (the single, default profile) | `BEVDET_DISPATCH=eth`, `BEVDET_NUM_CQS=1`, `BEVDET_VARIANT=default` + every knob pinned at its default (host test); no other profile || image `verify:` | `single_chip_arch_1cq_no_dispatch_s` asserted in `tt_metal/impl/dispatch/topology.cpp`, `eth_dispatch_patch_present()` asserted, `cv2` importable || container smoke (default profile) | `server/smoke_test.py` fails unless `/info` reports `eth`, `12x10` and the pinned dispatch / CQs / variant / revision || gate tests (`code/conftest.py`) | `open_device(..., allow_fallback=False)`: a failed ETH open is an error, never a silent WORKER run || bench / profile / public-data scripts | `from_pretrained(dispatch=None -> eth)`; `--dispatch worker` only for the D14 matrix (OPT_BASELINE.md) || vendored `ttaw` | 0.20.0 @ `89dec49`, `source_dirty: false`; `check_bundle.py` drift check clean |
Every run of this pass printed `dispatch eth, grid 12x10, fallback null, 1 CQ` (`bench.log` config line: `"dispatch": "eth", "num_command_queues": 1, "fallback": null, "grid": "12x10", "cores": 120, "eth_patch": true`; the smoke: `dispatch=eth grid=12x10 cqs=1`; `server_info.json` `device`).
## Logs and commands
All under `logs/bevdet/release/` of the tt-models workspace; every device command ran through `bin/devrun`(`logs/devrun/history.log`):
- `jobR3_release.log`, `scripts/bd_rel_job.sh` (`STEPS="suite quickstart server streams bench"`), copies of every output in `jobR3_c8a3ef8/`- `device_suite.log` (`reports/`: this run's per-tap reports; `port_reports_backup/`: the port's, restored)- `quickstart.log`, `quickstart/quickstart.json`, `quickstart/quickstart_bev.png`- `server.log`, `smoke.log`, `smoke_predict.json`, `server_info.json`, `client_timing.log`, `served_default.json`- `stream_switch.log`, `bench.log`, `bench_eth-1cq.json`- `host_tests_r3_ttaw0200.log` (host suite, fake ttnn), `test_reference_cpu.log` (CPU reference vs ORT)- `public_r2.log` + `results_r2/` (public-data TT runs of the media, on `aa70bfe`: the same device code), `eval_release.log` + `metrics/` (nuScenes devkit), `make_demo.log`- `jobR_aa70bfe/`, `jobR_release.log`: the first release job (ttaw 0.19.0), same results1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798# bevdet-p150: independent verification of the optimization claims (round 1), 2026-10-14
**Verdict: PASS.** I re-ran the measurements myself and they reproduce the claims in OPT_REPORT.md. The device framewent from 34.34 ms (published baseline) to 9.95-10.00 ms back to back. Every frozen gate passes read-only, and theprinted values are identical to the round-6 final gate run. Gate files are byte-unchanged since the release. The1200-call soak of the shipped default path was deterministic with no hang. Three non-blocking issues are listed at the end.
- Code under test: bundle HEAD `951ceba` (clean tree, ttaw 0.23.2 vendored), at the shipped defaults (`tt-model.yaml` serve env == `KNOBS` defaults; no `BEVDET_*` set).- "Before": the published release commit `1bdee60`, extracted with `git archive` into `logs/bevdet/verify_opt1/base_src` (ttaw 0.20.0). It ran in the same device session, alternating with HEAD.- Setup: p150, ETH dispatch 12x10, 1 CQ, tt-metal `44d66500520` + ETH patch. Every device job went through `bin/devrun`. Host load average was 5.0-6.7.- Device availability: when this verification started, the chip was FAULTed by the round-7 `bring4` hang (09:50 UTC). Device work waited until the orchestrator cleared it (13:48 UTC).- Scripts and logs: `logs/bevdet/verify_opt1/` (`job.sh`, `soak.py`, `job.rcs`, `gates.log`, `ab_*.json|log`, `soak.json|log`, `host_tests.log`).
## 1. Accuracy gates (read-only, shipped defaults)
| check | result ||---|---|| Device suite `test_pcc_device` + `test_e2e_device` + `test_streams_device` + `test_kin_device` + `test_mmres_k_device` + `test_conv_l1_device` + `test_dec_l1_device` (`TTAW_GATES_READONLY=1`, same `*_TEST` selectors as `job_final6.sh`) | **34 passed, 2 skipped** in 64 s. The 2 skips are `test_bevpool_device`, which runs only with `BEVPOOL=device` || Gate files | md5 identical before and after the run. `git log` shows the last change to `*.gates.json` was `07a76a8`, before the release, so no gate was loosened || Values vs the optimizer's round-6 final run (`opt_r6/gates_final6.log`) | Every `PASS` line (21 PCC gates) and every box-agreement line (PandaSet f38-40, sample0, nuScenes scene-0103 / 0916) is **identical** || Held-out / real frames | PandaSet f38-40 recall 1.0 / 0.992 / 0.995, score error <= 0.0078. nuScenes scene-0103 / 0916 (81 frames) recall 0.9919 / 0.9892, precision 0.9913 / 0.9902, score error p99 0.0079 / 0.0086. Synthetic 10 / 10. **sample0 50 / 52 (gate 50 / 52)** || Default path after the R7 commit | The R7 commit refactored `api._forward` and `model._encode`. The optimizer gated only `BEVPOOL=device` after that commit (`gates_dev*`). This run covers the default `host` path at HEAD, and its values are identical || Host suite (fake ttnn, 15 host test files) | **164 passed** |
## 2. Performance re-measurement (`bench.py`, 60 iterations, alternating arms in one session)
| arm | b2b frame (ms) | with ego motion | encode / decode b2b | e2e p50 synthetic / PandaSet 1920x1080 / nuScenes + poses (ms) ||---|---|---|---|---|| 1 base `1bdee60` | 34.344 | 34.627 | 24.24 / 8.87 | 139.9 / 349.9 / 169.8 || 2 HEAD | 9.997 | 14.693 | 6.79 / 2.95 | 31.0 / 34.3 / 39.2 || 3 base `1bdee60` | 34.343 | 34.625 | 24.24 / 8.87 | 140.8 / 344.3 / 168.4 || 4 HEAD | 9.959 | 14.696 | 6.80 / 2.95 | 31.0 / 34.6 / 39.1 || 5 HEAD with round-5 knobs (`TSHARD=none DEC_CHAIN=0 L3T=0 HOST_RESIZE=cv2`) | 10.585 | 15.360 | 7.30 / 3.09 | 31.5 / 40.4 / 39.7 || 6 HEAD | 9.954 | 14.692 | 6.80 / 2.95 | 30.4 / 35.3 / 40.3 || 7 HEAD with **every revert knob** set (all `R*` switches + host oracles) | 34.348 | 34.641 | 24.24 / 8.87 | 140.4 / 346.9 / 168.0 |
Claims vs my measurements:
| claim (OPT_REPORT) | claimed | measured | ||---|---|---|---|| baseline device frame | 34.15-34.35 ms | 34.34 ms | confirmed || current device frame | 9.970 / 9.977 ms | 9.954-9.997 ms | confirmed (-71 % vs base) || current frame with ego motion | 14.69 ms (was 34.45) | 14.69 ms | confirmed || round-6 step (R6.1-R6.3) | 10.575 -> 9.97 ms | 10.585 -> 9.95-10.00 ms | confirmed || e2e synthetic 1600x900 | 30.9-31.1 ms (baseline 147-173) | 30.4-31.0 ms (base 139.9-140.8) | confirmed || e2e PandaSet 1920x1080 | 36.4 ms (baseline 353) | 34.3-35.3 ms (base 344-350) | confirmed (slightly better than claimed) || e2e nuScenes + poses | 38.8-40.4 ms (baseline 172) | 39.1-40.3 ms (base 168-170) | confirmed || revert knobs restore the old path | each round lists them | Arm 7 builds with all of them at once and reproduces the base frame time (34.348 vs 34.344 ms) | confirmed |
## 3. Soak / flakiness (shipped default path)
`soak.py` makes 600 `model()` calls on the nuScenes 3-frame cycle (ego poses, moving AlignBEV) and 600 on thePandaSet 3-frame cycle (1920x1080 resize path). That is 1200 frames, or >= 3600 trace replays (encode + decode + ringupdate). The cycle is periodic, so once the history is full, call i must be bit-identical to call i-3.
The result is **0 mismatches, exactly 3 distinct outputs per loop, no hang, rc 0**. e2e p50 was 39.8 / 34.3 ms and p9952.6 / 48.0 ms. Each loop had one outlier of 0.59 / 1.08 s; these are probably the first calls. My first soak attempt(`soak_try1_hashbug.*`) hashed the response envelope, which contains timing and frame metadata, so every call"differed". I fixed it to hash boxes / scores / labels / velocities only. That was a bug in my script, not a model issue.
## 4. Audit
- **Gates:** none loosened (see section 1). One new device test was added: `test_bevpool_device`, which checks `BEVPOOL=device` against the host twin with a <= 4 ulp bound in <= 0.01 % of values. It runs only with that knob, and the default skips it.- **Untested defaults:** none. Every `serve.env` knob equals its `KNOBS` default, and the host test checks this. Every default-on knob (`STEM_IN=kin` ... `L3T=1`) has a same-session A/B and a gate run in OPT_REPORT, and this run re-proves the combined default. `BEVPOOL` defaults to `host`. `UPK_TERMS` defaults to 1, the gate-green form.- **Precision changes:** R3.3 (`HEAD2=hs`, fp32 K-block order) and R5.1 (`UPSAMPLE=kernel`, TF32-rounded interpolation weights) are not bit-identical. Both are covered by the full gate set, including real PandaSet / nuScenes frames. All other rounds are bit-identical: the frozen-gate values printed by this run are identical to the round-6 final run.- **Hangs:** the only recorded hang is the round-7 experimental `bpk` grouped / NB=4 form (`.device.FAULT` 09:50 UTC, cleared 13:48 UTC). It is not in the default path.
## Issues (non-blocking)
1. **sample0 recall is exactly at its frozen gate (50 / 52; threshold 0.9615; 51 / 52 at freeze) since R5.1.** The gate is green, but it has zero margin. Any further precision change will fail it. R7's exact device BEVPool recovered 51 / 52, which shows the margin comes from the BEVPool / up-sampling summation order.2. **`BEVDET_BEVPOOL=device` is selectable, but its last form hangs the chip at the model shape.** It needs only an env var and is guarded only by docs (SERVING.md "experimental, not served"). The committed default (NB = 1, consecutive groups) is the form that ran and passed the gates. However, OPT_REPORT has no soak or A/B for it. I recommend a hard opt-in (e.g. refuse unless an `_EXPERIMENTAL` flag is set), or a soak, before anyone enables it.3. **OPT_REPORT doc nits.** The "Summary" table still shows only baseline vs release, not the current 9.97 ms / 31 ms. In the Steps table the R6 row comes before R5.4. **Republish prerequisite.** The in-container ETH stress test of >= 2000 frames is still to be run at packaging. My 1200-frame host soak does not replace it.
## Addendum: republish preparation (2026-10-14, after this verification)
What changed after the run above, and what the republish checks found. Evidence: `logs/bevdet/republish/`.
- **ttaw 0.23.4 re-vendored** (common `9dd4abf`; only `ops/segment.py` and its kernel changed, which BEVDet does not use). `patches/` gains the SYS-1419 reshape patch that the tt-metal tree, every optimization round and the image carry; the image's verify step now checks it (source, library, ttaw). Host suite 164 passed, then 165 with the new test below.- **Finding: WORKER dispatch did not load at the optimized defaults.** On the 11×10 grid, `tt.linear1x1` applied a 1D matmul config that had been probed on the 12×10 grid. layer1.0 conv1 then failed with `TT_FATAL per_core_M (20) must be divisible by out_block_h (6)` at trace capture (`bench_worker.log`). This also breaks the documented fallback of a tt-metal without the ETH patch. Neither the optimization rounds nor this verification ran WORKER. Fix `3efa0f5`: a probed config runs only where it is valid on the device grid, and the conv uses the stock `conv2d` otherwise. On the 12×10 grid the fix is a no-op. After the fix, WORKER gives 10.343 ms back to back (`bench_worker_try2.log`), and its gates (`test_pcc_device`, `test_e2e_device`, `test_streams_device`, read-only) give 20 passed with the same values as ETH (`worker_gates.log`).- **Card job at the shipped defaults** (`a04770a`, `job_card.sh`, host load 9-10 during a package build): device suite 34 passed / 2 skipped read-only, gate md5 unchanged, values identical to section 1. b2b frame 9.988 ms (14.712 with ego motion). `model()` p50 34.6 / 39.7 / 42.4 ms (synthetic / PandaSet / nuScenes), higher than section 2 because of the host load. nuScenes mini_val mAP / NDS 0.3658 / 0.4354 (ego) and 0.2533 / 0.2742 (node).- **Issue 3 (doc nits)** fixed in OPT_REPORT: the Summary now has a second-release column, and the R5 / R6 rows are in order. **Issue 2** (the `BEVPOOL=device` opt-in) is unchanged in code. The card, SERVING and PYTHON call it experimental and not served, and the image pins `BEVDET_BEVPOOL=host`. **Issue 4**: the in-container stress is in PUSH_READY.md.OPT_BASELINE.mdDeleted-574
OPT_REPORT.mdDeleted-647
VERIFICATION_2026-10-08.mdDeleted-193
VERIFICATION_OPT_2026-10-14.mdDeleted-98