Datasets:
Rebuild: preflight probes (tokenizer/quant/qad)
Browse files- kit_manifest.json +3 -3
- scripts/preflight.py +99 -26
- scripts/run_lane.py +25 -0
kit_manifest.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
{
|
| 2 |
-
"built_from_commit": "
|
| 3 |
"files": {
|
| 4 |
"scripts/rht_int4_convert.py": "add2a584ad9e0d586bfaa16230b19491c580f9e7a11a7aac5fdfb4972e1eca9d",
|
| 5 |
"scripts/rewrite_lalamo_hybrid_spec.py": "154564c88391f81b5c24f64125d99abc15d81bd082a8264e36d43a00d4c47a04",
|
|
@@ -11,7 +11,7 @@
|
|
| 11 |
"scripts/eval_quantized.py": "703904d36ff9f096aa2d7cfbad420318908834b34c2890d10e85aa05fb4fdd28",
|
| 12 |
"scripts/qad_finetune.py": "26830bf55203a6a2e7fd79451c400949a1f6cdd1fc8d4011b62ff59d39c6e486",
|
| 13 |
"scripts/compute_bpc.py": "2b55fd1df406d54b40daeeca2ecaf2efb35981655f5bf5e0cc10c057ce796256",
|
| 14 |
-
"scripts/run_lane.py": "
|
| 15 |
"scripts/make_sweep_spec.py": "dc31ec026c89e7db316a185575a4423bca988c2ac6cf08ef6df8f955328cda69",
|
| 16 |
"scripts/make_smoke_specs.py": "a76091d7a6a38427cdde5264a49d7bb4d8bfcc75284705817dd4c83b012bba2e",
|
| 17 |
"scripts/combine_lane_manifests.py": "164ba691d60b3e2987b805426c606d135dcf3cf0c855b38cf7f5d6d57628a481",
|
|
@@ -26,7 +26,7 @@
|
|
| 26 |
"scripts/dedup_calibration.py": "62ecc3c3921d307048c9e3547026634b616110115baf561f74dfb74c91e89b7d",
|
| 27 |
"scripts/check_experiment.py": "a2e7e40909f68031dfccd7013ed055dfbc0ebb21f2a619622b71e6772c685ca5",
|
| 28 |
"scripts/check_docs.py": "e867ccced2e240fadd9a467dcca018e0d668c5e92ddccaeb4f9f936252f7883d",
|
| 29 |
-
"scripts/preflight.py": "
|
| 30 |
"scripts/tiny_sharding_probe.py": "29eb58f2689242b919616f6aab6ff753e0de031b16371137975b4d645e836fae",
|
| 31 |
"scripts/audit_public_corpus.py": "84f1ec805a74004e71f63a70a8ed19967cb3fad9966f254798e655ab95e53ab0",
|
| 32 |
"scripts/build_kit.py": "93d86c32562c1485a3164649355874d68b24695f3252ac9d863c02e95c0ac9e8",
|
|
|
|
| 1 |
{
|
| 2 |
+
"built_from_commit": "bb6bfb3e1e579f78f643118260e0d4168a1aad76",
|
| 3 |
"files": {
|
| 4 |
"scripts/rht_int4_convert.py": "add2a584ad9e0d586bfaa16230b19491c580f9e7a11a7aac5fdfb4972e1eca9d",
|
| 5 |
"scripts/rewrite_lalamo_hybrid_spec.py": "154564c88391f81b5c24f64125d99abc15d81bd082a8264e36d43a00d4c47a04",
|
|
|
|
| 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",
|
|
|
|
| 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",
|
scripts/preflight.py
CHANGED
|
@@ -36,31 +36,35 @@ def parse_capabilities(output: str) -> list[float]:
|
|
| 36 |
return values
|
| 37 |
|
| 38 |
|
| 39 |
-
def verdict(capabilities: list[float],
|
| 40 |
"""Pure decision table so it can be tested without a GPU."""
|
| 41 |
-
ampere = bool(capabilities) and all(value >= TRITON_MIN for value in capabilities)
|
| 42 |
-
if bf16_ok is None:
|
| 43 |
-
bf16 = ampere # no measurement: fall back to the hardware generation
|
| 44 |
-
source = "capability"
|
| 45 |
-
else:
|
| 46 |
-
bf16 = bf16_ok
|
| 47 |
-
source = "measured"
|
| 48 |
probes = probes or {}
|
| 49 |
-
|
| 50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
attention = "unavailable"
|
| 52 |
note = "dot_product_attention is unsupported on this GPU: use CPU or Modal"
|
| 53 |
-
elif
|
| 54 |
attention = "default"
|
| 55 |
note = "" if bf16 else "BF16 accumulation unsupported: use float32"
|
| 56 |
else:
|
| 57 |
attention = "default" if ampere else "xla"
|
| 58 |
note = "" if bf16 else "BF16 unsupported: use float32 or CPU/Modal"
|
|
|
|
| 59 |
return {
|
| 60 |
"ampere_or_newer": ampere,
|
| 61 |
"bf16_matmul": bf16,
|
| 62 |
-
"bf16_source":
|
| 63 |
"probes": probes,
|
|
|
|
|
|
|
| 64 |
"eval_dtype": "bfloat16" if bf16 else "float32",
|
| 65 |
"attention": attention,
|
| 66 |
"note": note,
|
|
@@ -86,26 +90,91 @@ PROBES = {
|
|
| 86 |
"q = jnp.ones((2, 4, 8, 16), dtype=jnp.bfloat16)\n"
|
| 87 |
"jax.nn.dot_product_attention(q, q, q, implementation='xla').block_until_ready()\n"
|
| 88 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
}
|
| 90 |
|
|
|
|
|
|
|
| 91 |
|
| 92 |
-
|
|
|
|
|
|
|
| 93 |
try:
|
| 94 |
result = subprocess.run(
|
| 95 |
-
[sys.executable, "-c", code
|
|
|
|
|
|
|
|
|
|
|
|
|
| 96 |
)
|
| 97 |
except (OSError, subprocess.TimeoutExpired) as error:
|
| 98 |
-
return
|
| 99 |
if result.returncode == 0:
|
| 100 |
-
return
|
| 101 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 102 |
|
| 103 |
|
| 104 |
-
def measure_probes() -> tuple[dict, dict]:
|
| 105 |
results, errors = {}, {}
|
| 106 |
for name, code in PROBES.items():
|
| 107 |
-
|
| 108 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 109 |
if error:
|
| 110 |
errors[name] = error
|
| 111 |
return results, errors
|
|
@@ -133,7 +202,8 @@ def main() -> None:
|
|
| 133 |
parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
|
| 134 |
parser.add_argument("--json", type=Path, default=None)
|
| 135 |
parser.add_argument("--strict", action="store_true", help="exit 1 if BF16 matmul is unavailable")
|
| 136 |
-
parser.add_argument("--skip-bf16", action="store_true", help="do not import jax")
|
|
|
|
| 137 |
args = parser.parse_args()
|
| 138 |
|
| 139 |
try:
|
|
@@ -147,22 +217,25 @@ def main() -> None:
|
|
| 147 |
except OSError:
|
| 148 |
nvidia_stdout = ""
|
| 149 |
capabilities = parse_capabilities(nvidia_stdout)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 150 |
if args.skip_bf16:
|
| 151 |
probes, probe_errors = {}, {}
|
| 152 |
else:
|
| 153 |
-
probes, probe_errors = measure_probes()
|
| 154 |
-
bf16_ok = None if args.skip_bf16 else (bool(probes) and all(probes.values()))
|
| 155 |
|
| 156 |
report = {
|
| 157 |
"jax_platform": os.environ.get("JAX_PLATFORM_NAME"),
|
| 158 |
"compute_capabilities": capabilities,
|
| 159 |
"gpu_names": [line.split(",")[-1].strip() for line in nvidia_stdout.splitlines() if line.strip()],
|
| 160 |
-
"
|
| 161 |
-
"probe_errors": {k: v for k, v in (probe_errors if not args.skip_bf16 else {}).items()},
|
| 162 |
"disk_free_gib": disk_free_gib(Path("/kaggle/working")) if Path("/kaggle/working").exists() else disk_free_gib(Path(".")),
|
| 163 |
"kit_commit": kit_commit(Path("kit")),
|
| 164 |
}
|
| 165 |
-
report.update(verdict(capabilities,
|
| 166 |
report["jax_version"] = None
|
| 167 |
try:
|
| 168 |
from importlib.metadata import version
|
|
|
|
| 36 |
return values
|
| 37 |
|
| 38 |
|
| 39 |
+
def verdict(capabilities: list[float], probes: dict | None = None) -> dict:
|
| 40 |
"""Pure decision table so it can be tested without a GPU."""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
probes = probes or {}
|
| 42 |
+
ampere = bool(capabilities) and all(value >= TRITON_MIN for value in capabilities)
|
| 43 |
+
|
| 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":
|
| 52 |
attention = "unavailable"
|
| 53 |
note = "dot_product_attention is unsupported on this GPU: use CPU or Modal"
|
| 54 |
+
elif status("sdpa_xla") == "pass":
|
| 55 |
attention = "default"
|
| 56 |
note = "" if bf16 else "BF16 accumulation unsupported: use float32"
|
| 57 |
else:
|
| 58 |
attention = "default" if ampere else "xla"
|
| 59 |
note = "" if bf16 else "BF16 unsupported: use float32 or CPU/Modal"
|
| 60 |
+
|
| 61 |
return {
|
| 62 |
"ampere_or_newer": ampere,
|
| 63 |
"bf16_matmul": bf16,
|
| 64 |
+
"bf16_source": "measured" if probes else "capability",
|
| 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,
|
|
|
|
| 90 |
"q = jnp.ones((2, 4, 8, 16), dtype=jnp.bfloat16)\n"
|
| 91 |
"jax.nn.dot_product_attention(q, q, q, implementation='xla').block_until_ready()\n"
|
| 92 |
),
|
| 93 |
+
# tokenizer: load and round-trip both scripts
|
| 94 |
+
"tokenizer": (
|
| 95 |
+
"import sys\n"
|
| 96 |
+
"from tokenizers import Tokenizer\n"
|
| 97 |
+
"tok = Tokenizer.from_file(sys.argv[1])\n"
|
| 98 |
+
"for text in ('the quick brown fox', '日本語のテキストです'):\n"
|
| 99 |
+
" ids = tok.encode(text).ids\n"
|
| 100 |
+
" assert ids, text\n"
|
| 101 |
+
" tok.decode(ids)\n"
|
| 102 |
+
),
|
| 103 |
+
# quantize / dequantize a tiny matrix through lalamo's INT4 + RHT path
|
| 104 |
+
"quant_roundtrip": (
|
| 105 |
+
"from lalamo.compressed.hybrid import HybridSpec\n"
|
| 106 |
+
"from lalamo.compressed.int import IntSpec\n"
|
| 107 |
+
"from lalamo.compressed.incoherence import HadamardSpec, IncoherenceProcessingMode\n"
|
| 108 |
+
"from lalamo.utils.sharding import ShardingConfig\n"
|
| 109 |
+
"from lalamo.weight_matrix import Layout\n"
|
| 110 |
+
"import jax, jax.numpy as jnp, numpy as np\n"
|
| 111 |
+
"spec = HybridSpec(\n"
|
| 112 |
+
" quantization_spec=IntSpec(bits=4, group_size=32, is_symmetric=False, layout=Layout.OUTPUT_INPUT),\n"
|
| 113 |
+
" adapter_spec=None,\n"
|
| 114 |
+
" incoherence_spec=HadamardSpec(block_size=32, processing_mode=IncoherenceProcessingMode.INPUT_OUTPUT),\n"
|
| 115 |
+
")\n"
|
| 116 |
+
"cfg = ShardingConfig.replicated()\n"
|
| 117 |
+
"w = jax.device_put(np.random.RandomState(0).randn(64, 32).astype(np.float32), cfg.resolve_sharding((None, None)))\n"
|
| 118 |
+
"compressed = spec.compress(w, key=jax.random.key(0), sharding_config=cfg)\n"
|
| 119 |
+
"restored = compressed.decompress()\n"
|
| 120 |
+
"assert bool(jnp.isfinite(restored).all())\n"
|
| 121 |
+
"assert restored.shape == w.shape\n"
|
| 122 |
+
),
|
| 123 |
+
# QAD gradient path: finite grads through quantize/dequantize
|
| 124 |
+
"qad_grad": (
|
| 125 |
+
"from lalamo.compressed.hybrid import HybridSpec\n"
|
| 126 |
+
"from lalamo.compressed.int import IntSpec\n"
|
| 127 |
+
"from lalamo.utils.sharding import ShardingConfig\n"
|
| 128 |
+
"from lalamo.weight_matrix import Layout\n"
|
| 129 |
+
"import jax, jax.numpy as jnp, numpy as np\n"
|
| 130 |
+
"spec = HybridSpec(\n"
|
| 131 |
+
" quantization_spec=IntSpec(bits=4, group_size=32, is_symmetric=False, layout=Layout.OUTPUT_INPUT),\n"
|
| 132 |
+
" adapter_spec=None, incoherence_spec=None,\n"
|
| 133 |
+
")\n"
|
| 134 |
+
"sharding = ShardingConfig.replicated()\n"
|
| 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 |
}
|
| 142 |
|
| 143 |
+
# probes that need lalamo; missing lalamo is a skip, not a failure
|
| 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:
|
| 150 |
result = subprocess.run(
|
| 151 |
+
[sys.executable, "-c", code, *(extra or [])],
|
| 152 |
+
text=True,
|
| 153 |
+
capture_output=True,
|
| 154 |
+
timeout=180,
|
| 155 |
+
check=False,
|
| 156 |
)
|
| 157 |
except (OSError, subprocess.TimeoutExpired) as error:
|
| 158 |
+
return "fail", str(error)
|
| 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]:
|
| 170 |
results, errors = {}, {}
|
| 171 |
for name, code in PROBES.items():
|
| 172 |
+
extra = [str(tokenizer_path)] if name == "tokenizer" and tokenizer_path else None
|
| 173 |
+
if name == "tokenizer" and tokenizer_path is None:
|
| 174 |
+
results[name] = "skip"
|
| 175 |
+
continue
|
| 176 |
+
status, error = run_probe(name, code, extra)
|
| 177 |
+
results[name] = status
|
| 178 |
if error:
|
| 179 |
errors[name] = error
|
| 180 |
return results, errors
|
|
|
|
| 202 |
parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
|
| 203 |
parser.add_argument("--json", type=Path, default=None)
|
| 204 |
parser.add_argument("--strict", action="store_true", help="exit 1 if BF16 matmul is unavailable")
|
| 205 |
+
parser.add_argument("--skip-bf16", action="store_true", help="do not import jax / lalamo")
|
| 206 |
+
parser.add_argument("--tokenizer", type=Path, default=None, help="tokenizer.json for the round-trip probe")
|
| 207 |
args = parser.parse_args()
|
| 208 |
|
| 209 |
try:
|
|
|
|
| 217 |
except OSError:
|
| 218 |
nvidia_stdout = ""
|
| 219 |
capabilities = parse_capabilities(nvidia_stdout)
|
| 220 |
+
tokenizer_path = args.tokenizer
|
| 221 |
+
if tokenizer_path is None:
|
| 222 |
+
for candidate in Path("/kaggle/input").rglob("tokenizer.json"):
|
| 223 |
+
tokenizer_path = candidate
|
| 224 |
+
break
|
| 225 |
if args.skip_bf16:
|
| 226 |
probes, probe_errors = {}, {}
|
| 227 |
else:
|
| 228 |
+
probes, probe_errors = measure_probes(tokenizer_path)
|
|
|
|
| 229 |
|
| 230 |
report = {
|
| 231 |
"jax_platform": os.environ.get("JAX_PLATFORM_NAME"),
|
| 232 |
"compute_capabilities": capabilities,
|
| 233 |
"gpu_names": [line.split(",")[-1].strip() for line in nvidia_stdout.splitlines() if line.strip()],
|
| 234 |
+
"probe_errors": probe_errors if not args.skip_bf16 else {},
|
|
|
|
| 235 |
"disk_free_gib": disk_free_gib(Path("/kaggle/working")) if Path("/kaggle/working").exists() else disk_free_gib(Path(".")),
|
| 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
|
scripts/run_lane.py
CHANGED
|
@@ -105,6 +105,7 @@ class Runner:
|
|
| 105 |
self.kit = kit
|
| 106 |
self.work = work
|
| 107 |
self.scripts = {
|
|
|
|
| 108 |
"calibrate": self._script(paths.get("calibrate", "scripts/yaqa_calibration.py")),
|
| 109 |
"convert": self._script(paths.get("convert", "scripts/rht_int4_convert.py")),
|
| 110 |
"merge": self._script(paths.get("merge", "scripts/merge_language_hessians.py")),
|
|
@@ -112,6 +113,7 @@ class Runner:
|
|
| 112 |
"copy": self._script(paths.get("copy", "scripts/make_lalamo_eval_copy.py")),
|
| 113 |
}
|
| 114 |
self.lane = spec.get("lane") or spec_path.stem
|
|
|
|
| 115 |
capabilities = detect_compute_capabilities()
|
| 116 |
self.triton_off = needs_triton_off(capabilities)
|
| 117 |
# T4 (cc 7.5) has no BF16 matmul: ALG_DOT_BF16_BF16_F32 is unsupported.
|
|
@@ -194,6 +196,27 @@ class Runner:
|
|
| 194 |
|
| 195 |
# ---------- steps ----------
|
| 196 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 197 |
def ensure_bf16(self) -> Path:
|
| 198 |
"""Return a lalamo-loadable BF16 directory.
|
| 199 |
|
|
@@ -580,6 +603,7 @@ class Runner:
|
|
| 580 |
|
| 581 |
def write_manifest(self, summaries: list[dict[str, Any]], problems: list[str]) -> Path:
|
| 582 |
manifest = {
|
|
|
|
| 583 |
"lane": self.lane,
|
| 584 |
"spec": str(self.spec_path),
|
| 585 |
"model": self.spec.get("model"),
|
|
@@ -669,6 +693,7 @@ def main() -> None:
|
|
| 669 |
if not args.dry_run:
|
| 670 |
runner.lane_dir.mkdir(parents=True, exist_ok=True)
|
| 671 |
|
|
|
|
| 672 |
bf16 = runner.ensure_bf16()
|
| 673 |
summaries = []
|
| 674 |
for condition in conditions:
|
|
|
|
| 105 |
self.kit = kit
|
| 106 |
self.work = work
|
| 107 |
self.scripts = {
|
| 108 |
+
"preflight": self._script(paths.get("preflight", "scripts/preflight.py")),
|
| 109 |
"calibrate": self._script(paths.get("calibrate", "scripts/yaqa_calibration.py")),
|
| 110 |
"convert": self._script(paths.get("convert", "scripts/rht_int4_convert.py")),
|
| 111 |
"merge": self._script(paths.get("merge", "scripts/merge_language_hessians.py")),
|
|
|
|
| 113 |
"copy": self._script(paths.get("copy", "scripts/make_lalamo_eval_copy.py")),
|
| 114 |
}
|
| 115 |
self.lane = spec.get("lane") or spec_path.stem
|
| 116 |
+
self.preflight: dict | None = None
|
| 117 |
capabilities = detect_compute_capabilities()
|
| 118 |
self.triton_off = needs_triton_off(capabilities)
|
| 119 |
# T4 (cc 7.5) has no BF16 matmul: ALG_DOT_BF16_BF16_F32 is unsupported.
|
|
|
|
| 196 |
|
| 197 |
# ---------- steps ----------
|
| 198 |
|
| 199 |
+
def run_preflight(self) -> dict | None:
|
| 200 |
+
"""Refuse to burn ten minutes on a GPU that cannot run the attention path."""
|
| 201 |
+
script = self.scripts.get("preflight")
|
| 202 |
+
if script is None or not Path(script).exists() or self.dry_run:
|
| 203 |
+
return None
|
| 204 |
+
report_path = self.lane_dir / "preflight.json"
|
| 205 |
+
command = [sys.executable, str(script), "--json", str(report_path)]
|
| 206 |
+
env = self.environment()
|
| 207 |
+
result = subprocess.run(command, text=True, capture_output=True, env=env, check=False)
|
| 208 |
+
print(result.stdout.strip()[:800], flush=True)
|
| 209 |
+
if result.returncode != 0 or not report_path.exists():
|
| 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 "
|
| 216 |
+
f"({report.get('gpu_names')}). Use --jax-platform cpu or Modal."
|
| 217 |
+
)
|
| 218 |
+
return report
|
| 219 |
+
|
| 220 |
def ensure_bf16(self) -> Path:
|
| 221 |
"""Return a lalamo-loadable BF16 directory.
|
| 222 |
|
|
|
|
| 603 |
|
| 604 |
def write_manifest(self, summaries: list[dict[str, Any]], problems: list[str]) -> Path:
|
| 605 |
manifest = {
|
| 606 |
+
"preflight": self.preflight,
|
| 607 |
"lane": self.lane,
|
| 608 |
"spec": str(self.spec_path),
|
| 609 |
"model": self.spec.get("model"),
|
|
|
|
| 693 |
if not args.dry_run:
|
| 694 |
runner.lane_dir.mkdir(parents=True, exist_ok=True)
|
| 695 |
|
| 696 |
+
runner.preflight = runner.run_preflight()
|
| 697 |
bf16 = runner.ensure_bf16()
|
| 698 |
summaries = []
|
| 699 |
for condition in conditions:
|