From 329dee99deb9479cc6e899a9c4ccac80879daf92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Thu, 10 Sep 2026 04:37:58 +0300 Subject: [PATCH] docs(av1): lane-b128res report -- the parked 128 residual arm re-measured after edge128: the bars 2160p 8-sample mismatch is gone (cdef owner map), the arm stays inert at 0.4-1.9 writer fires/frame with flat BD on both gates, disposition stays-off; pins unmoved at 8291 / 33227 --- lanes/b128res.charter.md | 70 +++++++++++++++++++ lanes/b128res.report.md | 144 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 214 insertions(+) create mode 100644 lanes/b128res.charter.md create mode 100644 lanes/b128res.report.md diff --git a/lanes/b128res.charter.md b/lanes/b128res.charter.md new file mode 100644 index 00000000..9400d8e9 --- /dev/null +++ b/lanes/b128res.charter.md @@ -0,0 +1,70 @@ +# lane-b128res — re-measure the parked 128 residual arm after edge128 + +GOAL: `EC_AV1_B128RES` is written, witnessed, and OFF because (1) RD took it +0-2 times/frame (inert) and (2) bars 2160p q=90 frame 11 disagreed with +ffmpeg by 8 luma samples at a 128 block's horizontal edge. lane-edge128 +claimed that mismatch was CDEF search pricing four indices under a root +that carries one literal, fixed with an owner map. This lane decides +whether the residual arm can ship. + +Work ONLY in this worktree (`lane-b128res`). Never touch main, never +push, never `git checkout `, never repo-wide `cargo fmt`. +`export CARGO_TARGET_DIR=$HOME/.cache/cargo-target-b128res` on every cargo +command. Logs under `~/.cache/b128res/`. TMPDIR only on gate command +lines, not on the sccache server. Gates: `systemd-run --user -p MemoryMax=14G`, +`--ignored --exact` on both BD tests (they are `#[ignore]`; without +`--ignored` they measure nothing). One gate at a time; record LOADAVG +before AND after. Pins 8291 / 33227. Keep rule: one film row ≥0.5 BD +down on a column, the other flat within ±0.3, screen not worse by 0.3, +wall ≤+15%. Sign: BD-rate, lower better. + +## 1. Refute or confirm the 8-sample mismatch (do this FIRST) + +Recipe: the native bars 2160p row, `EC_AV1_B128RES=1`, q=90, the frame +and rows named in `encode.rs` `b128_residual` (frame 11, luma rows +126..127, cols 1611..1616). Compare encoder reconstruction vs ffmpeg vs +`decode_stream`. Cite the command. + +- If the 8 samples are STILL wrong: STOP. Do not ship. Report the + remaining mismatch (class, path:line). Leave the default off. +- If they are gone: continue. + +INVARIANT from lane-ab128: a skip-only 128-wide piece writes no +`cdef_idx`. `cdef_unit_owner` currently only special-cases `Whole128`. +The residual arm IS Whole128. Do not extend the owner map to Rect128/Ab128 +in this lane unless you turn those pieces into residual carriers — that +is a different lane. + +## 2. If the mismatch is gone: measure + +Control = default (B128RES off) on this HEAD. Arm = `EC_AV1_B128RES=1`. + +- `cargo test -p ec-av1 --release --lib -- --ignored --exact --nocapture encode::tests::bd_rate_film_long_gop` + (deciding). Both films. +- 12-frame guard: `encode::tests::bd_rate_screen_native` with + `EC_AV1_NATIVE_FILM=1` then `EC_AV1_NATIVE_FILM4K=1` then the screen + arm, or however the standing table ran them — all five 12-frame rows. +- Residual fire count: `take_b128_residual_hits` / writer + `take_sb128_residual_hits` on the long-GOP arm. If still 0-2/frame, + it is still inert even if exact. + +Keep → default ON (and drop the "filter mismatch" paragraph). Inert + +exact → leave OFF, but rewrite the comment so it no longer names an +open filter bug. Mismatch remains → OFF, report. + +## 3. Witness / pins / suite (only if you change the default) + +Pins at default and `EC_AV1_SPEED=6`. Existing residual witnesses +(`a_128_root_block_with_a_real_residual_decodes_exact_through_both_decoders` +and the CDEF-covered-units one) `--ignored`. Workspace check +`timeout 900 cargo check --workspace --all-targets -j4` (0 ec-av1 +warnings). Do NOT run the full lib suite unless you change the default; +if you do, three lanes: `--skip stream::` / `stream:: --skip 10bit` / +`10bit`. + +## DONE + +Commit on `lane-b128res` + `lanes/b128res.report.md` with EVIDENCE lines +(`EVIDENCE: | | `), fire counts, BD +table, mismatch gone/still, disposition `ships-on | stays-off | stopped`. +Never merge or push. diff --git a/lanes/b128res.report.md b/lanes/b128res.report.md new file mode 100644 index 00000000..903b3b35 --- /dev/null +++ b/lanes/b128res.report.md @@ -0,0 +1,144 @@ +# lane-b128res — the parked 128 residual arm after edge128 + +Base: `6de54e81` (lane-b128res worktree). Disposition: **stays-off**. +`EC_AV1_B128RES` keeps its default (off). Pins untouched at 8291 / 33227 +(no default change, so no pin run). Never merged, never pushed. + +## 1. The 8-sample mismatch: GONE + +lane-edge128's diagnosis was right: `read_cdef` codes ONE literal for the +block that first reaches a unit and copies it over every unit the block +spans, while the encoder's CDEF search priced a preset per 64x64 unit — +`crate::tile::cdef_unit_owner` (tile.rs) collapses the four to the one the +decoder derives. On this HEAD the parked recipe re-measures clean: + +- Command: `systemd-run --user -p MemoryMax=14G --wait --unit=b128res-probe + bash -lc 'cd && CARGO_TARGET_DIR=$HOME/.cache/cargo-target-b128res + EC_AV1_B128RES=1 cargo test -p ec-av1 --release --lib -- + encode::tests::b128res_mismatch_probe --ignored --exact --nocapture'` + (throwaway probe, removed after the run; recipe = the gate's own: + bars 2160p fixture, `gate_crop` window 1920x1024:960:568, 12 frames, + `encode_sequence_with_ctx(…, 90, …)`). +- frame 11 q=90, luma rows 126..127 cols 1611..1616 (idx 243531..243536, + 245451..245456): encoder reconstruction == ffmpeg == decode_stream, all + eight samples read 107. Whole stream (12 frames, Y/U/V): three-way EXACT. +- Broader: with `EC_AV1_B128RES=1` BOTH BD gates passed their standing + three-way exactness assertion (encoder == ffmpeg == decode_stream) at + every clip x every q point x every frame — 5 clips x 4 q x 12 frames and + 2 films x 4 q x 48 frames. + +EVIDENCE: ~/.cache/b128res/probe-mismatch.log | EC_AV1_B128RES=1, q=90, +frame 11, rows 126..127 cols 1611..1616 + whole-stream sweep | 8/8 samples +agree (all 107); 0 differing samples in any plane/frame; "whole stream +three-way EXACT". LOADAVG 1.96/2.43/3.42 before, 2.44/2.51/3.41 after. + +## 2. Long-GOP BD (deciding; 48 pictures, gop=48, both films) + +Control = default (off), arm = `EC_AV1_B128RES=1`, same HEAD, same ladder +(`encode::tests::bd_rate_film_long_gop`, `--ignored --exact`). BD-rate, +lower better: + +| row | off vs libaom | off vs rav1e | on vs libaom | on vs rav1e | +|---|---|---|---|---| +| film A (1080p) 1920x768 | +20.9% | -9.0% | +20.8% | -9.1% | +| film B (2160p HDR) 1920x1024 | +70.4% | -2.2% | +70.5% | -2.1% | + +Wall ours: film A 542.3s -> 549.8s (+1.4%), film B 422.9s -> 445.5s (+5.3%). +Control reproduces the standing table (film B +70.4/-2.2) to the digit. + +EVIDENCE: ~/.cache/b128res/longgop-control.log | gate 2a, MemoryMax=14G | +film A +20.9%/-9.0%, film B +70.4%/-2.2%. LOADAVG 2.64/2.57/3.07 before, +3.44/2.79/2.76 after. +EVIDENCE: ~/.cache/b128res/longgop-arm.log | gate 2b, EC_AV1_B128RES=1, +MemoryMax=14G | film A +20.8%/-9.1%, film B +70.5%/-2.1%. LOADAVG +3.35/2.80/2.76 before, 3.07/3.53/3.19 after. + +## 3. 12-frame native guard (all five rows) + +`encode::tests::bd_rate_screen_native`, control and arm: + +| row | off vs libaom | off vs rav1e | on vs libaom | on vs rav1e | wall ours off->on | +|---|---|---|---|---|---| +| bars 1080p | -3.3% | -19.0% | -3.4% | -18.9% | 160.4s -> 164.4s | +| bars 2160p | +8.4% | -13.9% | +8.4% | -13.9% | 137.1s -> 143.7s | +| film A | +17.9% | -6.3% | +17.8% | -6.4% | 144.2s -> 145.0s | +| film B | +22.6% | -3.8% | +22.6% | -3.8% | 122.8s -> 123.8s | +| screen capture | +14.4% | -33.2% | +14.5% | -33.2% | 94.9s -> 94.3s | + +EVIDENCE: ~/.cache/b128res/native12-control.log | gate 3a, five rows, +MemoryMax=14G | table above, "off" columns. LOADAVG 2.38/3.32/3.13 before, +3.63/3.57/3.34 after. +EVIDENCE: ~/.cache/b128res/native12-arm.log | gate 3b, five rows, +EC_AV1_B128RES=1, MemoryMax=14G | table above, "on" columns; three-way +sample exactness held at every point. LOADAVG 3.42/3.53/3.33 before, +3.32/3.23/3.27 after. + +## 4. Residual fire counts (writer `take_sb128_residual_hits`) + +Per clip, cumulative over the run's four-q ladder (12-frame rows: 48 +encoded frames; long-GOP rows: 192): + +| clip (frames encoded) | search won | writer coded | per frame | +|---|---|---|---| +| bars 1080p (48) | 1567 | 63 | 1.3 | +| bars 2160p (48) | 985 | 32 | 0.7 | +| film A 12f (48) | 2331 | 92 | 1.9 | +| film B 12f (48) | 1797 | 47 | 1.0 | +| screen capture (48) | 307 | 61 | 1.3 | +| film A long-GOP (192) | 10205 | 320 | 1.7 | +| film B long-GOP (192) | 6056 | 75 | 0.4 | + +0.4-1.9 fires/frame against thousands of whole 128 roots — still INERT, +exactly the historical 0-2 band. The census is now a permanent line of the +native arm ("128x128 roots … with a residual … (search) / … (writer)"), so +the next reader does not need a custom run. + +## 5. Keep rule — NOT met + +One film row >=0.5 BD down on a column: best delta anywhere is -0.1 +(film A long-GOP and 12-frame). Other film row flat within +/-0.3: yes +(+0.1). Screen not worse by 0.3: yes (+0.1). Wall <= +15%: yes (max +5.3%). +The deciding column fails, and the arm is inert. Inert + exact = the +charter's stays-off branch. + +## 6. Witnesses (both `--ignored`, run standalone) + +- `a_128_root_residual_block_under_a_per_unit_cdef_list_decodes_exact`: + PASS as-is — writer coded 566 residual 128 blocks, 24 CDEF units taking + another unit's literal, byte-exact through both decoders. This is the + witness lane-edge128 built for the exact interaction that used to break + bars 2160p. +EVIDENCE: ~/.cache/b128res/witness-cdef.log | --ignored --exact run | +"writer coded 566; covered 24", ok. LOADAVG 2.03/2.21/3.13 before, +2.72/2.36/3.15 after. +- `a_128_root_block_with_a_real_residual_decodes_exact_through_both_decoders`: + was RED on its precondition at its fixture q (150: writer coded 0) and + still at 90 — the forced residual arm replaces the skip arm's cost + unconditionally, and the cost model moved under it since lane-b128r + (lane-rectdq's delta_q group on every non-skipped root; the pyramid's + per-level q), so the NONE root lost its partition at all 420 roots and + nothing reached the writer. Fixture re-vitalized at q=60: writer coded + 52, byte-exact through both decoders, PASS. q change + a doc paragraph + naming the drift class are in the commit; the `coded > 0` assert stays + as the guard. +EVIDENCE: ~/.cache/b128res/witness-residual.log (q=90, FAILED, writer 0), +witness-residual-q60.log (q=60, "search won 420, writer coded 52", ok). + +## 7. Changes on the lane + +- encode.rs `b128_residual` doc: the "open filter bug" paragraph is + replaced by the closed story (owner map, re-measured three-way EXACT) + and the inertness numbers; the knob stays as the arm's gate. +- encode.rs `native_bd_arm`: one census line added — residual fires + (search/writer) next to the standing 128-root census. +- encode.rs pan residual witness: fixture q 150 -> 60 + drift note. +- Throwaway probe removed after its run. + +## 8. Non-goals respected + +Rect128/Ab128 residual pieces (a rect half carrying a residual still +refuses in `write_inter_block_128_rect`, owner map still Whole128-only), +merging, pushing, full workspace suite (default did not flip). Media files +read-only; all runs gated under `systemd-run --user -p MemoryMax=14G`, one +gate at a time, `--ignored --exact` on the ignored tests, logs under +`~/.cache/b128res/`.