forge
Explore
Log in

Don't you dare go Hollow

Lane-gm r3 report (root cause = missing global-warp prediction path)

Browse files at this commit

4fc67a0b27dc69ea1058acbdb1d86e1ce49222c7Ahmet Kaan GümüşParent: 75017f1
  • docs
    • lane-gm r3 report (root cause = missing global-warp prediction path)
Show full message
docs(av1): lane-gm r3 report (root cause = missing global-warp prediction path)
lanes/gm-r3.report.mdadded+39 -0
@@ -0,0 +1,39 @@
1+VERDICT: ROOT-CAUSED, NOT FIXED -- the interintra-wedge gate mismatch (seed 43, frame 1 luma) is not an mv, mvstack, or entropy bug; it is a missing decoder capability. This decoder never implements AV1's GLOBAL WARP prediction path (`reconinter.c`'s `allow_warp` -> `global_warp_allowed` branch): libaom predicts every `is_global_mv_block` block (ROTZOOM/AFFINE `GLOBALMV`/`GLOBAL_GLOBALMV`, >=8x8, non-force-integer-mv) with the FULL per-pixel affine global-motion warp, independent of `motion_mode` -- our decoder only ever builds a warp prediction for local `WARPED_CAUSAL` and falls back to plain translational MC using the block-centre mv for every other GLOBALMV block. The whole-frame `global_motion != IDENTITY` refusal in `stream.rs` stays in place; it is still correct to refuse.
2+
3+## Method (charter ladder, steps 1-3)
4+
5+**1. Reproduce and pin.** Gated the whole-frame refusal behind a temporary `EC_GM_ALLOW_NONIDENTITY` env var (reverted before commit), ran `EC_WEDGE_GATE_ATTEMPTS=20 EC_AV1_REQUIRE_AOMENC=1 EC_AV1_GATE_DUMP=<scratchpad>/gm-seed43.obu`. Reproduced deterministically first attempt: seed 43, frame 1 luma mismatch, pinned to `gm-seed43.obu`. Decoded the pinned bytes twice via `scratch_isolate_pinned_mismatch` (`EC_AV1_PIN=gm-seed43.obu EC_AV1_PIN_W=64 EC_AV1_PIN_H=64 EC_AV1_PIN_N=24`) -- byte-identical output both runs (only the timing line differed), confirming this is a real deterministic defect, not the documented parallel-flake-is-attempt-selection class.
6+
7+**2. Localize.** `scratch_isolate_pinned_mismatch`'s per-plane diff: frame 0 (key) MATCH on all 3 planes; frame 1 first divergence at luma offset 2048 = **row 32, col 0** (416 mismatches, worst delta 6) -- exactly the top-left corner of the bottom-left 32x32 partition leaf (frame is forced to 32x32 leaves via `--min/max-partition-size=32`), i.e. block `mi=(8,0)`. Frame 1's `global_motion` table (dumped via a temporary debug `eprintln!`, reverted): ref slot 0 (LAST_FRAME) = `Rotzoom { params: [137216, 144384, 61182, -64, 64, 61182] }`, all other refs Identity. `allow_high_precision_mv=false force_integer_mv=false` for this frame.
8+
9+**3. Range ladder (prediction vs entropy).** `EC_AV1_TRACE=1` on our decode: `TRACE part32_pre mi=(8,0) rng=38664` immediately before `EC_TRACE mi_row=8 mi_col=0 skip=0 mv=(-8,8) is_new_mv=false bsize=32 ref=1 motion_mode_eligible=0`. `EC_TRACE=1 aomdec` on the identical pinned bytes: `EC_PART mi_row=8 mi_col=0 bsize=9 ctx=8 tell=1001 rng=38664` (frame 1's own entry, matched by tell-count ordering). **RANGE IDENTICAL: 38664 == 38664** -- entropy decode is in sync through this block's partition/mode symbols. Verdict: PREDICTION-side defect, not a symbol-consumption/CDF bug.
10+
11+## Root cause
12+
13+Hand-verified our `gm_get_motion_vector` (`warp.rs`) against the real oracle's `mv.h:183-286` (`~/.cache/aom-oracle/src/av1/common/mv.h`, foreign implementation, not our own transcription): found and fixed a genuine bug -- `block_center_x`/`block_center_y` (mv.h:183-191) subtract 1 from the halved-block-size offset (`mi_col*MI_SIZE + bw/2 - 1`); our `warp.rs` was missing the `- 1` on both axes. Fixed in `warp.rs`. This is a real spec-conformance bug (kept fixed) but hand-computing both versions for this exact block showed the `-1` shifts `xc`/`yc` by only ~4354 out of a ~16384 rounding threshold in `convert_to_trans_prec` -- **it does not flip the rounded mv for this block** (confirmed empirically: 417 -> 416 mismatches, same first offset, same magnitude, before/after the fix). So it is real but not sufficient, and not the seed-43 root cause.
14+
15+Re-derived `gm_get_motion_vector`'s output for block `mi=(8,0)`, `bw4=bh4=8` by hand with the fixed formula: `x=15, y=47`, giving `mv=(-8,8)` -- **exactly what the trace shows** (`mv=(-8,8)`). The mv-stack/mvstack.rs wiring was also independently re-audited against the oracle's `mvref_common.c`: `add_ref_mv_candidate` (75-135, gm-substitutes) maps correctly to `single_ref_match`/`scan_row_compound` etc.; `process_single_ref_mv_candidate`/`process_compound_ref_mv_candidate` (350-472, must NOT substitute) map correctly to our functions of the same name, which correctly use raw `candidate.mv`/`.mv1` with no gm substitution. This wiring is provably correct against the charter's own named concern.
16+
17+So: entropy in sync, mv computation matches the (now spec-correct) oracle formula exactly, mvstack substitution correctly scoped, motion_mode correctly suppressed (`motion_mode_eligible=0` since `is_global_mv_block && !force_integer_mv`) -- yet the pixel is still off by a small, block-localized, frame-to-frame-growing delta (417 mismatches in frame 1/2, ballooning to ~3900 by frame 23 as the error propagates through the reference chain -- consistent with a systematic per-pixel prediction error, not entropy garbage). Traced this to `reconinter.c`'s `allow_warp` (`~/.cache/aom-oracle/src/av1/common/reconinter.c:33-55`): its `global_warp_allowed` branch is set by the real encoder as `is_global_mv_block(mi, wm->wmtype)` (`reconinter_enc.c:281`) -- the SAME predicate our decoder already computes and correctly uses to suppress `motion_mode`, but which we never feed into the actual per-pixel prediction. `av1_init_warp_params` is called unconditionally for every inter block's predictor build (not gated on `motion_mode`); when `global_warp_allowed` and the global model is valid, it uses the block's FULL affine model (not the block-centre-derived integer mv) to warp-predict every pixel individually. Our decoder's `warp_params: Option<WarpParams>` is populated ONLY when `motion_mode == WARPED_CAUSAL` (local warp) -- every `GLOBALMV`/`GLOBAL_GLOBALMV` block with a non-translation model falls through to plain translational MC using the block-centre mv, which is only a centre-point approximation of the true per-pixel warp and diverges more the further a pixel sits from the block centre -- matching the observed error shape exactly (small at the block's near corner, growing, and compounding across P-frames).
18+
19+## Refusal count (wedge gate, `EC_AV1_REQUIRE_AOMENC=1`)
20+
21+- Before this round (refusal in place): 27 other-capability refusals / 13 matches / wii_hits=6-7 out of 40 (r2 baseline).
22+- With the whole-frame refusal REMOVED (diagnostic only, reverted): 0 gm refusals, real pixel mismatch at seed 43 frame 1 (reproduced this round).
23+- After this round (refusal restored, `warp.rs` fix landed): 27 other-capability refusals / 13 matches / wii_hits=3 out of 40 -- unchanged shape, still `ok` (the global-motion refusal is still one of the 27 named refusals; it is correct to keep it).
24+
25+## What is NOT fixed
26+
27+Implementing the global-warp prediction path itself: this needs `is_global_mv_block`'s already-computed value fed into a new "predict with `global_motion[ref]` as the affine model" branch in the block reconstruction pipeline (reuse `crate::warp::warp_affine`, the same 8x8-tiled warped filter the local `WARPED_CAUSAL` path already has, just keyed off `global_motion[ref]` instead of the locally-estimated `wm_params`), gated exactly on `is_global_mv_block && !global_motion[ref].invalid` (matching `allow_warp`'s `global_warp_allowed` branch, independent of `motion_mode`). That is real, scoped, next-round work -- not guessed at this round per the charter's "do not guess-fix" instruction.
28+
29+## Files touched
30+- `crates/ec-av1/src/warp.rs` -- `gm_get_motion_vector`'s ROTZOOM/AFFINE branch: added the missing `- 1` to both `x`/`y` block-centre offsets (`block_center_x`/`block_center_y`, mv.h:183-191), a genuine spec-conformance fix found via the oracle diff, kept even though it did not resolve seed 43.
31+- `crates/ec-av1/src/stream.rs` -- doc comment on the whole-frame refusal updated with this round's root-cause finding (refusal itself unchanged, still in place). Diagnostic env-var gate and debug `eprintln!` added and reverted before commit (net: comment-only + the one real `warp.rs` fix; no functional change to `stream.rs`'s refusal behaviour).
32+
33+## Gate ladder
34+- `scratch_isolate_pinned_mismatch` (pin, twice): deterministic, byte-identical.
35+- `cargo test -p ec-av1 --release --lib -- --skip a_real_aomenc_stream_with_interintra_wedge`: 227 passed, 0 failed, 17 ignored, 1 filtered.
36+- `EC_AV1_REQUIRE_AOMENC=1 cargo test ... a_real_aomenc_stream_with_interintra_wedge`: `ok`, 27/40 refusals, 13/40 matches, wii_hits=3 (refusal restored, unchanged shape from r2).
37+
38+## Next round
39+Wire `is_global_mv_block && !global_motion[ref].invalid` into the block predictor to select global-affine-warp prediction (reuse `warp::warp_affine` keyed on `global_motion[ref]` instead of the locally-fit `wm_params`), independent of `motion_mode`. Re-run this exact pin (`gm-seed43.obu`, kept in the scratchpad this round -- not committed to the repo, re-capture with the same `EC_AV1_GATE_DUMP` recipe if needed) to confirm frame 1 luma goes to MATCH before attempting to narrow/remove the whole-frame refusal again.