forge
Explore
Log in

Don't you dare go Hollow

Lane-newmv report -- the NEWMV census, the sweep, and what shipped

Browse files at this commit

629901f364d27b17ec2b68187f2e4973f2f26bc3Ahmet Kaan GümüşParent: 215871e
  • docs
    • lane-newmv report -- the NEWMV census, the sweep, and what shipped
Show full message
docs(av1): lane-newmv report -- the NEWMV census, the sweep, and what shipped
lanes/newmv.report.mdadded+165 -0
@@ -0,0 +1,165 @@
1+# lane-newmv — why we code NEWMV on a fifth of the blocks libaom does
2+
3+Worktree `edith_codecs-newmv`, branch `lane-newmv` off main 6b95562d. Every
4+BD row is the prebuilt release lib-test binary (`bd_rate_screen_native`, 12
5+pictures, `gop 12`, four quantizers, native `gate_crop`; `bd_rate_film_long_gop`
6+for the 48-picture rows), each detached under its own `systemd-run` unit, read
7+off the log's own clip line.
8+
9+## 0. The controls reproduce
10+
11+| row | control (vs libaom / vs rav1e) | charter |
12+|---|---|---|
13+| film A, 12 frames | +21.0 / -4.8 | +21.0 / -4.8 |
14+| film B, 12 frames | +24.9 / -1.9 | +24.9 / -1.9 |
15+| screen, 12 frames | +14.5 / -33.2 | +14.5 / -33.2 |
16+| film A, long GOP | +25.2 / -7.2 | +25.2 / -7.2 |
17+| film B, long GOP | +86.7 / +7.3 | +86.7 / +7.3 |
18+
19+All five land to the digit.
20+
21+## 1. The instrument (`EC_AV1_NEWMV_CENSUS=1`)
22+
23+Per block side: how often a `LAST` `NEWMV` is searched, how often the writer
24+can name the vector (offered to RD), how often it wins, the mean RD margin on
25+each side of the decision, the searched vector's distance from `NEARESTMV`,
26+how often it IS `NEARESTMV`, and its mv syntax bits. Then the two pre-RD
27+margins' skip shares, and the search's own bound witness (class `instrument at
28+bound`: how often the winner was walked to at the log stage's WIDEST step).
29+It rides the guard `EC_AV1_SPLIT_CENSUS` already had in
30+`Av1Encoder::encode_frames`, so it prints on every exit and costs nothing when
31+unset.
32+
33+Film B, gate crop, 12 frames, q=90 — CONTROL:
34+
35+| side | searched | offered | won | won% | win margin | lose margin | \|mv-nearest\| | mv==nearest | mv bits |
36+|---|---|---|---|---|---|---|---|---|---|
37+| 8 | 65296 | 65296 | 13319 | 20.4% | 47 | 26 | 16.48 | 61.3% | 5.90 |
38+| 16 | 25500 | 25500 | 9564 | 37.5% | 106 | 35 | 17.29 | 41.6% | 6.68 |
39+| 32 | 18344 | 18344 | 3627 | 19.8% | 137 | 32 | 9.69 | 54.1% | 5.82 |
40+
41+pre-RD margin skips: extra-reference 86.2%, leaf second reference 4.2%.
42+search: 293394 calls, 69.2 evals/call, 6.35 integer rounds/call; winner within
43+±1 pel of `pred_mv` 54.9%, winner = starting seed 17.4%, moved at the widest
44+step 18.9% of calls.
45+
46+READ IT AS:
47+
48+1. **No margin drops LAST's `NEWMV`.** `searched == offered` in every row: the
49+ candidate reaches RD on every inter block. The two skip margins
50+ (`EXTRA_NEW_SKIP_MARGIN`, `LEAF_SECOND_NEW_MARGIN`) gate only the EXTRA
51+ references' searches. The charter's first hypothesis is refuted by the
52+ instrument.
53+2. **The vectors we do code are the right size.** 5.8-6.7 mv bits per CODED
54+ `NEWMV` against libaom's 3.2-7.5 per BLOCK: the whole census gap
55+ (0.83-2.5 mv bits/block) is the SHARE, not the precision.
56+3. **It loses by very little.** The mean losing margin (26-43 RD units) is a
57+ quarter to a third of the mean winning one — a near-tie decision, i.e. a
58+ population a small change in the search or the rate weight moves.
59+4. **The search is not at its own bound.** Only 18.9% of calls ever move at
60+ the widest log step, so the initial step / distance scale is not what
61+ stops it. But over half its winners sit within ±1 pel of `pred_mv` and
62+ 41-61% of them ARE `NEARESTMV`.
63+
64+## 2. The sweep (film B, 12 frames)
65+
66+| arm | vs libaom | vs rav1e |
67+|---|---|---|
68+| control | +24.9 | -1.9 |
69+| `EC_AV1_MV_LAMBDA=0.5` (block RD mv rate x0.5) | +26.3 | -0.6 |
70+| `EC_AV1_MV_LAMBDA=1.5` | +25.3 | -1.7 |
71+| `EC_AV1_MV_SEARCH_LAMBDA=0.25` | +25.2 | -1.7 |
72+| `EC_AV1_MV_SEARCH_LAMBDA=0.5` | +24.9 | -2.0 |
73+| `EC_AV1_MV_SEARCH_LAMBDA=0.75` | +24.8 | -1.9 |
74+| `EC_AV1_MV_SEARCH_LAMBDA=2.0` | +26.9 | -0.2 |
75+| `EC_AV1_MV_SUBPEL_ITERS=4` | +25.2 | -1.7 |
76+| **`SUBPEL_ITERS=4` + `SEARCH_LAMBDA=0.5`** | **+24.8** | **-2.1** |
77+
78+The chartered lever — the mv RATE term of the BLOCK decision — is
79+**single-peaked at the control on both sides** (0.5 loses 1.4/1.3, 1.5 loses
80+0.4/0.2). That is the third instance of class `rd-rate-term-calibration` on
81+this encoder (lane-txd, lane-split, here): our block-level pricing of a coded
82+vector is already RD-optimal on this content, so the finding the charter named
83+as the fallback holds — it is the SEARCH, not the pricing.
84+
85+The two search-side knobs are new and both are one-liners:
86+
87+* `EC_AV1_MV_SEARCH_LAMBDA` (`motion::MV_SEARCH_LAMBDA`): the search compares
88+ **SAD** while the lambda it is handed is the block RD's **SSE-domain**
89+ weight (`LAMBDA_SCALE * step * step`), so charging mv bits at the full RD
90+ lambda over-prices motion inside the search itself and pins the winner to
91+ `pred_mv`. Halving it is the floor of a clean bowl; doubling it costs 2.0
92+ points.
93+* `EC_AV1_MV_SUBPEL_ITERS` (`motion::MV_SUBPEL_ITERS`): each subpel stage ran
94+ ONE ±1-step round, so a winner two half-pels off the integer centre was
95+ unreachable (class `search bounded by its heuristic`). It re-runs from its
96+ own winner now, up to 4 times, stopping when a round does not move.
97+
98+## 3. What ships
99+
100+`MV_SEARCH_LAMBDA = 0.5`, `MV_SUBPEL_ITERS = 4`. `MV_LAMBDA` stays 1.0 (the
101+knob stays for the next sweep).
102+
103+| row | control | shipped | move |
104+|---|---|---|---|
105+| film A, 12 frames | +21.0 / -4.8 | **+20.6 / -5.1** | -0.4 / -0.3 |
106+| film B, 12 frames | +24.9 / -1.9 | **+24.8 / -2.1** | -0.1 / -0.2 |
107+| screen, 12 frames | +14.5 / -33.2 | +14.6 / -33.2 | +0.1 / 0.0 |
108+| film A, long GOP | +25.2 / -7.2 | **+24.7 / -7.5** | -0.5 / -0.3 |
109+| film B, long GOP | +86.7 / +7.3 | +86.8 / +7.4 | +0.1 / +0.1 |
110+
111+Keep rule met: both film rows improve on both columns at 12 frames; at long
112+GOP film A is 0.5/0.3 down with film B flat inside ±0.3; screen is 0.1 worse,
113+inside the 0.3 the rule allows. Wall (ours, same arm's own line): film A 146.5
114+-> 150.4 s, film B 123.2 -> 131.4 s, film A long GOP 564.9 -> 607.0 s, film B
115+long GOP 417.2 -> 437.7 s — +2.7% to +7.4%, under the 15% ceiling.
116+
117+Decomposed on film A (12 frames): each half alone reads +20.8/-4.9, the pair
118++20.6/-5.1 — they compose. On film B the subpel iteration ALONE loses
119+(+25.2/-1.7) and only pays with the lighter search rate term beside it, which
120+is why the pair ships as a pair.
121+
122+## 4. The mechanism moved, not just the bytes
123+
124+Same census, same clip and quantizer, after the change:
125+
126+| side | won% (was) | mv bits (was) | mv==nearest (was) |
127+|---|---|---|---|
128+| 8 | **30.7%** (20.4) | 7.82 (5.90) | 36.4% (61.3) |
129+| 16 | **46.5%** (37.5) | 8.21 (6.68) | 21.6% (41.6) |
130+| 32 | **23.3%** (19.8) | 6.76 (5.82) | 38.5% (54.1) |
131+
132+The search now spends 81.7 evals/call (was 69.2) and its winner sits within
133+±1 pel of `pred_mv` in 42.6% of calls (was 54.9). The NEWMV share moves toward
134+libaom's 54-76% at 3.2-7.5 mv bits/block, i.e. the BD move is the mechanism
135+the census pointed at — not something else that happened to move bytes.
136+
137+## 5. Pins
138+
139+`the_encoders_own_streams_are_byte_identical_to_their_pins` re-taken with a
140+two-line comment: 8325 -> 8288 bytes at q=150 and 33014 -> 33090 at q=60.
141+Green at the default and at `EC_AV1_SPEED=6`. No other byte pin went red
142+(split suite below).
143+
144+## 6. Gates
145+
146+* split suite, release lib tests: s1 (`--skip stream::`) 339 passed / 0 failed
147+ RC=0; s2 (`stream:: --skip 10bit`) 200 / 0 RC=0; s3 (`10bit`) 42 / 0 RC=0.
148+* `--ignored encoder::tests::every_speed_preset_decodes_sample_exact_through_both_decoders`
149+ 1 passed RC=0.
150+* `cargo check --workspace --all-targets`: 0 errors, 0 ec-av1 warnings.
151+
152+## 7. What this lane did NOT do
153+
154+* `deferred: allow_high_precision_mv` — the writer codes every frame with it
155+ off, so the finest vector the search can commit to is a quarter pel
156+ (`round_to_valid_mv` rounds the residual to an even 1/8-pel count). Whether
157+ 1/8-pel vectors pay is unmeasured; it needs the header bit, the `mv_hp`
158+ symbols and a decode witness first, then this same gate.
159+* `deferred: the mv rate weight of the COMPOUND halves and of the 64x64 skip
160+ root` — `EC_AV1_MV_LAMBDA` reaches the single-reference `NEWMV` candidates
161+ only. Since the single-reference sweep came back single-peaked at 1.0,
162+ re-pricing the compound halves has no measured reason to be different.
163+* `deferred: a per-speed-preset value for MV_SUBPEL_ITERS` — it costs 5-7%
164+ wall at every preset, and the preset ladder's own wall/BD Pareto
165+ (lanes `software speed Pareto`) is where that belongs, not here.