Elfsong commited on
Commit
da5a4da
·
verified ·
1 Parent(s): 7d093e6

Fix dataset viewer with an explicit, normalized mutation witness table

Browse files
Files changed (3) hide show
  1. README.md +26 -0
  2. data/witnesses.jsonl +0 -0
  3. pipeline/export_hf_viewer.py +65 -0
README.md CHANGED
@@ -10,6 +10,11 @@ tags:
10
  - code-generation
11
  size_categories:
12
  - 10K<n<100K
 
 
 
 
 
13
  ---
14
 
15
  # KernelBench-M
@@ -37,6 +42,27 @@ The substrate count above describes the original release. InstanceNorm's
37
  repaired source has passed H100 re-admission; its active witness and summary
38
  records now describe the repaired source and expanded regression suites.
39
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
  Supporting records: `mechanism_curves.json` (Fig. 2b–c), `holdout.json`
41
  (dev/test split), `ladder_summary.json` (knowledge ladder),
42
  `gate_report.json` (substrate admission), `invalid_suites.json` (suites
 
10
  - code-generation
11
  size_categories:
12
  - 10K<n<100K
13
+ configs:
14
+ - config_name: default
15
+ data_files:
16
+ - split: validation
17
+ path: data/witnesses.jsonl
18
  ---
19
 
20
  # KernelBench-M
 
42
  repaired source has passed H100 re-admission; its active witness and summary
43
  records now describe the repaired source and expanded regression suites.
44
 
45
+ ## Dataset Viewer and library access
46
+
47
+ The viewer's `default` configuration contains one row per mutation record in
48
+ the active `witnesses/*.json` files, with `problem` and `mutant_id` identifying
49
+ its source. The other columns preserve the original witness fields, including
50
+ null values. The `validation` split is a browsing table of all active records;
51
+ the dev/test assignment for the paper remains in `holdout.json`.
52
+
53
+ ```python
54
+ from datasets import load_dataset
55
+
56
+ records = load_dataset("Elfsong/KernelBench-M", split="validation")
57
+ # Use streaming=True to iterate without downloading the entire table first.
58
+ ```
59
+
60
+ `data/witnesses.jsonl` is generated by `pipeline/export_hf_viewer.py`. After
61
+ updating active witness records, run `python pipeline/export_hf_viewer.py`
62
+ from the repository root; `--check` verifies that the export is up to date.
63
+ The explicit `data_files` configuration keeps the separate, heterogeneous
64
+ reports in `validation/` out of the viewer's table.
65
+
66
  Supporting records: `mechanism_curves.json` (Fig. 2b–c), `holdout.json`
67
  (dev/test split), `ladder_summary.json` (knowledge ladder),
68
  `gate_report.json` (substrate admission), `invalid_suites.json` (suites
data/witnesses.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
pipeline/export_hf_viewer.py ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Export active mutation witnesses to the table configured in the dataset card."""
2
+
3
+ import argparse
4
+ import json
5
+ from pathlib import Path
6
+
7
+
8
+ WITNESS_FIELDS = ("rule", "family", "site", "cls", "killed_by_official", "witness")
9
+
10
+
11
+ def export_content(dataset_dir: Path) -> tuple[str, int]:
12
+ sources = sorted((dataset_dir / "witnesses").glob("*.json"))
13
+ if not sources:
14
+ raise ValueError(f"No active witness files found in {dataset_dir / 'witnesses'}")
15
+
16
+ lines = []
17
+ seen = set()
18
+ for source in sources:
19
+ records = json.loads(source.read_text(encoding="utf-8"))
20
+ for mutant_id, record in sorted(records.items()):
21
+ if mutant_id in seen or not mutant_id.startswith(source.stem + ":"):
22
+ raise ValueError(f"Duplicate or misplaced mutant ID in {source}: {mutant_id}")
23
+ if set(record) != set(WITNESS_FIELDS):
24
+ raise ValueError(f"Unexpected witness fields in {source}: {mutant_id}")
25
+ for field in WITNESS_FIELDS:
26
+ value = record[field]
27
+ if field == "killed_by_official":
28
+ valid = isinstance(value, bool)
29
+ else:
30
+ valid = isinstance(value, str) or value is None
31
+ if not valid:
32
+ raise ValueError(f"Unexpected {field} type in {source}: {mutant_id}")
33
+ seen.add(mutant_id)
34
+ row = {"problem": source.stem, "mutant_id": mutant_id}
35
+ row.update((field, record[field]) for field in WITNESS_FIELDS)
36
+ lines.append(json.dumps(row, ensure_ascii=False, allow_nan=False))
37
+
38
+ if not lines:
39
+ raise ValueError("Active witness files contain no records")
40
+ return "\n".join(lines) + "\n", len(lines)
41
+
42
+
43
+ def main() -> None:
44
+ parser = argparse.ArgumentParser(description=__doc__)
45
+ parser.add_argument(
46
+ "--dataset-dir", type=Path, default=Path(__file__).resolve().parents[1]
47
+ )
48
+ parser.add_argument(
49
+ "--check", action="store_true", help="Fail if the export is missing or stale"
50
+ )
51
+ args = parser.parse_args()
52
+ content, count = export_content(args.dataset_dir)
53
+ output = args.dataset_dir / "data" / "witnesses.jsonl"
54
+ if args.check:
55
+ if not output.is_file() or output.read_bytes() != content.encode("utf-8"):
56
+ parser.exit(1, f"Missing or stale export: run {Path(__file__).name}\n")
57
+ print(f"Export is current: {count} mutation records")
58
+ else:
59
+ output.parent.mkdir(parents=True, exist_ok=True)
60
+ output.write_text(content, encoding="utf-8")
61
+ print(f"Exported {count} mutation records to {output}")
62
+
63
+
64
+ if __name__ == "__main__":
65
+ main()