yamahei21 commited on
Commit
2b2dfe2
·
verified ·
1 Parent(s): a9e710b

Rebuild: 6c480a5f (env fingerprint + verified publish)

Browse files
kit_manifest.json CHANGED
@@ -1,5 +1,13 @@
1
  {
2
- "built_from_commit": "6d843d1d882722d70488fafa163a8925b6249eb3",
 
 
 
 
 
 
 
 
3
  "files": {
4
  "scripts/rht_int4_convert.py": "86419eb87505d7d08737163043ff7989d338a868ddbd08e72ae3185f37ba2819",
5
  "scripts/rewrite_lalamo_hybrid_spec.py": "154564c88391f81b5c24f64125d99abc15d81bd082a8264e36d43a00d4c47a04",
@@ -11,7 +19,7 @@
11
  "scripts/eval_quantized.py": "703904d36ff9f096aa2d7cfbad420318908834b34c2890d10e85aa05fb4fdd28",
12
  "scripts/qad_finetune.py": "26830bf55203a6a2e7fd79451c400949a1f6cdd1fc8d4011b62ff59d39c6e486",
13
  "scripts/compute_bpc.py": "2b55fd1df406d54b40daeeca2ecaf2efb35981655f5bf5e0cc10c057ce796256",
14
- "scripts/run_lane.py": "486beac814f99994beab940025c59ce4104a9be5cb5de95fb9af32a6a3a602d7",
15
  "scripts/make_sweep_spec.py": "dc31ec026c89e7db316a185575a4423bca988c2ac6cf08ef6df8f955328cda69",
16
  "scripts/make_smoke_specs.py": "a76091d7a6a38427cdde5264a49d7bb4d8bfcc75284705817dd4c83b012bba2e",
17
  "scripts/combine_lane_manifests.py": "164ba691d60b3e2987b805426c606d135dcf3cf0c855b38cf7f5d6d57628a481",
@@ -25,11 +33,13 @@
25
  "scripts/dedup_lines.py": "d7caa00dc29f0ba48bc1bdac675e2ed5d81f0514d5d9df17a8f5b2017e6ea8d4",
26
  "scripts/dedup_calibration.py": "62ecc3c3921d307048c9e3547026634b616110115baf561f74dfb74c91e89b7d",
27
  "scripts/check_experiment.py": "a2e7e40909f68031dfccd7013ed055dfbc0ebb21f2a619622b71e6772c685ca5",
28
- "scripts/check_docs.py": "e867ccced2e240fadd9a467dcca018e0d668c5e92ddccaeb4f9f936252f7883d",
29
- "scripts/preflight.py": "4f713d8a3c0c6b18cfbebbcdb9c16c50cd51be31d9da63ce3e78f12863a090f2",
 
 
30
  "scripts/tiny_sharding_probe.py": "29eb58f2689242b919616f6aab6ff753e0de031b16371137975b4d645e836fae",
31
  "scripts/audit_public_corpus.py": "84f1ec805a74004e71f63a70a8ed19967cb3fad9966f254798e655ab95e53ab0",
32
- "scripts/build_kit.py": "93d86c32562c1485a3164649355874d68b24695f3252ac9d863c02e95c0ac9e8",
33
  "scripts/bootstrap_kaggle.py": "1633e3edbb80976c337444e3e4544e2b5210b2d8d1821e3a2717c1099c00843e",
34
  "data/calibration_en_wikitext2_dedup.txt": "18a79f4f938cc25747a90a12b120c7131e7f4ac55b58dfc691795ea61d4b5e9a",
35
  "data/calibration_ja_wikipedia_dedup.txt": "b45e3f3f00f2137be280a75c1fa9c9883a7e69d289257c4388fc701f33fee0d1",
 
1
  {
2
+ "built_from_commit": "6c480a5f6224f7598c6c0b6388bcadc8f16502a5",
3
+ "capabilities": [
4
+ "rht_int4_convert.layer_filter",
5
+ "eval_quantized.dtype",
6
+ "preflight",
7
+ "preflight.sdpa_xla",
8
+ "env_fingerprint",
9
+ "qad.freeze_scales"
10
+ ],
11
  "files": {
12
  "scripts/rht_int4_convert.py": "86419eb87505d7d08737163043ff7989d338a868ddbd08e72ae3185f37ba2819",
13
  "scripts/rewrite_lalamo_hybrid_spec.py": "154564c88391f81b5c24f64125d99abc15d81bd082a8264e36d43a00d4c47a04",
 
19
  "scripts/eval_quantized.py": "703904d36ff9f096aa2d7cfbad420318908834b34c2890d10e85aa05fb4fdd28",
20
  "scripts/qad_finetune.py": "26830bf55203a6a2e7fd79451c400949a1f6cdd1fc8d4011b62ff59d39c6e486",
21
  "scripts/compute_bpc.py": "2b55fd1df406d54b40daeeca2ecaf2efb35981655f5bf5e0cc10c057ce796256",
22
+ "scripts/run_lane.py": "cd74b56651cdff82b4ff12ab74fa84ecce1a658eb205c72faa1f6b770148ada6",
23
  "scripts/make_sweep_spec.py": "dc31ec026c89e7db316a185575a4423bca988c2ac6cf08ef6df8f955328cda69",
24
  "scripts/make_smoke_specs.py": "a76091d7a6a38427cdde5264a49d7bb4d8bfcc75284705817dd4c83b012bba2e",
25
  "scripts/combine_lane_manifests.py": "164ba691d60b3e2987b805426c606d135dcf3cf0c855b38cf7f5d6d57628a481",
 
33
  "scripts/dedup_lines.py": "d7caa00dc29f0ba48bc1bdac675e2ed5d81f0514d5d9df17a8f5b2017e6ea8d4",
34
  "scripts/dedup_calibration.py": "62ecc3c3921d307048c9e3547026634b616110115baf561f74dfb74c91e89b7d",
35
  "scripts/check_experiment.py": "a2e7e40909f68031dfccd7013ed055dfbc0ebb21f2a619622b71e6772c685ca5",
36
+ "scripts/check_docs.py": "b293dab14b2e8ebb63b32b07ec4454ca08b7bee194ee10c56871a340c6c8eda6",
37
+ "scripts/preflight.py": "5c2bcbe3693c8abf645fbf3f8160d96fdc1695daf09dc4961464ca8a23698e6e",
38
+ "scripts/env_fingerprint.py": "651db85ad3cdf28bc46e97010986109df60785eb6646507ee38b0fa75dce57d5",
39
+ "scripts/kaggle_slots.py": "e3baafe52347e74158c5b82fe6a2849f72a201d8ce60c0bbbf0871e47c75ae79",
40
  "scripts/tiny_sharding_probe.py": "29eb58f2689242b919616f6aab6ff753e0de031b16371137975b4d645e836fae",
41
  "scripts/audit_public_corpus.py": "84f1ec805a74004e71f63a70a8ed19967cb3fad9966f254798e655ab95e53ab0",
42
+ "scripts/build_kit.py": "1f8c3519fe8ffe29963b80f81d066de554b30f2294f993dee737b62e6bbb2541",
43
  "scripts/bootstrap_kaggle.py": "1633e3edbb80976c337444e3e4544e2b5210b2d8d1821e3a2717c1099c00843e",
44
  "data/calibration_en_wikitext2_dedup.txt": "18a79f4f938cc25747a90a12b120c7131e7f4ac55b58dfc691795ea61d4b5e9a",
45
  "data/calibration_ja_wikipedia_dedup.txt": "b45e3f3f00f2137be280a75c1fa9c9883a7e69d289257c4388fc701f33fee0d1",
scripts/build_kit.py CHANGED
@@ -59,6 +59,8 @@ KIT_SCRIPTS = [
59
  "check_experiment.py",
60
  "check_docs.py",
61
  "preflight.py",
 
 
62
  # sharding / audit
63
  "tiny_sharding_probe.py",
64
  "audit_public_corpus.py",
@@ -143,6 +145,9 @@ def build(output: Path) -> list[str]:
143
  MANIFEST_NAME = "kit_manifest.json"
144
  manifest = {
145
  "built_from_commit": source_commit(),
 
 
 
146
  "files": {
147
  name: sha256(output / name) for name in copied
148
  },
@@ -151,6 +156,28 @@ def build(output: Path) -> list[str]:
151
  return copied
152
 
153
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
154
  def local_modules(scripts: list[Path]) -> dict[str, set[str]]:
155
  """Map module name -> places where it is imported, for kit-local modules."""
156
  available = {path.stem for path in scripts}
 
59
  "check_experiment.py",
60
  "check_docs.py",
61
  "preflight.py",
62
+ "env_fingerprint.py",
63
+ "kaggle_slots.py",
64
  # sharding / audit
65
  "tiny_sharding_probe.py",
66
  "audit_public_corpus.py",
 
145
  MANIFEST_NAME = "kit_manifest.json"
146
  manifest = {
147
  "built_from_commit": source_commit(),
148
+ # Downstream kernels should assert these, not an exact commit hash:
149
+ # the kit is rebuilt often, but a capability answers the real question.
150
+ "capabilities": detect_capabilities(output),
151
  "files": {
152
  name: sha256(output / name) for name in copied
153
  },
 
156
  return copied
157
 
158
 
159
+ def detect_capabilities(root: Path) -> list[str]:
160
+ """Features a consumer may depend on, independent of the commit hash."""
161
+ wanted = {
162
+ "rht_int4_convert.layer_filter": ("scripts/rht_int4_convert.py", "--layer-filter"),
163
+ "eval_quantized.dtype": ("scripts/eval_quantized.py", "--dtype"),
164
+ "preflight": ("scripts/preflight.py", "def verdict"),
165
+ "preflight.sdpa_xla": ("scripts/preflight.py", "sdpa_xla"),
166
+ "env_fingerprint": ("scripts/env_fingerprint.py", "lalamo_code_hashes"),
167
+ "qad.freeze_scales": ("scripts/qad_finetune.py", "--freeze-scales"),
168
+ }
169
+ found = []
170
+ for name, (relative, needle) in wanted.items():
171
+ path = root / relative
172
+ try:
173
+ text = path.read_text(encoding="utf-8")
174
+ except OSError:
175
+ continue
176
+ if needle in text:
177
+ found.append(name)
178
+ return found
179
+
180
+
181
  def local_modules(scripts: list[Path]) -> dict[str, set[str]]:
182
  """Map module name -> places where it is imported, for kit-local modules."""
183
  available = {path.stem for path in scripts}
scripts/check_docs.py CHANGED
@@ -36,6 +36,7 @@ DEFAULT_DOCS = [
36
  "docs/KAGGLE_SLOTS.md",
37
  "docs/EVAL.md",
38
  "docs/MODAL.md",
 
39
  "tests/README.md",
40
  "antigravity/README.md",
41
  ]
 
36
  "docs/KAGGLE_SLOTS.md",
37
  "docs/EVAL.md",
38
  "docs/MODAL.md",
39
+ "docs/ENVIRONMENT.md",
40
  "tests/README.md",
41
  "antigravity/README.md",
42
  ]
scripts/env_fingerprint.py ADDED
@@ -0,0 +1,144 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Canonical environment fingerprint for quantization runs.
3
+
4
+ Version strings lie. PyPI ``lalamo==0.17.0`` (2026-09-24) and the pinned git
5
+ commit ``e401e177`` (2026-11-02) both report 0.17.0, but the PyPI tree has no
6
+ ``compressed/incoherence.py``, so RHT cannot run there. Comparing results from
7
+ those two installs is meaningless even though every version field matches.
8
+
9
+ The fingerprint records two independent identities:
10
+
11
+ 1. where the package came from (``direct_url.json``: VCS URL + commit)
12
+ 2. hashes of the files that change numerics (RHT / INT4 / weight layout)
13
+
14
+ (2) is the one to trust: identical hashes mean identical quantize/dequantize
15
+ code, regardless of how the package was installed.
16
+
17
+ Usage:
18
+ python scripts/env_fingerprint.py
19
+ python scripts/env_fingerprint.py --json out.json
20
+ """
21
+
22
+ from __future__ import annotations
23
+
24
+ import argparse
25
+ import hashlib
26
+ import json
27
+ import platform
28
+ import sys
29
+ from importlib.metadata import distribution, version
30
+ from pathlib import Path
31
+
32
+ # Files that directly determine the quantized weights. A change in any of
33
+ # these can move BPC, so they belong in every result manifest.
34
+ FINGERPRINT_FILES = (
35
+ "compressed/incoherence.py",
36
+ "compressed/int.py",
37
+ "compressed/hybrid.py",
38
+ "compressed/quant_params.py",
39
+ "weight_matrix.py",
40
+ )
41
+
42
+
43
+ def file_sha256(path: Path) -> str | None:
44
+ try:
45
+ return hashlib.sha256(path.read_bytes()).hexdigest()
46
+ except OSError:
47
+ return None
48
+
49
+
50
+ def parse_direct_url(text: str | None) -> dict[str, str]:
51
+ """Extract the VCS source of an installed distribution.
52
+
53
+ PyPI and a git checkout can both report version 0.17.0 while shipping
54
+ different code, so the version string alone is not provenance.
55
+ """
56
+ try:
57
+ payload = json.loads(text or "")
58
+ except (TypeError, ValueError):
59
+ return {}
60
+ if not isinstance(payload, dict):
61
+ return {}
62
+ result: dict[str, str] = {}
63
+ url = payload.get("url")
64
+ if url:
65
+ result["source"] = url
66
+ commit = (payload.get("vcs_info") or {}).get("commit_id")
67
+ if commit:
68
+ result["commit"] = commit
69
+ return result
70
+
71
+
72
+ def lalamo_root() -> Path | None:
73
+ try:
74
+ import lalamo
75
+
76
+ return Path(lalamo.__file__).resolve().parent
77
+ except Exception: # noqa: BLE001 - fingerprint must never break a run
78
+ return None
79
+
80
+
81
+ def lalamo_provenance() -> dict[str, str]:
82
+ seen: dict[str, str] = {}
83
+ try:
84
+ seen["lalamo_version"] = version("lalamo")
85
+ parsed = parse_direct_url(distribution("lalamo").read_text("direct_url.json"))
86
+ except Exception: # noqa: BLE001
87
+ return seen
88
+ if parsed.get("source"):
89
+ seen["lalamo_source"] = parsed["source"]
90
+ if parsed.get("commit"):
91
+ seen["lalamo_commit"] = parsed["commit"]
92
+ if not parsed:
93
+ seen["lalamo_source"] = "pypi-or-unknown"
94
+ return seen
95
+
96
+
97
+ def lalamo_code_hashes(root: Path | None = None) -> dict[str, str]:
98
+ root = root or lalamo_root()
99
+ if root is None:
100
+ return {}
101
+ hashes: dict[str, str] = {}
102
+ missing = []
103
+ for relative in FINGERPRINT_FILES:
104
+ digest = file_sha256(root / relative)
105
+ if digest:
106
+ key = "lalamo_" + relative.replace("/", "_").replace(".py", "") + "_sha256"
107
+ hashes[key] = digest
108
+ else:
109
+ missing.append(relative)
110
+ hashes["lalamo_hash_complete"] = "false" if missing else "true"
111
+ if missing:
112
+ hashes["lalamo_hash_missing"] = ",".join(missing)
113
+ return hashes
114
+
115
+
116
+ def fingerprint() -> dict[str, str]:
117
+ """Everything needed to decide whether two runs used the same code."""
118
+ seen: dict[str, str] = {"python_version": platform.python_version()}
119
+ try:
120
+ seen["jax_version"] = version("jax")
121
+ except Exception: # noqa: BLE001
122
+ pass
123
+ seen.update(lalamo_provenance())
124
+ seen.update(lalamo_code_hashes())
125
+ return seen
126
+
127
+
128
+ def main() -> None:
129
+ parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
130
+ parser.add_argument("--json", type=Path, default=None)
131
+ args = parser.parse_args()
132
+
133
+ report = fingerprint()
134
+ text = json.dumps(report, indent=2, sort_keys=True)
135
+ print(text)
136
+ if args.json:
137
+ args.json.parent.mkdir(parents=True, exist_ok=True)
138
+ args.json.write_text(text + "\n", encoding="utf-8")
139
+ if not any(key.endswith("_sha256") for key in report):
140
+ print("warning: lalamo is not importable; no code hashes recorded", file=sys.stderr)
141
+
142
+
143
+ if __name__ == "__main__":
144
+ main()
scripts/kaggle_slots.py ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Check how many Kaggle sessions are running before pushing another one.
3
+
4
+ We accidentally had six CPU kernels alive. Kaggle silently drops whichever it
5
+ wants, so the rule is: never exceed the per-account cap; wait in line instead.
6
+
7
+ python scripts/kaggle_slots.py # owner kernels from tasks/kernels.json
8
+ python scripts/kaggle_slots.py --extra yamahei21python/uzu-foo
9
+ python scripts/kaggle_slots.py --max 5 --json out.json
10
+
11
+ Exit code is 1 when the account is full, so a shell guard can refuse the push.
12
+ """
13
+
14
+ from __future__ import annotations
15
+
16
+ import argparse
17
+ import json
18
+ import subprocess
19
+ from pathlib import Path
20
+
21
+ ROOT = Path(__file__).resolve().parents[1]
22
+ TASKS = ROOT / "tasks" / "kernels.json"
23
+
24
+ TERMINAL = ("COMPLETE", "ERROR", "FAILED", "CANCEL", "CANCELLED")
25
+
26
+
27
+ def status_of(kernel: str) -> str:
28
+ try:
29
+ result = subprocess.run(
30
+ ["kaggle", "kernels", "status", kernel], text=True, capture_output=True, check=False
31
+ )
32
+ except OSError:
33
+ return "unknown"
34
+ text = (result.stdout or "") + (result.stderr or "")
35
+ line = next((item.strip() for item in text.splitlines() if "status" in item.lower()), "")
36
+ return line or "unknown"
37
+
38
+
39
+ def is_running(status: str) -> bool:
40
+ upper = status.upper()
41
+ if any(marker in upper for marker in TERMINAL):
42
+ return False
43
+ return "RUNNING" in upper or "QUEUED" in upper
44
+
45
+
46
+ def count_running(statuses: list[str]) -> int:
47
+ return sum(1 for status in statuses if is_running(status))
48
+
49
+
50
+ def owner_entries() -> list[dict]:
51
+ if not TASKS.exists():
52
+ return []
53
+ payload = json.loads(TASKS.read_text(encoding="utf-8"))
54
+ return [entry for entry in payload.get("kernels", []) if entry.get("owner") == "owner"]
55
+
56
+
57
+ def main() -> None:
58
+ parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
59
+ parser.add_argument("--max-cpu", type=int, default=5)
60
+ parser.add_argument("--max-gpu", type=int, default=2)
61
+ parser.add_argument("--extra", action="append", default=[], help="additional kernel refs to count")
62
+ parser.add_argument("--json", type=Path, default=None)
63
+ args = parser.parse_args()
64
+
65
+ rows = []
66
+ for entry in owner_entries():
67
+ status = status_of(entry["ref"])
68
+ rows.append(
69
+ {
70
+ "kernel": entry["ref"],
71
+ "kind": entry.get("kind", "cpu"),
72
+ "status": status,
73
+ "running": is_running(status),
74
+ }
75
+ )
76
+ for kernel in args.extra:
77
+ status = status_of(kernel)
78
+ rows.append({"kernel": kernel, "kind": "cpu", "status": status, "running": is_running(status)})
79
+
80
+ cpu_running = sum(1 for row in rows if row["running"] and row["kind"] == "cpu")
81
+ gpu_running = sum(1 for row in rows if row["running"] and row["kind"] == "gpu")
82
+ running = cpu_running + gpu_running
83
+ print(f"{'kernel':34s} {'kind':5s} {'running':8s} status")
84
+ for row in rows:
85
+ print(
86
+ f"{row['kernel'].split('/')[-1]:34s} {row['kind']:5s} "
87
+ f"{'yes' if row['running'] else 'no':8s} {row['status'][:50]}"
88
+ )
89
+ print(f"\ncpu {cpu_running}/{args.max_cpu} gpu {gpu_running}/{args.max_gpu}")
90
+
91
+ if args.json:
92
+ args.json.parent.mkdir(parents=True, exist_ok=True)
93
+ args.json.write_text(
94
+ json.dumps(
95
+ {"cpu_running": cpu_running, "gpu_running": gpu_running,
96
+ "max_cpu": args.max_cpu, "max_gpu": args.max_gpu, "rows": rows},
97
+ indent=2,
98
+ )
99
+ + "\n",
100
+ encoding="utf-8",
101
+ )
102
+
103
+ if cpu_running >= args.max_cpu or gpu_running >= args.max_gpu:
104
+ print("account is full: wait for a slot instead of pushing another kernel")
105
+ raise SystemExit(1)
106
+
107
+
108
+ if __name__ == "__main__":
109
+ main()
scripts/preflight.py CHANGED
@@ -17,6 +17,7 @@ from __future__ import annotations
17
  import argparse
18
  import json
19
  import os
 
20
  import shutil
21
  import subprocess
22
  import sys
@@ -44,8 +45,11 @@ def verdict(capabilities: list[float], probes: dict | None = None) -> dict:
44
  def status(name: str) -> str:
45
  return str(probes.get(name, "skip"))
46
 
47
- core = ("dot", "dot_f32_acc", "sdpa_xla", "quant_roundtrip", "qad_grad", "tokenizer")
 
 
48
  failures = [name for name in core if status(name) == "fail"]
 
49
  bf16 = all(status(name) == "pass" for name in ("dot", "dot_f32_acc", "sdpa_xla"))
50
 
51
  if status("sdpa_xla") == "fail":
@@ -65,6 +69,7 @@ def verdict(capabilities: list[float], probes: dict | None = None) -> dict:
65
  "probes": probes,
66
  "probe_failures": failures,
67
  "lane_ok": not failures,
 
68
  "eval_dtype": "bfloat16" if bf16 else "float32",
69
  "attention": attention,
70
  "note": note,
@@ -135,7 +140,9 @@ PROBES = {
135
  "def loss(w):\n"
136
  " return jnp.sum(spec.compress(w, key=jax.random.key(0), sharding_config=sharding).decompress() ** 2)\n"
137
  "w = jax.device_put(np.random.RandomState(0).randn(64, 32).astype(np.float32), sharding.resolve_sharding((None, None)))\n"
138
- "grad = jax.grad(loss)(w)\n"
 
 
139
  "assert bool(jnp.isfinite(grad).all())\n"
140
  ),
141
  }
@@ -144,6 +151,18 @@ PROBES = {
144
  LALAMO_PROBES = {"quant_roundtrip", "qad_grad"}
145
 
146
 
 
 
 
 
 
 
 
 
 
 
 
 
147
  def run_probe(name: str, code: str, extra: list[str] | None = None) -> tuple[str, str | None]:
148
  """Returns (pass|fail|skip, error)."""
149
  try:
@@ -159,11 +178,10 @@ def run_probe(name: str, code: str, extra: list[str] | None = None) -> tuple[str
159
  if result.returncode == 0:
160
  return "pass", None
161
  message = (result.stderr or result.stdout or "").strip()[-400:] or "unknown failure"
162
- if name in LALAMO_PROBES and "lalamo" in message and (
163
- "ModuleNotFoundError" in message or "No module named" in message
164
- ):
165
- return "skip", "lalamo not importable in this interpreter"
166
- return "fail", message
167
 
168
 
169
  def measure_probes(tokenizer_path: Path | None = None) -> tuple[dict, dict]:
@@ -236,6 +254,12 @@ def main() -> None:
236
  "kit_commit": kit_commit(Path("kit")),
237
  }
238
  report.update(verdict(capabilities, probes))
 
 
 
 
 
 
239
  report["jax_version"] = None
240
  try:
241
  from importlib.metadata import version
 
17
  import argparse
18
  import json
19
  import os
20
+ import re
21
  import shutil
22
  import subprocess
23
  import sys
 
45
  def status(name: str) -> str:
46
  return str(probes.get(name, "skip"))
47
 
48
+ # qad_grad is checked separately: it needs a mesh context that non-QAD
49
+ # lanes never create, so a failure there must not block ordinary lanes.
50
+ core = ("dot", "dot_f32_acc", "sdpa_xla", "quant_roundtrip", "tokenizer")
51
  failures = [name for name in core if status(name) == "fail"]
52
+ qad_failure = status("qad_grad") == "fail"
53
  bf16 = all(status(name) == "pass" for name in ("dot", "dot_f32_acc", "sdpa_xla"))
54
 
55
  if status("sdpa_xla") == "fail":
 
69
  "probes": probes,
70
  "probe_failures": failures,
71
  "lane_ok": not failures,
72
+ "qad_ok": not qad_failure,
73
  "eval_dtype": "bfloat16" if bf16 else "float32",
74
  "attention": attention,
75
  "note": note,
 
140
  "def loss(w):\n"
141
  " return jnp.sum(spec.compress(w, key=jax.random.key(0), sharding_config=sharding).decompress() ** 2)\n"
142
  "w = jax.device_put(np.random.RandomState(0).randn(64, 32).astype(np.float32), sharding.resolve_sharding((None, None)))\n"
143
+ "mesh = sharding.resolve_sharding((None, None)).mesh\n"
144
+ "with jax.set_mesh(mesh):\n"
145
+ " grad = jax.grad(loss)(w)\n"
146
  "assert bool(jnp.isfinite(grad).all())\n"
147
  ),
148
  }
 
151
  LALAMO_PROBES = {"quant_roundtrip", "qad_grad"}
152
 
153
 
154
+ def classify_probe_failure(name: str, message: str) -> tuple[str, str | None]:
155
+ """Missing top-level lalamo is a skip; a missing submodule is a failure.
156
+
157
+ The PyPI lalamo 0.17.0 tree reports ModuleNotFoundError for
158
+ ``lalamo.compressed.incoherence``. Treating that as "skip" would let the
159
+ wrong environment pass the gate.
160
+ """
161
+ if name in LALAMO_PROBES and re.search(r"No module named 'lalamo'(\s|$|\")", message):
162
+ return "skip", "lalamo not importable in this interpreter"
163
+ return "fail", message
164
+
165
+
166
  def run_probe(name: str, code: str, extra: list[str] | None = None) -> tuple[str, str | None]:
167
  """Returns (pass|fail|skip, error)."""
168
  try:
 
178
  if result.returncode == 0:
179
  return "pass", None
180
  message = (result.stderr or result.stdout or "").strip()[-400:] or "unknown failure"
181
+ # Only a missing top-level package is a skip. A missing submodule means the
182
+ # installed lalamo is the wrong tree (PyPI 0.17.0 has no compressed/
183
+ # incoherence.py), which must fail the gate instead of being skipped.
184
+ return classify_probe_failure(name, message)
 
185
 
186
 
187
  def measure_probes(tokenizer_path: Path | None = None) -> tuple[dict, dict]:
 
254
  "kit_commit": kit_commit(Path("kit")),
255
  }
256
  report.update(verdict(capabilities, probes))
257
+ try:
258
+ from env_fingerprint import fingerprint
259
+
260
+ report["environment"] = fingerprint()
261
+ except Exception: # noqa: BLE001 - older kits may not ship env_fingerprint.py
262
+ report["environment"] = {}
263
  report["jax_version"] = None
264
  try:
265
  from importlib.metadata import version
scripts/run_lane.py CHANGED
@@ -92,6 +92,19 @@ def find_dataset_dir(root: Path, name: str) -> Path | None:
92
  return None
93
 
94
 
 
 
 
 
 
 
 
 
 
 
 
 
 
95
  class Runner:
96
  def __init__(self, spec: dict[str, Any], spec_path: Path, *, dry_run: bool = False) -> None:
97
  self.spec = spec
@@ -156,6 +169,7 @@ class Runner:
156
  seen["jax_version"] = version("jax")
157
  except Exception: # noqa: BLE001 - provenance must never break a run
158
  pass
 
159
  return seen
160
 
161
  def environment(self, base: dict[str, str] | None = None) -> dict[str, str]:
@@ -210,6 +224,15 @@ class Runner:
210
  print(f"preflight failed to produce a report (rc={result.returncode})", flush=True)
211
  return None
212
  report = json.loads(report_path.read_text(encoding="utf-8"))
 
 
 
 
 
 
 
 
 
213
  if (self.jax_platform or "").startswith("gpu") and report.get("attention") == "unavailable":
214
  raise SystemExit(
215
  "preflight: dot_product_attention is unavailable on this GPU "
@@ -609,6 +632,7 @@ class Runner:
609
  "model": self.spec.get("model"),
610
  "eval": self.spec.get("eval"),
611
  "env": self.env_provenance(),
 
612
  "eval_dtype": self.eval_dtype,
613
  "results": summaries,
614
  "problems": problems,
 
92
  return None
93
 
94
 
95
+ try:
96
+ from env_fingerprint import fingerprint, lalamo_provenance, parse_direct_url
97
+ except Exception: # noqa: BLE001 - older kits may not ship env_fingerprint.py
98
+ def parse_direct_url(text: str) -> dict[str, str]:
99
+ return {}
100
+
101
+ def lalamo_provenance() -> dict[str, str]:
102
+ return {}
103
+
104
+ def fingerprint() -> dict[str, str]:
105
+ return {}
106
+
107
+
108
  class Runner:
109
  def __init__(self, spec: dict[str, Any], spec_path: Path, *, dry_run: bool = False) -> None:
110
  self.spec = spec
 
169
  seen["jax_version"] = version("jax")
170
  except Exception: # noqa: BLE001 - provenance must never break a run
171
  pass
172
+ seen.update(lalamo_provenance())
173
  return seen
174
 
175
  def environment(self, base: dict[str, str] | None = None) -> dict[str, str]:
 
224
  print(f"preflight failed to produce a report (rc={result.returncode})", flush=True)
225
  return None
226
  report = json.loads(report_path.read_text(encoding="utf-8"))
227
+ probes = report.get("probes") or {}
228
+ if probes.get("quant_roundtrip") == "fail":
229
+ error = (report.get("probe_errors") or {}).get("quant_roundtrip", "")
230
+ raise SystemExit(
231
+ "preflight: lalamo has no working RHT quantize/dequantize path. "
232
+ "This is the PyPI 0.17.0 trap: install "
233
+ "git+https://github.com/trymirai/lalamo@e401e177 instead. "
234
+ f"{error}".strip()
235
+ )
236
  if (self.jax_platform or "").startswith("gpu") and report.get("attention") == "unavailable":
237
  raise SystemExit(
238
  "preflight: dot_product_attention is unavailable on this GPU "
 
632
  "model": self.spec.get("model"),
633
  "eval": self.spec.get("eval"),
634
  "env": self.env_provenance(),
635
+ "environment_fingerprint": fingerprint(),
636
  "eval_dtype": self.eval_dtype,
637
  "results": summaries,
638
  "problems": problems,