diff --git a/docs/VALIDATION.md b/docs/VALIDATION.md index 82df605ca..1cadf439a 100644 --- a/docs/VALIDATION.md +++ b/docs/VALIDATION.md @@ -302,7 +302,7 @@ CONTRIBUTING.md says how to run it. Both end with one table: every harness row over its limit on every leg (the harness budget below), with its kind (GPU time, host time, own part for a creation row judged on the new runtime's own part, or count for the instructions gate), its ratio and -limit, the frozen arm's verdict on it (`VOID`, `stands`, `rebased` or `no base`), and its +limit, the frozen arm's verdict on it (`VOID` by either rule below, `stands`, `rebased` or `no base`), and its status, from `scripts/matrix/status.tsv` by card and row: an open record, with its owner, its age in rounds and the ratio it was owned at; a known gap, with the place it was ruled; or, for a row with neither, `NEW` in the first round it is over and `UNOWNED` after. A row of a card's own @@ -411,7 +411,11 @@ median of five rounds) is compared with the same time in the leg's base, the pre and a row whose old time moved more than 10% either way is VOID for the round on that GPU: it is named on the leg's line and judged on nothing, and its comparison comes only from a re-time in one process with both runtimes interleaved. The report shows that move on every row the base has -(`FROZEN_DRIFT` in `scripts/matrix/results.py`). It measures noise only between rounds of one +(`FROZEN_DRIFT` in `scripts/matrix/results.py`). A second rule voids a row judged by its host time +and not re-timed in pairs whose excess over its limit (its ratio over the limit, less 1) is +smaller than its own old time's move in the round, since the old runtime's drift alone could +carry it there (`excess_void`). The leg's lines name the rows each rule voided. Neither rule makes +a row red: a row past its limit is red only after its paired re-time agrees. It measures noise only between rounds of one harness, one old runtime and one timing shape: where the trees of `crates/metal2vulkan-harness` or `crates/metal2vulkan-runtime` differ between the two commits, every row but the creation rows reads `rebased` and voids nothing, and where the base was timed in another shape (the note's diff --git a/scripts/matrix/matrix b/scripts/matrix/matrix index be84074c3..105f5302e 100755 --- a/scripts/matrix/matrix +++ b/scripts/matrix/matrix @@ -1053,8 +1053,8 @@ def run_cmd(sha, only, dry): def print_leg(sha, leg_id, leg): """SHA's leg's verdict line, then each of its harness rows' times and GPU times, with the - frozen arm's move on its base (results.frozen_move, frozen_rebase), and the rows the frozen arm - voids.""" + frozen arm's move on its base (results.frozen_move, frozen_rebase), and the rows each of the + frozen arm's two rules voids (results.frozen_void, results.excess_voids).""" print(results.verdict_line(leg_id, leg)) base = leg.get("base") and (note(leg["base"]) or {}).get("legs", {}).get(leg_id) rebased = base and frozen_rebase(sha, leg.get("shape"), leg["base"], base) @@ -1068,6 +1068,9 @@ def print_leg(sha, leg_id, leg): print(f" frozen arm against {leg['base'][:10]}{f', {rebased}' if rebased else ''}: {compared} " f"compared, {len(void)} VOID, old moved past {results.FROZEN_DRIFT:.0%}" + "".join(f"; {row} {move:+.1%}" for row, _, _, move in void)) + excess = results.excess_voids(leg_id, leg["records"], base, rebased, leg.get("cpu")) + print(f" frozen arm, past its limit by less than old's own move: {len(excess)} VOID" + + "".join(f"; {row} {ratio:.3f} over {limit:.3f}, old {move:+.1%}" for row, ratio, limit, move in excess)) def rounds_since(sha, since): diff --git a/scripts/matrix/results.py b/scripts/matrix/results.py index 31a639904..791511279 100644 --- a/scripts/matrix/results.py +++ b/scripts/matrix/results.py @@ -914,6 +914,36 @@ def frozen_void(times, base, rebased=None): return [(row, *move) for row, move in moves if move and abs(move[2]) > FROZEN_DRIFT] +#: The frozen arm's second rule, beside FROZEN_DRIFT: a row judged by its host time (not by its GPU +#: time, and not by re-timed pairs, which judge themselves) that is past its limit by less than its +#: own old time moved from the base in the round is VOID for the round too, as the old runtime's +#: own drift could carry it there. Its excess is the ratio over the limit less one, the move the +#: size of frozen_move's. Neither rule makes a row red; a row past its limit is red only after its +#: paired re-time agrees. +def excess_void(move, ratio, limit): + """Whether a host-time row judged at RATIO past its LIMIT is VOID by its own frozen arm's MOVE + (frozen_move, or None): its excess over the limit smaller than the move's size.""" + return move is not None and ratio > limit and ratio / limit - 1 < abs(move[2]) + + +def excess_voids(leg_id, records, base, rebased=None, cpu=None): + """The rows of a leg's RECORDS on LEG_ID past their limits by host time (over_rows) that the + second rule voids (excess_void) against BASE, the base leg's times, and the first (FROZEN_DRIFT) + does not: each `(row, ratio, limit, move)`, in row order; none where REBASED leaves the row + uncompared (frozen_rebased) or its re-timed pairs judged it. CPU: the CPU model of the leg's + node.""" + out = [] + for row, kind, ratio, limit in over_rows(leg_id, records, cpu): + if kind == "GPU time" or kind == "count" or frozen_rebased(row, rebased): + continue + if retimed(records["time"], row) is not None: + continue + move = frozen_move(records["time"], base, row) + if move and abs(move[2]) <= FROZEN_DRIFT and excess_void(move, ratio, limit): + out.append((row, ratio, limit, move[2])) + return out + + def harness_budget(leg_id, leg, base=None, rebased=None, cpu=None): """The harness budget on LEG, the parsed leg LEG_ID: each row timed on both runtimes (`harness-new/` and `harness-old/`) against its limit, row_limit: HARNESS_BUDGET times @@ -1002,6 +1032,16 @@ def harness_budget(leg_id, leg, base=None, rebased=None, cpu=None): f"{move[0]:.1f} us to {move[1]:.1f} us, so the round judges nothing from it: " "re-time it in one process, both runtimes interleaved") continue + + def within_drift(line, ratio): + """Whether ROW past its limit at RATIO is VOID by the second rule (excess_void), + naming it after LINE when it is.""" + if not excess_void(move, ratio, limit): + return False + parked.append(f"{line}: VOID: past its limit {limit:.3f} by {ratio / limit - 1:.1%}, less than " + f"old's own move of {move[2]:+.1%} from the base's, so the round judges nothing " + "from it: re-time it in one process, both runtimes interleaved") + return True if first_row(row): samples = first_samples(times, row) if samples is None: @@ -1024,12 +1064,15 @@ def harness_budget(leg_id, leg, base=None, rebased=None, cpu=None): f"part {own:.1f} us over old's whole {old:.1f} us is {own / old:.3f}; the " f"driver's part {driver:.1f} us, new {new:.1f} us whole is {new / old:.3f}: {gap}") if own / old > limit: - past_its_limit(row, f"{line}, {past_limit(leg_id, row)}: a regression of its own", own / old) + if not within_drift(line, own / old): + past_its_limit(row, f"{line}, {past_limit(leg_id, row)}: a regression of its own", + own / old) else: parked.append(line) continue if new / old > limit: - past_its_limit(row, f"{line}, {past_limit(leg_id, row)}", new / old) + if not within_drift(line, new / old): + past_its_limit(row, f"{line}, {past_limit(leg_id, row)}", new / old) elif listed_row(row) in ceilings: parked.append(f"{line}, its ceiling {ceilings[listed_row(row)]}") continue @@ -1056,6 +1099,8 @@ def harness_budget(leg_id, leg, base=None, rebased=None, cpu=None): if judged <= limit: parked.append(f"{past}, within: judged by the median") continue + elif not gpu and within_drift(line, ratio): + continue if variance: parked.append(f"{past}: the card's own variance, not judged ({variance})") else: @@ -1249,16 +1294,18 @@ def owned_verdict(leg_id, row, ratio): def over_lines(leg_id, records, base, rebased, rounds_since, cpu=None): """The report's table on LEG_ID: one line per row over its limit in the leg's RECORDS (over_rows): its kind, its ratio and limit, the frozen arm's verdict against BASE, the base - leg's records (`VOID`, `stands`, `rebased` where REBASED leaves it uncompared, `no base`; `-` + leg's records (`VOID` by either of its rules, FROZEN_DRIFT and excess_voids, `stands`, + `rebased` where REBASED leaves it uncompared, `no base`; `-` for a count; `VOID` on every time where the old runtime's own spread voids the leg, base_spread), and its status (row_status). CPU: the CPU model of the leg's node.""" base_times = base and base["time"] before = {(row, kind) for row, kind, _, _ in over_rows(leg_id, base, cpu)} if base else set() void = base_spread_void(records["time"], cpu) lines = [] + excess = {row for row, *_ in excess_voids(leg_id, records, base_times, rebased, cpu)} if base else set() for row, kind, ratio, limit in over_rows(leg_id, records, cpu): move = frozen_move(records["time"], base_times, row) - meter = ("-" if kind == "count" else "VOID" if void else "no base" if move is None + meter = ("-" if kind == "count" else "VOID" if void or row in excess else "no base" if move is None else "rebased" if frozen_rebased(row, rebased) else "VOID" if abs(move[2]) > FROZEN_DRIFT else "stands") status = row_status(leg_id, row, (row, kind) in before, rounds_since, None if kind == "count" else ratio) lines.append(f"{leg_id:<24} {row:<36} {kind:<9} {ratio:6.3f} over {limit:.3f} {meter:<7} {status}") diff --git a/scripts/matrix/test_results.py b/scripts/matrix/test_results.py index 4d39e04a7..2be6c8851 100644 --- a/scripts/matrix/test_results.py +++ b/scripts/matrix/test_results.py @@ -859,6 +859,49 @@ class HarnessBudgetTests(unittest.TestCase): "1.500, old +25.0% on the base VOID", "1.000, old -20.0% on the base VOID"]) self.assertEqual(results.harness_rows(recs(time=times)), [line.split(", old ")[0] for line in lines]) + def test_a_host_time_row_past_its_limit_by_less_than_old_s_own_move_is_void(self): + first = "create_state/first" + times = {"harness-old/alu": 100.0, "harness-new/alu": 106.0, + "harness-old/frame": 100.0, "harness-new/frame": 112.0, + "harness-old/loop": 100.0, "harness-new/loop": 106.0, + "harness-old/sampling": 30.0, "harness-new/sampling": 30.0, + "harness-gpu-old/sampling": 20.0, "harness-gpu-new/sampling": 21.0, + f"harness-old/{first}": 1000.0, f"harness-new/{first}": 1040.0} + for n in range(2, results.FIRST_RUNS + 1): + times[f"{results.HARNESS_FIRST}{first}/{n}/old"] = 1000.0 + times[f"{results.HARNESS_FIRST}{first}/{n}/new"] = 1040.0 + for pair in range(1, results.RETIME_PAIRS + 1): + times[f"{results.HARNESS_RETIME}loop/{pair}/old"] = 100.0 + times[f"{results.HARNESS_RETIME}loop/{pair}/new"] = 106.0 + # Old moved +5.3% on alu, frame and loop, +2.6% on sampling's GPU time and -4.8% on the + # first's median: each under FROZEN_DRIFT, so the first rule voids none. + base = dict(times, **{"harness-old/alu": 95.0, "harness-old/frame": 95.0, "harness-old/loop": 95.0, + "harness-gpu-old/sampling": 19.5, f"harness-old/{first}": 1050.0}) + for n in range(2, results.FIRST_RUNS + 1): + base[f"{results.HARNESS_FIRST}{first}/{n}/old"] = 1050.0 + void = "so the round judges nothing from it: re-time it in one process, both runtimes interleaved" + with mock.patch.object(results, "HARNESS_CEILINGS", {}), mock.patch.object(results, "OWN_PART_GATES", {}): + problems, parked = results.harness_budget("a", leg_of(recs(time=times)), base) + # alu, 2.9% past its limit, and the first, 1.0% past, are within old's own move; + # frame, 8.7% past, is not; loop is judged by its re-timed pairs and sampling by its + # GPU time, which the second rule never voids. + self.assertEqual([line.split(":")[0] for line in problems], + ["harness budget frame", "harness budget loop", "harness budget sampling"]) + self.assertEqual(parked, [ + f"harness budget {first}: median of {results.FIRST_RUNS} processes, new 1040.0 us over old " + f"1000.0 us is 1.040: VOID: past its limit 1.030 by 1.0%, less than old's own move of -4.8% " + f"from the base's, {void}", + "harness budget alu: new 106.0 us over old 100.0 us is 1.060: VOID: past its limit 1.030 by " + f"2.9%, less than old's own move of +5.3% from the base's, {void}"]) + self.assertEqual([(row, round(ratio, 3), round(move, 3)) for row, ratio, _, move in + results.excess_voids("a", recs(time=times), base)], + [(first, 1.04, -0.048), ("alu", 1.06, 0.053)]) + # A base that moved past FROZEN_DRIFT leaves the row to the first rule alone. + far = dict(base, **{"harness-old/alu": 80.0}) + self.assertEqual([row for row, *_ in results.excess_voids("a", recs(time=times), far)], [first]) + # No base voids nothing. + self.assertEqual(len(self.budget("a", times)[0]), 5) + def test_a_re_timed_run_keeps_the_row_s_time_and_gpu_time(self): output = ["M2V-MATRIX time harness-new/sampling 36.000", "M2V-MATRIX time harness-gpu-new/sampling 17.600", "M2V-MATRIX time harness-new/alu 10.000", "a table row"]