From 02eaf891366a5d37c1e7643cc4b95bb5e6f0ffdb Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Wed, 18 Nov 2026 15:20:12 -0800 Subject: [PATCH] matrix: the report ends with one table of every row over its limit, with its status Two legs of eleven passed and every red was known, so the reds were no longer read. The report (`matrix run` and `matrix show`) now ends with one table: every harness row over its limit on every leg (results.over_rows, the rows harness_budget fails or names as its card's variance), with its kind (GPU time, host time, or count for the instructions gate), its ratio and limit, the frozen arm's verdict (VOID, stands, rebased, no base) and its status. The status comes from scripts/matrix/status.tsv, one typed entry per card and row (a `*` in the row matches any run): an open record with its owner and first round, whose age the table counts in rounds; a known gap with the place it was ruled; or a note alone. A row with neither reads NEW in the first round it is over (not over in its leg's base) and UNOWNED after; a CARD_VARIANCE row reads as its card's known gap. The table changes no verdict: the red rule waits for the planner's ruling. Seeded from the rulings so far: NVIDIA create_64MiB/first_take, a known gap (the 2080 and the 3090); create_64MiB on AMD, a note that it is no known gap and is unjudged until the first interleaved round; the Iris Xe's GPU-time rows, a note of one time-boxed investigation after that round; the Iris row_cells, identity's open record (first over at 795c834ded); the 2080 and Iris frame_5cb, core's open records (from 140714ceae), and both cards' frame and frame_5cb, the planner's state of throughput and latency from idle. Verified: test_results (three new tests: the stored table reads and a malformed entry is refused; every row past its limit is listed with its kind and judged ratio, re-timed and shown rows included; statuses NEW, UNOWNED, open with its age, gap, notes, an extra leg and the card's variance). Against the stored notes of 795c834ded and 140714ceae, over_rows lists exactly the rows the budget named past their limits on every leg (15 and 14 on the Iris Xe). --- docs/VALIDATION.md | 8 +++ scripts/matrix/matrix | 32 ++++++++++ scripts/matrix/results.py | 111 +++++++++++++++++++++++++++++++++ scripts/matrix/status.tsv | 28 +++++++++ scripts/matrix/test_results.py | 86 +++++++++++++++++++++++++ 5 files changed, 265 insertions(+) create mode 100644 scripts/matrix/status.tsv diff --git a/docs/VALIDATION.md b/docs/VALIDATION.md index f5782760f..81b7b5166 100644 --- a/docs/VALIDATION.md +++ b/docs/VALIDATION.md @@ -299,6 +299,14 @@ note under `refs/notes/matrix`: one JSON document per commit, kept in the local never pushed. `scripts/matrix/matrix show SHA` prints a note's verdicts, one line per leg. 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, 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 +status, from `scripts/matrix/status.tsv` by card and row: an open record, with its owner and its +age in rounds; 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 variance (`CARD_VARIANCE`) +reads as its card's known gap. The table changes no verdict. + A leg is one GPU, named by its PCI `vendor:device`, or `lavapipe`, or `lint`. Each GPU runs on one node, and the nodes run at once; a node with several leg GPUs runs their device tests in turn in one job that holds them, then times each GPU in a job of its own. diff --git a/scripts/matrix/matrix b/scripts/matrix/matrix index b61d0c1c4..bb8ab5bb8 100755 --- a/scripts/matrix/matrix +++ b/scripts/matrix/matrix @@ -925,6 +925,7 @@ def run_cmd(sha, only, dry): git("notes", f"--ref={NOTES}", "add", "-f", "-F", str(path), sha) for leg_id in sorted(entries): print_leg(sha, leg_id, doc["legs"][leg_id]) + print_over(sha, doc) failed = sum(1 for e in entries.values() if e["verdict"] != "pass") print(f"matrix {sha[:12]}: {len(entries) - failed} of {len(entries)} legs pass, {wall} min wall; note {NOTES}") return 1 if failed else 0 @@ -949,12 +950,43 @@ def print_leg(sha, leg_id, leg): + "".join(f"; {row} {move:+.1%}" for row, _, _, move in void)) +def rounds_since(sha, since): + """How many rounds ran on SHA's first-parent line from the commit SINCE on, SHA's included: + its noted commits; None where SINCE is not on that line within 500 commits.""" + noted = {line.split()[1] for line in git("notes", f"--ref={NOTES}", "list").splitlines() if line} + since = git("rev-parse", "--verify", "--quiet", f"{since}^{{commit}}", check=False) + count = 0 + for commit in git("rev-list", "--first-parent", "--max-count=500", sha, check=False).splitlines(): + count += commit in noted + if commit == since: + return count + return None + + +def print_over(sha, doc): + """The report's one table: every row over its limit on each leg of SHA's note DOC + (results.over_lines), with the frozen arm's verdict on its base and its status + (results.row_status, status.tsv).""" + lines = [] + for leg_id, leg in sorted(doc["legs"].items()): + if not (leg.get("records") or {}).get("time"): + continue + 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) + lines += results.over_lines(leg_id, leg["records"], base and base["records"], rebased, + lambda since: rounds_since(sha, since)) + print(f"rows over their limits: {len(lines)}") + for line in lines: + print(f" {line}") + + def show_cmd(sha): doc = note(sha) if not doc: sys.exit(f"no matrix note on {sha}") for leg_id in sorted(doc["legs"]): print_leg(sha, leg_id, doc["legs"][leg_id]) + print_over(sha, doc) last = doc["runs"][-1] print(f"matrix {sha[:12]}: last run {last['started']}, {last['minutes']} min wall, jobs {' '.join(last['jobs'])}") diff --git a/scripts/matrix/results.py b/scripts/matrix/results.py index 44dfa55c2..a0aa36fcf 100644 --- a/scripts/matrix/results.py +++ b/scripts/matrix/results.py @@ -871,6 +871,117 @@ def harness_budget(leg_id, leg, base=None, rebased=None): return problems, parked +def over_rows(leg_id, records): + """Every harness row of a leg's RECORDS past its limit on LEG_ID as harness_budget judges it, + each `(row, kind, ratio, limit)`, in row order: kind `GPU time` for a row judged on its GPU + time (gpu_judged), `host time` for one judged on its time, `count` for the instructions gate + (EXACT against the stored count, LENIENT against the old runtime's whole count), the ratio + new over old (the median of the re-timed pairs where the row was re-timed, of the FIRST_RUNS + processes' medians for a creation row's first sample). A row its re-timed pairs bring within + is not over; a shown first sample (SHOWN_FIRST) is never judged, so never over.""" + times, counted = records["time"], records["instructions"] + out = [] + for key in sorted(times): + row = key[len(HARNESS_NEW):] + if not key.startswith(HARNESS_NEW) or not times.get(HARNESS_OLD + row): + continue + new_i, old_i = (counted.get(f"harness-{runtime}/{row}{INSTRUCTIONS_PER_RUN}") for runtime in ("new", "old")) + own = counted.get(f"harness-new/{row}{OWN_PER_RUN}") + if row.startswith(WALL_ROWS) and new_i and old_i and own is not None: + stored = stored_count(leg_id, row) + if stored and own > HARNESS_BUDGET * stored: + out.append((row, "count", own / stored, HARNESS_BUDGET)) + if own > old_i: + out.append((row, "count", own / old_i, 1.0)) + if first_row(row) and any(row.endswith(end) for end in SHOWN_FIRST): + continue + if first_row(row): + samples = first_samples(times, row) + if samples is None: + continue + old, new = (statistics.median(values) for values in samples) + kind, ratio, limit = "host time", new / old, row_limit(leg_id, row) + else: + gpu = gpu_judged(times, row) + prefix = HARNESS_GPU if gpu else "harness-" + new, old = (times[f"{prefix}{runtime}/{row}"] for runtime in ("new", "old")) + kind, ratio, limit = ("GPU time" if gpu else "host time"), new / old, row_limit(leg_id, row, gpu) + ratios = retimed(times, row, gpu) if ratio > limit else None + if ratios is not None: + ratio = statistics.median(ratios) + if ratio > limit: + out.append((row, kind, ratio, limit)) + return out + + +#: The status of each row a report lists over its limit (over_rows), by card and row, read from +#: status.tsv (read_status): `open`, an open record, with its owner and the round it first went +#: over; `gap`, a known gap, with the place it was ruled; `note`, a note alone. A row with no open +#: record or gap reads NEW in the first round it is over (not over in its leg's base) and UNOWNED +#: after; a CARD_VARIANCE row reads as its card's known gap. +STATUSES = ("open", "gap", "note") + + +def read_status(text): + """The status table's TEXT: `#` comments, a header line, then one entry a line, `|` between + its fields: card (`vendor:device`), row (`*` matches any run of characters), status + (STATUSES), who owns it or where it was ruled, since (an open record's first round, a commit; + else `-`) and a note (or `-`). Returns [(card, row, status, who, since, note)]; a malformed + line raises ValueError.""" + entries = [] + lines = [line for line in text.splitlines() if line.strip() and not line.lstrip().startswith("#")] + for line in lines[1:]: + fields = [field.strip() for field in line.split("|")] + if len(fields) != 6: + raise ValueError(f"status.tsv: {len(fields)} fields, not 6: {line}") + card, row, status, who, since, note = fields + if (not re.fullmatch(r"[0-9a-f]{4}:[0-9a-f]{4}", card) or status not in STATUSES or not row + or (status == "open") != bool(re.fullmatch(r"[0-9a-f]{7,40}", since)) + or (status != "note" and who == "-")): + raise ValueError(f"status.tsv: malformed entry: {line}") + entries.append((card, row, status, who, since, note)) + return entries + + +STATUS = read_status((Path(__file__).resolve().parent / "status.tsv").read_text()) + + +def row_status(leg_id, row, over_before, rounds_since): + """ROW's status on LEG_ID for the report's table: `open, 's, rounds` (ROUNDS_SINCE + gives the rounds from a commit on, this one's included, or None), `known gap: `, + `NEW`, or `UNOWNED` where OVER_BEFORE (the row was over in the leg's base), each with the + entries' notes.""" + entries = [entry for entry in STATUS + if entry[0] == card_of(leg_id) and re.fullmatch(re.escape(entry[1]).replace(r"\*", ".*"), row)] + notes = "".join(f"; {note}" for _, _, _, _, _, note in entries if note != "-") + for _, _, status, who, since, _ in entries: + if status == "open": + age = rounds_since(since) + return f"open, {who}'s, {'?' if age is None else age} round{'' if age == 1 else 's'}" + notes + if status == "gap": + return f"known gap: {who}" + notes + if row in CARD_VARIANCE.get(card_of(leg_id), {}): + return "known gap: the card's own variance (CARD_VARIANCE)" + notes + return ("UNOWNED" if over_before else "NEW") + notes + + +def over_lines(leg_id, records, base, rebased, rounds_since): + """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`; `-` + for a count), and its status (row_status).""" + base_times = base and base["time"] + before = {(row, kind) for row, kind, _, _ in over_rows(leg_id, base)} if base else set() + lines = [] + for row, kind, ratio, limit in over_rows(leg_id, records): + move = frozen_move(records["time"], base_times, row) + meter = ("-" if kind == "count" 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) + lines.append(f"{leg_id:<24} {row:<36} {kind:<9} {ratio:6.3f} over {limit:.3f} {meter:<7} {status}") + return lines + + def harness_rows(records, base=None, rebased=None): """Every harness row timed on either runtime in a leg's RECORDS, one line each: its time, its GPU time (HARNESS_GPU) and, where recorded, its instructions per run (with its own threads' diff --git a/scripts/matrix/status.tsv b/scripts/matrix/status.tsv new file mode 100644 index 000000000..daf4b9480 --- /dev/null +++ b/scripts/matrix/status.tsv @@ -0,0 +1,28 @@ +# The status of each harness row the matrix's report lists over its limit (results.over_rows), +# by card and row, read by results.read_status: one entry a line, `|` between its fields. +# card a GPU leg's card, vendor:device; its extra legs (vendor:device@node) take its entries +# row a harness row; `*` matches any run of characters +# status open: an open record, its owner in `who`, the round it first went over in `since` +# gap: a known gap, the place it was ruled in `who` +# note: a note alone; the row reads NEW or UNOWNED as a row with no entry does +# note shown beside the status, or `-` +# A row with no open record or gap reads NEW in the first round it is over and UNOWNED after. +# An open record leaves when its row is within its limit again; a gap carries its row's ceiling. +card | row | status | who | since | note +10de:1e87 | create_64MiB/first_take | gap | the planner's ruling of 2026-11-18 | - | - +10de:2204 | create_64MiB/first_take | gap | the planner's ruling of 2026-11-18 | - | - +1002:15bf | create_64MiB* | note | - | - | not a known gap: unjudged until the first interleaved round +1002:1900 | create_64MiB* | note | - | - | not a known gap: unjudged until the first interleaved round +1002:699f | create_64MiB* | note | - | - | not a known gap: unjudged until the first interleaved round +1002:744c | create_64MiB* | note | - | - | not a known gap: unjudged until the first interleaved round +8086:a7a0 | row_cells | open | identity | 795c834ded | - +10de:1e87 | frame_5cb | open | core | 140714ceae | latency from idle equal; throughput 8-14% behind +10de:1e87 | frame | note | - | - | new ahead in throughput and in latency from idle +8086:a7a0 | frame_5cb | open | core | 140714ceae | latency from idle ahead; throughput about 8% behind, the ranges overlapping +8086:a7a0 | frame | note | - | - | new ahead in throughput and in latency from idle +8086:a7a0 | constant_* | note | - | - | one time-boxed investigation after the first interleaved round +8086:a7a0 | constexpr_sampling | note | - | - | one time-boxed investigation after the first interleaved round +8086:a7a0 | sampling_deep* | note | - | - | one time-boxed investigation after the first interleaved round +8086:a7a0 | sampling_distinct* | note | - | - | one time-boxed investigation after the first interleaved round +8086:a7a0 | threadgroup_scan | note | - | - | one time-boxed investigation after the first interleaved round +8086:a7a0 | waves | note | - | - | one time-boxed investigation after the first interleaved round diff --git a/scripts/matrix/test_results.py b/scripts/matrix/test_results.py index 9a9ec69db..8231a4e0d 100644 --- a/scripts/matrix/test_results.py +++ b/scripts/matrix/test_results.py @@ -784,5 +784,91 @@ class HarnessBudgetTests(unittest.TestCase): self.assertGreater(ceiling, results.HARNESS_BUDGET, f"{leg} {row}") +class OverTableTests(unittest.TestCase): + def setUp(self): + for name, value in (("HARNESS_FLOORS", {}), ("HARNESS_GPU_FLOORS", {}), ("CARD_VARIANCE", {}), + ("HARNESS_CEILINGS", {"a:0001": {"listed": 2.0}}), ("STORED_INSTRUCTIONS", {})): + patch = mock.patch.object(results, name, value) + patch.start() + self.addCleanup(patch.stop) + + def test_the_stored_status_table_reads_and_a_malformed_entry_is_refused(self): + stored = results.read_status((Path(results.__file__).parent / "status.tsv").read_text()) + self.assertTrue(stored) + self.assertTrue(all(status in results.STATUSES for _, _, status, _, _, _ in stored)) + head = "card | row | status | who | since | note\n" + self.assertEqual(results.read_status(head + "10de:1e87 | frame | open | core | 140714ceae | -\n"), + [("10de:1e87", "frame", "open", "core", "140714ceae", "-")]) + for bad in ("10de:1e87 | frame | open | core | - | -", # an open record without its first round + "10de:1e87 | frame | gap | - | - | -", # a gap without its place + "10de:1e87 | frame | closed | core | - | -", # no such status + "nvidia | frame | gap | here | - | -", # not a card + "10de:1e87 | frame | gap | here | -"): # a field short + with self.assertRaises(ValueError, msg=bad): + results.read_status(head + bad + "\n") + + def test_every_row_past_its_limit_is_listed_with_its_kind_and_the_ratio_it_is_judged_by(self): + row = "create_state/first" + times = {"harness-old/alu": 100.0, "harness-new/alu": 110.0, + "harness-old/frame": 100.0, "harness-new/frame": 102.0, + "harness-old/listed": 100.0, "harness-new/listed": 150.0, + "harness-old/sampling": 30.0, "harness-new/sampling": 30.0, + "harness-gpu-old/sampling": 20.0, "harness-gpu-new/sampling": 30.0, + "harness-old/bandwidth": 100.0, "harness-new/bandwidth": 120.0, + f"harness-old/{row}": 1000.0, f"harness-new/{row}": 3000.0, + "harness-old/create_state/first_call": 1000.0, "harness-new/create_state/first_call": 9000.0} + for n in range(2, results.FIRST_RUNS + 1): + for runtime, value in (("old", 1000.0), ("new", 1200.0)): + times[f"{results.HARNESS_FIRST}{row}/{n}/{runtime}"] = value + times[f"{results.HARNESS_FIRST}create_state/first_call/{n}/{runtime}"] = 9 * value + # bandwidth's re-timed pairs bring it within; alu's keep it past, judged by their median. + for pair, (old, new) in enumerate(((100.0, 101.0), (100.0, 102.0)), 1): + times[f"{results.HARNESS_RETIME}bandwidth/{pair}/old"] = old + times[f"{results.HARNESS_RETIME}bandwidth/{pair}/new"] = new + times[f"{results.HARNESS_RETIME}alu/{pair}/old"] = old + times[f"{results.HARNESS_RETIME}alu/{pair}/new"] = new + 7.0 + counted = {"harness-new/frame/per_run": 3000, "harness-old/frame/per_run": 2000, + "harness-new/frame/own_per_run": 2500} + with mock.patch.object(results, "stored_count", lambda leg_id, r: 2000 if r == "frame" else None): + over = results.over_rows("a:0001", recs(time=times, instructions=counted)) + # frame's time is within; its own count is past both of the instructions gate's limits. + # listed is within its ceiling; the creation call alone is shown, never judged. + self.assertEqual([(r, kind, round(ratio, 3), round(limit, 3)) for r, kind, ratio, limit in over], [ + ("alu", "host time", 1.085, 1.03), (row, "host time", 1.2, 1.03), + ("frame", "count", 1.25, 1.03), ("frame", "count", 1.25, 1.0), + ("sampling", "GPU time", 1.5, 1.03)]) + + def test_a_listed_row_reads_its_status_and_an_unlisted_one_new_then_unowned(self): + entries = [("a:0001", "frame", "open", "core", "abc1234", "-"), + ("a:0001", "sampling_*", "gap", "a ruling", "-", "its ceiling holds"), + ("a:0001", "alu", "note", "-", "-", "looked at once")] + times = {"harness-old/frame": 100.0, "harness-new/frame": 150.0, + "harness-old/sampling_deep": 100.0, "harness-new/sampling_deep": 150.0, + "harness-old/alu": 100.0, "harness-new/alu": 150.0, + "harness-old/waves": 100.0, "harness-new/waves": 150.0} + base = recs(time=dict(times, **{"harness-new/waves": 100.0, "harness-old/frame": 80.0})) + rounds = {"abc1234": 3} + with mock.patch.object(results, "STATUS", entries): + lines = results.over_lines("a:0001@node", recs(time=times), base, None, rounds.get) + self.assertEqual([line.split(None, 1)[1] for line in lines], [ + "alu host time 1.500 over 1.030 stands UNOWNED; looked at once", + "frame host time 1.500 over 1.030 VOID open, core's, 3 rounds", + "sampling_deep host time 1.500 over 1.030 stands known gap: a ruling; " + "its ceiling holds", + "waves host time 1.500 over 1.030 stands NEW"]) + self.assertTrue(lines[0].startswith("a:0001@node ")) + # Without a base, every unlisted row is new and the arm has nothing to say; on another + # harness, only the creation rows are compared. + lines = results.over_lines("a:0001", recs(time=times), None, None, rounds.get) + self.assertEqual([line.split()[-1] for line in lines], ["once", "rounds", "holds", "NEW"]) + self.assertEqual({line.split(" ")[-2].strip() for line in + results.over_lines("a:0001", recs(time=times), base, results.REBASED_TREES, + rounds.get)}, {"rebased"}) + with mock.patch.object(results, "STATUS", []), \ + mock.patch.object(results, "CARD_VARIANCE", {"a:0001": {"waves": "it varies"}}): + self.assertEqual(results.row_status("a:0001", "waves", True, rounds.get), + "known gap: the card's own variance (CARD_VARIANCE)") + + if __name__ == "__main__": unittest.main()