Skip to content

Commit d17ecb3

Browse files
committed
fix(profiling): don't report sibling-instrument records as malformed
jax_compile/ hosts export_probe.py and trace_profile.py, which append their own schema into the SAME results/<hardware>/ tree probe.py writes to. Their records have no hardware/dataset_class/instrument because they are a different record kind, not because they are corrupt -- so the 4 the mode was reporting as malformed would have sent someone to fix two files that work correctly. Split the two: missing the whole identity triple is a sibling instrument (reported per file, under its own bucket); missing only some key fields is genuine corruption and stays malformed. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L4STU81pQP1GkMzZVvsMsv
1 parent 854706a commit d17ecb3

3 files changed

Lines changed: 51 additions & 11 deletions

File tree

agents/conductors/profiling/AGENTS.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,12 @@ Records whose cell is not in the sweep grid (`knn`, `delaunay_matern`, the
5757
non-tier hardware in an **other-hardware** bucket. Both are real measurements —
5858
neither counts as grid coverage, and neither is silently dropped.
5959

60+
`jax_compile/` also hosts sibling instruments (`export_probe.py`,
61+
`trace_profile.py`) that append their own schema into the same
62+
`results/<hardware>/` tree. Records missing the whole `(hardware, dataset_class,
63+
instrument)` identity triple are reported as **sibling-instrument** records, not
64+
as malformed — only a record missing *some* of its key fields is corruption.
65+
6066
## Fundamental principles
6167

6268
- **The classification is the result** for CPU-unusable cells (the usability

agents/conductors/profiling/_profiling.py

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@
5757

5858
# Fields a compile record needs before it can be placed on the grid at all.
5959
COMPILE_KEY_FIELDS = ("hardware", "dataset_class", "model_type", "instrument")
60+
# Absent *together*, these mark a record written by a sibling instrument sharing
61+
# the results tree rather than a corrupt probe record.
62+
COMPILE_IDENTITY_FIELDS = ("hardware", "dataset_class", "instrument")
6063

6164

6265
def workspace_root(explicit: str | None = None) -> Path:
@@ -247,16 +250,22 @@ def campaign_compile(ws: Path, tier: str) -> dict[str, Any]:
247250
covered: set[tuple[tuple[str, str, str | None], str]] = set()
248251
off_grid: dict[str, int] = {}
249252
other_hw: dict[str, int] = {}
253+
foreign: dict[str, int] = {}
250254
malformed: list[dict[str, Any]] = []
251255

252256
for rel, idx, rec in load_compile_corpus(ws):
253-
if any(rec.get(f) in (None, "") for f in COMPILE_KEY_FIELDS):
257+
absent = [f for f in COMPILE_KEY_FIELDS if rec.get(f) in (None, "")]
258+
if set(absent) >= set(COMPILE_IDENTITY_FIELDS):
259+
# Not corruption: jax_compile/ hosts sibling instruments
260+
# (export_probe.py, trace_profile.py) that append their own schema
261+
# into the SAME results/<hardware>/ tree. Missing the whole identity
262+
# triple means "another instrument's record", and calling that
263+
# malformed would send someone to fix a file that is working.
264+
foreign[rel] = foreign.get(rel, 0) + 1
265+
continue
266+
if absent:
254267
malformed.append(
255-
{
256-
"record": f"{rel}[{idx}]",
257-
"missing": [f for f in COMPILE_KEY_FIELDS if rec.get(f) in (None, "")],
258-
"tag": rec.get("tag"),
259-
}
268+
{"record": f"{rel}[{idx}]", "missing": absent, "tag": rec.get("tag")}
260269
)
261270
continue
262271
rec_tier = compile_tier_of(rec.get("hardware"))
@@ -314,6 +323,7 @@ def campaign_compile(ws: Path, tier: str) -> dict[str, Any]:
314323
"runs_missing": len(missing),
315324
"missing": missing,
316325
"off_grid": [{"cell": c, "records": n} for c, n in sorted(off_grid.items())],
326+
"foreign_records": [{"file": f, "records": n} for f, n in sorted(foreign.items())],
317327
"other_hardware": [{"hardware": h, "records": n} for h, n in sorted(other_hw.items())],
318328
"malformed": malformed,
319329
"policy": (
@@ -481,6 +491,10 @@ def emit_human(d: dict[str, Any]) -> None:
481491
print("Other hardware (neither tier):")
482492
for o in d["other_hardware"]:
483493
print(f" {o['hardware']}: {o['records']} record(s)")
494+
if d["foreign_records"]:
495+
print("Sibling-instrument records (not probe.py's schema):")
496+
for f in d["foreign_records"]:
497+
print(f" {f['file']}: {f['records']} record(s)")
484498
if d["malformed"]:
485499
print(f"Malformed records: {len(d['malformed'])}")
486500
for m in d["malformed"][:10]:

tests/test_profiling_conductor.py

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,19 +123,39 @@ def test_off_grid_records_are_reported_not_dropped(tmp_path):
123123
assert d["off_grid"] == [{"cell": "imaging/knn/hst", "records": 2}]
124124

125125

126-
def test_malformed_records_are_bucketed_with_their_location(tmp_path):
126+
def test_sibling_instrument_records_are_not_called_malformed(tmp_path):
127+
"""export_probe.py / trace_profile.py share the results tree with probe.py.
128+
129+
Their records lack the whole identity triple because they are a different
130+
schema, not because they are corrupt — reporting them as malformed would
131+
send someone to fix a file that is working correctly.
132+
"""
127133
ws = _workspace(tmp_path, {
128134
"local_cpu/export_probe.json": [
129-
{"transform": "jit", "model_type": "mge", "tag": "census"}, # no hardware/class/instrument
130-
_record(),
135+
{"transform": "jit", "model_type": "mge", "tag": "census"},
136+
{"transform": "vag", "model_type": "mge", "tag": "census"},
131137
],
138+
"local_cpu/mge.json": [_record()],
139+
})
140+
d = json.loads(_run(["campaign", "--axis", "compile", "--json"], ws).stdout)
141+
142+
assert d["malformed"] == []
143+
assert d["foreign_records"] == [{"file": "local_cpu/export_probe.json", "records": 2}]
144+
assert d["runs_done"] == 1, "the real probe record still counts"
145+
146+
147+
def test_a_genuinely_incomplete_probe_record_is_still_malformed(tmp_path):
148+
"""One field missing is corruption; the whole identity triple is a sibling."""
149+
ws = _workspace(tmp_path, {
150+
"local_cpu/mge.json": [_record(instrument=None), _record()],
132151
})
133152
d = json.loads(_run(["campaign", "--axis", "compile", "--json"], ws).stdout)
134153

154+
assert d["foreign_records"] == []
135155
assert len(d["malformed"]) == 1
136156
m = d["malformed"][0]
137-
assert m["record"] == "local_cpu/export_probe.json[0]"
138-
assert set(m["missing"]) == {"hardware", "dataset_class", "instrument"}
157+
assert m["record"] == "local_cpu/mge.json[0]"
158+
assert m["missing"] == ["instrument"]
139159
assert d["runs_done"] == 1, "the well-formed sibling record still counts"
140160

141161

0 commit comments

Comments
 (0)