forge
Explore
Log in

Don't you dare go Hollow

Lane-tiny r3 report -- root cause, fix, gate deltas, open residual

Browse files at this commit

c0807202163f951d8a304d5af75e7b7b002c81daAhmet Kaan GümüşParent: 3f037c3
  • docs
    • lane-tiny r3 report -- root cause, fix, gate deltas, open residual
Show full message
docs(av1): lane-tiny r3 report -- root cause, fix, gate deltas, open residual
lanes/tiny-r3.report.mdadded+130 -0
@@ -0,0 +1,130 @@
1+# lane-tiny r3 report
2+
3+## Coefficient range ladder result
4+
5+Added `EC_TRACE_COEFF` per-symbol range tracing to `read_coeffs` (decode.rs,
6+tags `all_zero`, `tx_type`, `eob`, `base_eob`, `after_bases`, `sign`,
7+`post_golomb`) matching the oracle's existing `decodetxb.c` instrumentation
8+(same var name, same tags -- oracle needed two more trace points added,
9+`all_zero`/`tx_type` entry ranges, rebuilt via `ninja aomdec` in
10+`~/.cache/aom-oracle/build`).
11+
12+Ran both against the pinned seed-45 32x32 fixture
13+(`$SCRATCHPAD/seed45.obu`, CFL + filter_intra DC_PRED block,
14+`filter_intra_mode=3`).
15+
16+**`all_zero` matched exactly** (ctx=1, all_zero=0, rng=52448 both sides) --
17+the very first symbol of the coefficient layer was clean.
18+
19+**Divergence: the very next symbol, `tx_type`.** Ours exited at rng=37340,
20+oracle at rng=42464. Direction: both consumed a symbol (range narrowed from
21+the same 52448 entry state) but landed on different final ranges -> a wrong
22+CDF *row* was read, not a missing/extra read (both sides read exactly one
23+tx_type symbol here).
24+
25+## Root cause
26+
27+`av1_read_tx_type` (libaom `decodemv.c:646`): for an **intra** block whose
28+`filter_intra_mode_info.use_filter_intra` is set, the `intra_ext_tx_cdf` row
29+index is
30+
31+```c
32+const PREDICTION_MODE intra_mode =
33+ mbmi->filter_intra_mode_info.use_filter_intra
34+ ? fimode_to_intradir[mbmi->filter_intra_mode_info.filter_intra_mode]
35+ : mbmi->mode;
36+```
37+
38+`fimode_to_intradir = { DC_PRED, V_PRED, H_PRED, D157_PRED, DC_PRED }`
39+(`blockd.h:180`) -- **not** the block's ordinary `mode`, which is always
40+`DC_PRED` whenever filter-intra is active (spec: filter-intra blocks always
41+carry `mode == DC_PRED`, the interesting information is in
42+`filter_intra_mode`). Every `read_plane` call site in `decode.rs` passed the
43+block's plain `mode` (here `DC_PRED == 0`) as `tx_mode` regardless of
44+filter_intra, so the CDF lookup always used the DC_PRED row instead of
45+`D157_PRED` (index 6) for `filter_intra_mode=3`. Wrong row -> wrong symbol ->
46+correctly-consumed bits but wrong resulting range and wrong `tx_type`, and
47+everything downstream (scan order, base/br contexts) reads off the wrong
48+axis from the very first coefficient TU on.
49+
50+## What shipped
51+
52+**Fix**, `crates/ec-av1/src/decode.rs`, `read_plane` (the single shared
53+chroma/luma coefficient entry point every multi-TU and single-TU luma call
54+routes through): when `plane_idx == 0` and `filter_intra` is `Some(mode)`,
55+remap `tx_mode` through `FIMODE_TO_INTRADIR = [DC_PRED, V_PRED, H_PRED,
56+D157_PRED, DC_PRED]` before the `cdfs.txb(set, tx_mode)` lookup. Added
57+`H_PRED`/`D157_PRED` consts (matched libaom's numbering: DC=0, V=1, H=2,
58+D157=6, verified against `crates/ec-av1/src/intra.rs`'s existing constants).
59+
60+One fix point covers every caller (chroma is unaffected by construction --
61+`plane_idx != 0` never touches the new branch, and chroma has no
62+filter-intra in AV1 to begin with).
63+
64+**Gate**: the existing `probe_tiny_frame_size_boundary` diagnostic sweep
65+(size x seed matrix, real aomenc + ffmpeg oracle) now shows:
66+
67+| size | before | after |
68+|-------|--------|-------|
69+| 32x32 | 3/10 | **10/10** |
70+| 24x24 | 3/10 | **10/10** |
71+| 16x32 | 2/10 | **10/10** |
72+| 32x16 | 2/10 | 8/10 (residual, see Open) |
73+| 16x16, 48x48, 64x64 | 10/10 | 10/10 (unaffected, already clean) |
74+
75+This is a `#[ignore]`d diagnostic, not a hard-asserting gate (matches its
76+pre-existing shape from r1/r2; converting it into a hard-asserting
77+`stream.rs` gate in the `a_real_aomenc_*` style is the natural next step but
78+did not fit this round's budget -- flagged in Open below).
79+
80+## Investigated and REJECTED as a fix
81+
82+Chased a second lead from the same trace session: the chroma `txb_skip_ctx`
83+computation (`usize::from(around.0) + usize::from(around.1)`, range 0..2)
84+looked wrong against libaom's `get_txb_ctx`'s chroma branch, which is
85+`get_entropy_context(...) + ctx_offset` where `ctx_offset` is 7 (chroma
86+plane_bsize == tx size, i.e. always true here since chroma is never split
87+into multiple TUs in this decoder). Oracle traced `ctx=7` where ours prints
88+`ctx=0` for the identical read -- **but this is not a bug**: our
89+`txb_skip_chroma_8`/`_16`/`_32`/`_4` CDF tables (`cdf_state.rs`) are already
90+pre-sliced 3-row extracts of the full 13-row spec table taken at the correct
91+7/10 offset (`TXB_SKIP_CHROMA_8` etc., confirmed by grep at their
92+initializer). Index 0 in our local table *is* spec index 7 -- the two
93+printed "ctx" numbers are in different local bases for the same CDF row,
94+which is exactly why the traced range matched exactly in that instance.
95+Applying a `+ 7` there panicked immediately (`index out of bounds: len 3,
96+index 7`) on the very first refused-8x8-then-16x16 case, confirmed the
97+tables are chroma-relative already, and was reverted in full before commit
98+(`git diff` verified clean, no residue in the shipped commit).
99+
100+## Open (not shipped this round)
101+
102+- **32x16 residual, 2/10 seeds**: `first_diff=None, ndiff_luma=0/512` --
103+ luma is bit-exact, only chroma differs, for exactly 2 of 10 seeds at one
104+ specific rectangular aspect (32x16, not its transpose 16x32 which is now
105+ 10/10). Not characterized further this round (budget). Not gated or
106+ refused -- this is a real "wrong pixels returned as success" gap per the
107+ charter's own standard, scoped narrower than what shipped fixed. Next
108+ round: re-run the same `EC_TRACE_COEFF`/`EC_TRACE_MODE_STEP` ladder on one
109+ of the two failing 32x16 seed-47/42 fixtures (pin them first, aomenc
110+ output is seeded but re-verify determinism per
111+ `seeded-fixture-not-reproducible.md`) to find the actual desync point --
112+ it is chroma-only, so start with the chroma predict path / CFL /
113+ uv_predict_mode rather than the luma tx_type fix's territory.
114+- `probe_tiny_frame_size_boundary` is still `#[ignore]`d and non-asserting.
115+ Promoting it to a hard-asserting gate under `stream.rs` (model:
116+ `a_real_aomenc_*_decodes_pixel_exact`, `EC_AV1_REQUIRE_AOMENC=1`,
117+ hard-assert a hit counter, no printed SKIP on decode error) is the
118+ natural follow-up once the 32x16 residual is closed too -- gating it now
119+ would either need to accept 32x16 as a known-flaky size (against the
120+ charter's own "never mismatch" rule) or hard-code a size exclusion, both
121+ of which are worse than finishing the fix.
122+
123+## Verification
124+
125+- `cargo test -p ec-av1 --lib`: **266 passed, 0 failed, 22 ignored** (221s).
126+- `cargo check --workspace --all-targets`: clean, 0 errors.
127+- HEAD: `1a89ed9` (branch `lane-tiny`).
128+
129+EVIDENCE: `cargo test -p ec-av1 --lib -- --ignored --nocapture probe_tiny_frame_size_boundary` | 32x32/24x24/16x32 3-or-2-of-10 -> 10/10, 32x16 2/10 -> 8/10, all other sizes unchanged at 10/10 | before/after table above
130+EVIDENCE: EC_TRACE_COEFF range ladder, seed45.obu, oracle vs ours | all_zero ctx=1 all_zero=0 rng=52448 matches both sides; tx_type exit rng 37340 (ours) vs 42464 (oracle) is the first divergent element | fixed by filter-intra tx_type CDF row remap, commit 1a89ed9