interplane.Get Omega
Read in your language

CUDApp

CUDA++: AIEN’s GPU machine-code toolchain, runtime and driver client for NVIDIA GPUs without the CUDA toolkit. Hardware coverage and driver replacement limits are explicit.

Brought by drakestapleton

branch main Branches Tags History

CUDApp / evidence / FLASH-NEXT-CODER-FULL-20261118 / verify_index.py

54 lines · 2447 bytes Raw Blame History
1"""Check the per-shard result files against the independent checkpoint weight index."""
2import json
3import re
4import sys
5from collections import Counter, defaultdict
6from pathlib import Path
7
8index, results = map(Path, sys.argv[1:])
9weights = json.loads(index.read_bytes())["weight_map"]
10shards = defaultdict(set)
11pattern = re.compile(r"(?:model\.language_model|mtp)\.layers\.\d+\.mlp\.experts\.\d+\.(down_proj|gate_proj|up_proj)\.weight")
12for name, shard in weights.items():
13 names = shards[shard]
14 if pattern.fullmatch(name):
15 names.add(name)
16
17def require(ok, detail):
18 if not ok:
19 raise SystemExit(f"FAIL {detail}")
20
21files = {p.name for p in results.glob("*.jsonl")}
22require(files == {s + ".jsonl" for s in shards}, "shard set")
23totals = defaultdict(Counter)
24for shard, expected in shards.items():
25 path = results / (shard + ".jsonl")
26 seen = set()
27 with path.open() as records:
28 for line in records:
29 row = json.loads(line)
30 if "done" in row:
31 require(row == {"shard": shard, "expert_matrices": len(seen), "done": 1}, shard)
32 require(records.readline() == "", f"{shard} trailing record")
33 break
34 name = row["name"]
35 require(name in expected and name not in seen, f"{shard} {name}")
36 dims = (2560, 640) if ".down_proj." in name else (640, 2560)
37 require((row["rows"], row["cols"]) == dims, name)
38 require(row["raw"] == dims[0] * dims[1] and row["coded"] > 0, name)
39 require(row["roundtrip"] == 1 and row["flip_detected"] in (0, 1), name)
40 family = "mtp" if name.startswith("mtp.") else "text"
41 counts = totals[family]
42 counts["matrices"] += 1
43 counts["unchanged_after_flip"] += 1 - row["flip_detected"]
44 for field in ("raw", "coded", "rows"):
45 counts[field] += row[field]
46 seen.add(name)
47 else:
48 raise SystemExit(f"FAIL {shard} missing completion marker")
49 require(seen == expected, f"{shard} missing rows")
50require(len(shards) == 131, "shard count")
51for family, count, raw in (("text", 73728, 120795955200), ("mtp", 1536, 2516582400)):
52 require((totals[family]["matrices"], totals[family]["raw"]) == (count, raw), family)
53 print(f"{family} {json.dumps(totals[family], sort_keys=True)}")
54print("PASS inventory, shapes, and clean round trips for both populations")