forge
Explore
Log in

Don't you dare go Hollow

Lane-rectdq report — control vs arm on both gates, pins unmoved, suite green

Browse files at this commit

619bdeb88b8c6809f24679f014f0f3d9c30ba489Ahmet Kaan GümüşParent: dc9d340
  • docs
    • lane-rectdq report — control vs arm on both gates, pins unmoved, suite green
Show full message
docs(av1): lane-rectdq report — control vs arm on both gates, pins unmoved, suite green
lanes/rectdq.report.mdadded+131 -0
@@ -0,0 +1,131 @@
1+# lane-rectdq — the 128 rect root pays for the delta_q group it codes
2+
3+Branch `lane-rectdq` off main 748e4328. Class name: **pricer omits a group the
4+writer codes** (sibling of `pricer-context-zero`: there the pricer priced the
5+right tree at the wrong context, here it priced a tree with a whole symbol
6+group missing).
7+
8+## The defect
9+
10+`crate::tile::write_delta_q` codes its symbol group for every block that sits
11+at its superblock's mode-info origin, with ONE exception: a block that is the
12+whole superblock AND is skipped (`if is_whole_sb && skip { return }`), which
13+mirrors decode.rs' `whole_sb = (side == write_w == write_h == sb_px)`.
14+
15+So at a 128 superblock root:
16+
17+| root shape | codes the delta_q group? | was it priced? |
18+|---|---|---|
19+| `PARTITION_NONE`, skipped | no | n/a (correct) |
20+| `PARTITION_NONE`, residual (`EC_AV1_B128RES`) | yes | NO |
21+| `PARTITION_HORZ`/`VERT` halves (first half only) | yes | NO |
22+| four 64 superblocks under a 128 grid (first cell) | yes | NO |
23+
24+The rect arm and the split arm were both under-priced by the group's bits on
25+every root of every frame that arms a delta_q plan (preset 0 has objective tpl
26+delta_q on, `DQ_TPL_K`) — the rect arm was measured against a NONE arm that
27+really is free, so it looked cheaper than it is. The class sweep
28+(`grep -n write_delta_q crates/ec-av1/src/tile.rs`) found the four writer sites
29+beyond the two 128 ones (Whole64 at `!sb128_armed()`, the 32 square, and both
30+inter leaves); under a 128 grid every one of them passes `is_whole_sb = false`,
31+which is why the four-superblock arm is charged here too.
32+
33+## The fix
34+
35+* `encode::delta_q_bits(target, cur, res)` — the writer's own three pieces in
36+ the writer's order, priced through a `SymbolEncoder::pricer` rather than a
37+ sum of table entries, because the escape's literal bits are equiprobable
38+ SYMBOLS carrying the `EC_MIN_PROB` floor and cost a little over one bit each
39+ (class `price-the-narrowing-not-the-table`; a table-entry sum was 0.43 bits
40+ light at `abs = 20`).
41+* `encode::delta_q_bits_at_root(...)` — the charge at one 128 root: the target
42+ is the root's own `sb_q` cell, exactly the entry `write_delta_q` indexes.
43+ **Stated approximation:** the writer's `CurrentQIndex` (`plan.cur`) is not
44+ knowable in the search — it only advances at the roots that really code a
45+ group, and which those are is what this very comparison decides — so the
46+ PREVIOUS 128 root's target in raster order stands in for it (`base_q_idx` at
47+ the first root, which is also the writer's per-tile reset). Wrong only where
48+ a neighbouring root came out a skipped NONE block, and then only by the
49+ difference between two adjacent tpl cells.
50+* Charged in `search_root_128_rect` for the FIRST half only (the second half
51+ sits at a non-origin mi and codes no group — `write_inter_block_128_rect`,
52+ tile.rs:517), in `search_root_128` only when the block is NOT skipped, and on
53+ the four-superblock side of the root comparison.
54+* `EC_AV1_RECTDQ=0` is the attribution control (pre-lane pricing).
55+
56+## Witness
57+
58+`tile::tests::the_delta_q_pricer_matches_the_writer_over_the_whole_domain`
59+enumerates the domain — `delta_q_abs` steps -20..=20, both signs, `res = 4` —
60+running `write_delta_q` into a pricing coder and comparing its `bits()` account
61+against `delta_q_bits`. Agreement is exact (`< 1e-9`), plus the disarmed case.
62+
63+ cargo test -p ec-av1 --release --lib -- --exact \
64+ tile::tests::the_delta_q_pricer_matches_the_writer_over_the_whole_domain
65+
66+Result: ok, 1 passed.
67+
68+## Gates (lower BD = better; control = `EC_AV1_RECTDQ=0`, arm = default)
69+
70+12 frames, `encode::tests::bd_rate_screen_native`, all five rows
71+(`~/.cache/rectdq/s.log`):
72+
73+| row | vs libaom ctl → arm | vs rav1e ctl → arm | wall ours ctl → arm |
74+|---|---|---|---|
75+| bars 1080p | -3.4% → **-3.5%** | -19.0% → **-19.1%** | 186.2s → 189.2s |
76+| bars 2160p | +8.4% → +8.4% | -14.0% → -14.0% | 160.2s → 181.4s |
77+| film A | +18.0% → +18.0% | -6.3% → -6.3% | 177.6s → 179.1s |
78+| film B | +23.0% → **+22.8%** | -3.5% → **-3.7%** | 155.9s → 138.5s |
79+| screen capture | +14.4% → +14.4% | -33.2% → -33.2% | 144.6s → 106.9s |
80+
81+48 frames, `encode::tests::bd_rate_film_long_gop` (`~/.cache/rectdq/g.log`):
82+
83+| row | vs libaom ctl → arm | vs rav1e ctl → arm | wall ours ctl → arm |
84+|---|---|---|---|
85+| film A (`EC_AV1_NATIVE_FILM=1`) | +21.9% → +22.0% | -8.6% → -8.5% | 655.6s → 698.9s |
86+| film B (`EC_AV1_NATIVE_FILM4K=1`) | +75.8% → **+75.7%** | +0.8% → **+0.7%** | 494.1s → 464.7s |
87+
88+Wall: every row inside +15% (the +13% on bars 2160p and +6.6% on long-GOP film
89+A are contention — two gate units shared the box, and the arm's own film B rows
90+came out FASTER on both gates; the search does one extra pricer call per root).
91+
92+**Keep rule, honestly:** not met as written. No row goes >=0.5 down. The arm is
93+BD-NEUTRAL: the largest move in either direction is 0.2 (12f film B, down on
94+both columns), long-GOP film B is 0.1 down on both, long-GOP film A is 0.1 UP
95+on both, screen is byte-identical. It ships default-on as a CORRECTNESS fix
96+(the pricer now prices the tree the writer writes, witnessed exactly), not as a
97+win; the b128hv "+0.1 on the 12-frame film rows" premise this lane was chartered
98+from is not explained by the missing group — the group is worth ~2-9 bits a
99+root against roots costing thousands.
100+
101+## Pins
102+
103+`encode::tests::the_encoders_own_streams_are_byte_identical_to_their_pins` PASS
104+at default and at `EC_AV1_SPEED=6` — the pins did NOT move (the pin fixtures
105+arm no delta_q plan, so `delta_q_bits_at_root` returns 0 there).
106+`encoder::tests::every_speed_preset_decodes_sample_exact_through_both_decoders`
107+PASS; `encode::tests::a_128_root_horz_and_vert_halves_decode_exact_through_both_decoders`
108+PASS (`~/.cache/rectdq/p.log`).
109+
110+## Suite
111+
112+Three detached lanes, all green (`~/.cache/rectdq/t.log`):
113+
114+* `cargo test -p ec-av1 --release -j4 -- --skip stream::` — 346 passed, 0 failed, 39 ignored (460s)
115+* `... -- stream:: --skip 10bit` — 202 passed, 0 failed, 15 ignored (927s)
116+* `... -- 10bit` — 42 passed, 0 failed, 1 ignored (66s)
117+* `timeout 900 cargo check --workspace --all-targets -j4` — 0 errors, 0 ec-av1 warnings (the only warnings are the pre-existing ec-vorbis `decode_capture` and ec-opus ones).
118+
119+## Deviations from the charter
120+
121+1. The charter's gate commands omit `--ignored`; both BD tests are `#[ignore]`,
122+ so `--ignored` was added or they would have filtered out silently.
123+2. The 12-frame gate was run WITHOUT `EC_AV1_NATIVE_FILM*` (one run per arm
124+ covering all five rows) instead of two per-film runs: the same two film rows
125+ plus the screen row the keep rule asks for, at half the runs.
126+3. The charge is made on the four-superblock arm as well as on the rect arm
127+ (charter item 2's class sweep) — charging only the rect arm would have
128+ biased the comparison toward SPLIT, which codes the same group. Both are
129+ under the single `EC_AV1_RECTDQ` knob.
130+4. The unit witness lives in `tile.rs`'s test module (it needs the private
131+ `write_delta_q`), not in `encode.rs`.