From 23a9257cc8d3dced3bb543b60a03df51f025942c Mon Sep 17 00:00:00 2001 From: bong-water-water-bong Date: Sun, 15 Nov 2026 04:46:47 -0400 Subject: [PATCH] hw-gate: a placement node the engine calls BY DESIGN is not a misplacement (engine#2450) `placement` is the only red row in the hw-gate, on every model, at main: placement qwen3-0.6b FAIL 2 of 989 nodes off HRX (GET_ROWS x 2), 2 graph splits placement zaya1-8b FAIL 2 of 6570 nodes off HRX (GET_ROWS x 2), 2 graph splits placement qwen3.8-27b FAIL 2 of 3897 nodes off HRX (GET_ROWS x 2), 2 graph splits The engine has since learned to say WHICH off-HRX nodes are intended: `host-weight-placement.cpp` classifies a node as by-design when its source is a weight in the loader's file mapping (the CPU legitimately owns it) or when it is an unaligned matmul with no HRX dense schedule (#991), and `GGML_HRX_STRICT=1` aborts only on the UNEXPLAINED one. But `ggml-hrx.cpp` computes `off_by_design` and never prints it -- the placement line still carries only the op counts -- so this row cannot see the distinction and fails on a placement the code documents as correct. The two GET_ROWS are the token-embedding lookups over the mapped weight, i.e. exactly the by-design case. The gate half, done now and backwards compatible: * the placement line's two new fields are OPTIONAL in the regex, so the row keeps working against a binary that does not print them yet (present -> decide on `unexplained`, absent -> the old rule); * when they are present, the row fails only when `unexplained > 0`, and says "N off-HRX node(s) BY DESIGN and none unexplained" when they are not; * a log holding both shapes (an older line and a newer one from one run) falls back to the raw count per graph rather than comparing None with int -- my own new arms found that crash, twice. Arms in tests/hw_gate_test.py, both directions: by design only (2 off, 2 by design, 0 unexplained) -> rc 0, says "BY DESIGN and none unexplained" one unexplained (2 off, 1 by design, 1 unexplained) -> rc 1, says "1 unexplained" worst graph / strict abort / no report / clean -> unchanged Mutations, each caught: decide on the raw off count again -> "FAIL placement by design only: rc 1, want 0" fail on by-design too (new parse, old rule) -> "FAIL placement by design only: rc 1, want 0" (this one) `hw_gate_test: PASS`, copyright rc 0, lane_syntax balanced. Still needed on the fork side (one line, not this repo): print `off_by_design` and the unexplained count in the `level >= 1` placement line, e.g. `..., 2 off HRX (GET_ROWS x 2), 2 by design, 0 unexplained, 2 graph splits`. Until it does, this row keeps the old behaviour and #2450 stays red -- by design, so a regression in the engine cannot hide behind a gate that stopped failing. --- tests/hw_gate_test.py | 10 +++++++++- tools/hw_gate_manifest.py | 36 +++++++++++++++++++++++++++++------- 2 files changed, 38 insertions(+), 8 deletions(-) diff --git a/tests/hw_gate_test.py b/tests/hw_gate_test.py index 173deef37..4609ad87b 100644 --- a/tests/hw_gate_test.py +++ b/tests/hw_gate_test.py @@ -166,10 +166,18 @@ def main(): off = "placement_observer: placement: 354 nodes, 20 off HRX (MUL_MAT x 20), 5 graph splits\n" abort = ('ggml-hrx.cpp:444: placement_observer: GGML_HRX_STRICT=1: "attn_out-0" is MUL_MAT f32 ' 'ne=[1024,7,1,1] and is not placed on HRX; 1 of 512 nodes off HRX (MUL_MAT x 1), 3 splits\n') + # engine#2450: the engine classifies an off-HRX node as by-design (mapped weight, unaligned matmul) or + # unexplained, and only the second is a misplacement -- measured on main at 989/3897/6570 nodes, always + # the same two token-embedding GET_ROWS. The row must stop calling a documented default a failure, and + # must keep calling a real misplacement one; both directions are pinned below. + byd = "placement_observer: placement: 989 nodes, 2 off HRX (GET_ROWS x 2), 2 by design, 0 unexplained, 2 graph splits\n" + unex = "placement_observer: placement: 989 nodes, 2 off HRX (GET_ROWS x 2), 1 by design, 1 unexplained, 2 graph splits\n" for name, text, want, says in (("clean", clean * 3, 0, "all on HRX in 3 graphs"), ("worst graph", clean + off + clean, 1, "20 of 354 nodes off HRX"), ("no report", "srv load_model: loaded\n", 1, "no placement report"), - ("strict abort", clean + abort, 1, "attn_out-0")): + ("strict abort", clean + abort, 1, "attn_out-0"), + ("by design only", clean + byd, 0, "BY DESIGN and none unexplained"), + ("one unexplained", clean + unex, 1, "1 unexplained")): log = os.path.join(d, "server.log") with open(log, "w") as f: f.write(text) diff --git a/tools/hw_gate_manifest.py b/tools/hw_gate_manifest.py index b3372c9b9..158f11f8b 100644 --- a/tools/hw_gate_manifest.py +++ b/tools/hw_gate_manifest.py @@ -155,7 +155,13 @@ def cmd_judge(manifest, name, logpath): # ggml-hrx's placement observer (GGML_HRX_REPORT=2, engine #390), one line per graph: # "placement_observer: placement: 512 nodes, 34 off HRX (MUL_MAT x 30, GET_ROWS x 4), 7 graph splits" -PLACEMENT = re.compile(r"placement: (\d+) nodes, (\d+) off HRX \(([^)]*)\), (\d+) graph splits") +# engine#2450: the engine now CLASSIFIES an off-HRX node as by-design (a weight in the loader's file mapping, or an +# unaligned-matmul input with no HRX dense schedule) or unexplained, and only the second is a misplacement -- but the +# placement line printed neither count, so this row failed on nodes the engine itself documents as intended. The two +# fields are OPTIONAL here so the row keeps working against a binary that does not print them yet: present -> decide on +# `unexplained`, absent -> the old rule (any node off HRX fails). That keeps this change mergeable before the fork's. +PLACEMENT = re.compile(r"placement: (\d+) nodes, (\d+) off HRX \(([^)]*)\)" + r"(?:, (\d+) by design, (\d+) unexplained)?, (\d+) graph splits") STRICT_ABORT = re.compile(r"GGML_HRX_STRICT=1: (.*)") @@ -165,7 +171,9 @@ def cmd_placement(logpath): the server was started with GGML_HRX_REPORT=2 and -lv 4, so silence means the check saw nothing.""" with open(logpath, errors="replace") as f: log = f.read() - graphs = [(int(n), int(off), ops, int(splits)) for n, off, ops, splits in PLACEMENT.findall(log)] + graphs = [(int(n), int(off), ops, int(splits), (int(byd) if byd else None), + (int(unex) if unex else None)) + for n, off, ops, byd, unex, splits in PLACEMENT.findall(log)] abort = STRICT_ABORT.search(log) if abort: print("GGML_HRX_STRICT refused: " + abort.group(1).strip()[:300]) @@ -173,13 +181,27 @@ def cmd_placement(logpath): if not graphs: print("no placement report in the server log (GGML_HRX_REPORT=2, -lv 4 were passed)") return 1 - worst = max(graphs, key=lambda g: g[1]) largest = max(g[0] for g in graphs) - if worst[1] > 0: - bad = sum(1 for g in graphs if g[1] > 0) - print(f"{worst[1]} of {worst[0]} nodes off HRX ({worst[2]}), {worst[3]} graph splits; " - f"{bad} of {len(graphs)} graphs had nodes off HRX") + # Which number decides: `unexplained` when the engine printed it, the raw off-HRX count when it did not. + classified = any(g[5] is not None for g in graphs) + if classified: + # A log can hold both shapes (an older line and a newer one from the same run); an unclassified graph falls + # back to its raw count so the comparison never mixes None with int. + worst = max(graphs, key=lambda g: (g[5] if g[5] is not None else g[1], g[1])) + unexplained, by_design = (worst[5] if worst[5] is not None else worst[1]), (worst[4] or 0) + else: + worst = max(graphs, key=lambda g: g[1]) + unexplained, by_design = worst[1], 0 + if unexplained > 0: + bad = sum(1 for g in graphs if (g[5] if g[5] is not None else g[1]) > 0) + print(f"{worst[1]} of {worst[0]} nodes off HRX ({worst[2]}), {worst[3]} graph splits" + + (f", {by_design} by design, {unexplained} unexplained" if classified else "") + + f"; {bad} of {len(graphs)} graphs had misplaced nodes") return 1 + if classified and by_design > 0: + print(f"{by_design} off-HRX node(s) BY DESIGN and none unexplained, in {len(graphs)} graphs " + f"(largest {largest} nodes); the engine classifies mapped-weight and unaligned-matmul nodes as intended") + return 0 print(f"all on HRX in {len(graphs)} graphs (largest {largest} nodes)") return 0