forge
Explore
Log in

Don't you dare go Hollow

cmpff: prune infeasible subtrees in the assignment search (three cells went from >30 min to byte-exact in a second), count pairs at C speed, and pin PROBE to a provenance-verified build

Browse files at this commit

f91abd5137a1542db3bbcafdd034d145bb65474eAhmet Kaan GümüşParent: 05c4451
The 43-decode/40-display cells (AD_inter_nogm, AB_inter_warp_odd, AA_inter_compound) never finished in 300 s with
15 minutes of user CPU. The assignment DFS had no feasibility check, so an instance whose candidate lists cannot
cover the display side explored the whole tree before returning empty; with 'remaining decode frames must cover the
remaining display partners' plus a node cap that reports instead of hanging, all three measure BYTE-EXACT in 1.4 s
total. Pair counts for 8-bit planes now come from a big-int XOR counted with bytes.count (verified equal to the
per-sample loop on a synthetic case, and a stored cell's JSON is byte-identical after the change). PROBE is pinned to
a probe built in a fresh worktree whose filename carries its tree hash and whose embedded strings show no other
worktree -- the previous path had been silently built from a lane worktree at least once.
scripts/cmp422-ffmpeg.pymodified+82 -11
@@ -77,16 +77,32 @@ def split(raw, sizes, fsz, cell):
77 return [raw[i * fsz:(i + 1) * fsz] for i in range(len(raw) // fsz)]77 return [raw[i * fsz:(i + 1) * fsz] for i in range(len(raw) // fsz)]
78 78
79 79
80-def _matchings(cands, disp_n, cap=64):80+def _matchings(cands, disp_n, cap=64, node_cap=4_000_000):
81 """Every way to assign each decode frame either a distinct display partner81 """Every way to assign each decode frame either a distinct display partner
82 or the hidden role, covering the display side exactly. Enumerated, not82 or the hidden role, covering the display side exactly. Enumerated, not
83 guessed: a duplicated picture can make the assignment genuinely ambiguous,83 guessed: a duplicated picture can make the assignment genuinely ambiguous,
84- and the caller then has to show the ambiguity does not change the answer."""84+ and the caller then has to show the ambiguity does not change the answer.
85+
86+ Two bounds, both learned the hard way: without the feasibility prune, an
87+ instance whose candidate lists cannot cover the display side explores the
88+ whole 2**frames tree before returning empty (that is what made three
89+ 43-frame cells burn a 300 s cap with 15 minutes of user CPU and never
90+ finish), and without a node cap a pathological instance would hang the
91+ comparator instead of reporting."""
85 sols = []92 sols = []
93+ nodes = 0
86 94
87 def dfs(i, used, acc, hid):95 def dfs(i, used, acc, hid):
96+ nonlocal nodes
97+ nodes += 1
98+ if nodes > node_cap:
99+ raise SystemExit(f"the decode->display assignment search exceeded {node_cap} nodes "
100+ f"at frame {i} of {len(cands)} ({disp_n} display frames) -- this "
101+ f"instance is not enumerable; report it rather than hang")
88 if len(sols) >= cap:102 if len(sols) >= cap:
89 return103 return
104+ if disp_n - len(used) > len(cands) - i:
105+ return # not enough decode frames left to cover the display side
90 if i == len(cands):106 if i == len(cands):
91 if len(used) == disp_n:107 if len(used) == disp_n:
92 sols.append((dict(acc), list(hid)))108 sols.append((dict(acc), list(hid)))
@@ -181,15 +197,70 @@ def compare(cell, ours_prefix, disp, w, h, ss_x, ss_y, depth, want_hidden=None):
181 per_dec.append(fcount)197 per_dec.append(fcount)
182 return tot, per_disp, per_dec, first, bb_all198 return tot, per_disp, per_dec, first, bb_all
183 199
184- measured = [measure(m, h) for m, h in sols]200+ def xor_plane_counts(a, b):
185- totals = {tuple(t[0]) for t in measured}201+ """Per-plane differing-SAMPLE counts at 8-bit, at C speed: XOR the two
186- if len(totals) > 1:202+ planes as big ints, then count non-zero bytes per plane. Equivalent to
187- raise SystemExit(f"{cell}: the decode->display assignment is AMBIGUOUS "203+ the per-sample loop above, and the only reason a 43-frame cell with 64
188- f"({len(sols)} solutions) and they DISAGREE on the counts "204+ candidate assignments used to cost half an hour."""
189- f"{sorted(totals)} -- pick the identity source explicitly, "205+ z = int.from_bytes(a, "big") ^ int.from_bytes(b, "big")
190- f"this instrument will not choose for you")206+ zb = z.to_bytes(len(a), "big")
191- tot, per_disp, per_dec, first, bbox = measured[0]207+ out, off = [], 0
192- mapping, hidden = sols[0]208+ for sz in sizes:
209+ seg = zb[off:off + sz]
210+ off += sz
211+ out.append(len(seg) - seg.count(0))
212+ return out
213+
214+ if bps == 1:
215+ pair_cache = {}
216+
217+ def pair_total(oi, di):
218+ v = pair_cache.get((oi, di))
219+ if v is None:
220+ v = xor_plane_counts(ours[oi], disp[di])
221+ pair_cache[(oi, di)] = v
222+ return v
223+
224+ sol_totals = []
225+ for m, _h in sols:
226+ t = [0, 0, 0]
227+ for oi, di in m.items():
228+ p = pair_total(oi, di)
229+ t[0] += p[0]
230+ t[1] += p[1]
231+ t[2] += p[2]
232+ sol_totals.append(tuple(t))
233+ if len(set(sol_totals)) > 1:
234+ raise SystemExit(f"{cell}: the decode->display assignment is AMBIGUOUS "
235+ f"({len(sols)} solutions) and they DISAGREE on the counts "
236+ f"{sorted(set(sol_totals))} -- pick the identity source explicitly, "
237+ f"this instrument will not choose for you")
238+ tot = list(sol_totals[0])
239+ mapping, hidden = sols[0]
240+ if tot == [0, 0, 0]:
241+ per_disp = [[0, 0, 0] for _ in disp]
242+ per_dec = [None if oi in hidden else [0, 0, 0] for oi in range(len(ours))]
243+ first, bbox = None, [[None, None, None, None] for _ in range(3)]
244+ else:
245+ tot, per_disp, per_dec, first, bbox = measure(mapping, hidden)
246+ else:
247+ # 16-bit planes: the sample loop below is the only path today.
248+ if all(all(ours[oi] == disp[di] for oi, di in m.items()) for m, h in sols):
249+ hidden0 = sols[0][1]
250+ measured = [([0, 0, 0], [[0, 0, 0] for _ in disp],
251+ [None if oi in hidden0 else [0, 0, 0] for oi in range(len(ours))],
252+ None, [[None, None, None, None] for _ in range(3)])]
253+ measured *= len(sols)
254+ else:
255+ measured = [measure(m, h) for m, h in sols]
256+ totals = {tuple(t[0]) for t in measured}
257+ if len(totals) > 1:
258+ raise SystemExit(f"{cell}: the decode->display assignment is AMBIGUOUS "
259+ f"({len(sols)} solutions) and they DISAGREE on the counts "
260+ f"{sorted(totals)} -- pick the identity source explicitly, "
261+ f"this instrument will not choose for you")
262+ tot, per_disp, per_dec, first, bbox = measured[0]
263+ mapping, hidden = sols[0]
193 if want_hidden is not None and len(hidden) != want_hidden:264 if want_hidden is not None and len(hidden) != want_hidden:
194 raise SystemExit(f"{cell}: {len(hidden)} hidden decode frame(s) {hidden}, "265 raise SystemExit(f"{cell}: {len(hidden)} hidden decode frame(s) {hidden}, "
195 f"expected {want_hidden} -- the frame-count claim changed")266 f"expected {want_hidden} -- the frame-count claim changed")
scripts/run422-ffmpeg.pymodified+1 -1
@@ -9,7 +9,7 @@ import sys
9 sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))9 sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
10 import cmpff # noqa: E40210 import cmpff # noqa: E402
11 11
12-PROBE = "/home/user/.cache/tgt/av1422seed/debug/examples/decode_probe"12+PROBE = "/home/user/.cache/probes/decode_probe-main-8d6998d7"
13 WORK = "/home/user/.cache/seed422"13 WORK = "/home/user/.cache/seed422"
14 14
15 15