Skip to content

Run frontier MoE models on hardware you already own — pure C, zero deps, experts streamed from disk. Tiny engine, immense model. 🐦

C

doctor.py/resource_plan.py: surface the cached SSD probe (#379, S4)

monotophic42d72bc30ee9
diff --git a/c/doctor.py b/c/doctor.py
index ed00b5b4..092d71e2 100644
--- a/c/doctor.py
+++ b/c/doctor.py
@@ -511,11 +511,21 @@ def run_doctor(model, ram_gb=0, context=4096, gpu_indices=None, vram_gb=0, *,
checks.append(_check("placement.plan", "warn", "; ".join(plan["warnings"])))
else:
checks.append(_check("placement.plan", "pass", "tier placement has no warnings"))
+ # #379: read-and-display only -- the cached value colibri.c already measured
+ # (F_NOCACHE probe) on a Metal+darwin startup, never re-probed here.
+ ssd_gbs = plan.get("ssd_probe_gbs")
+ if ssd_gbs is not None:
+ checks.append(_check("storage.ssd_probe", "pass",
+ f"F_NOCACHE probe: {ssd_gbs:.1f} GB/s (cached, .coli_ssd)", gbs=ssd_gbs))
+ else:
+ checks.append(_check("storage.ssd_probe", "skip",
+ "no cached probe yet; measured on the first Metal+darwin engine start"))
except (OSError, ValueError, KeyError, TypeError) as error:
checks.append(_check("model.shards", "fail", str(error)))
checks.append(_check("storage.disk", "skip", "storage check requires a valid model"))
checks.append(_check("memory.ram", "skip", "RAM projection requires a valid model"))
checks.append(_check("placement.plan", "skip", "placement requires a valid model"))
+ checks.append(_check("storage.ssd_probe", "skip", "probe surfacing requires a valid model"))
if deep:
try:
diff --git a/c/resource_plan.py b/c/resource_plan.py
index ad2c06f5..f35309bc 100644
--- a/c/resource_plan.py
+++ b/c/resource_plan.py
@@ -143,6 +143,20 @@ def memory_available():
return 0
+def read_ssd_probe(model_dir):
+ """Read the cached F_NOCACHE storage probe the C engine writes to
+ <model>/.coli_ssd on its first Metal+darwin startup (colibri.c coli_ssd_probe_cached,
+ issue #379). Read-only: never re-measures, never guesses -- mirrors S4's
+ "read-and-display only" contract for `coli doctor`/`coli plan`. Returns the
+ measured GB/s as a float, or None if the file is absent or unparsable."""
+ try:
+ text = (Path(model_dir) / ".coli_ssd").read_text(encoding="utf-8").strip()
+ value = float(text.split()[0])
+ return value if value >= 0 else None
+ except (OSError, ValueError, IndexError):
+ return None
+
+
def discover_gpus():
# NVIDIA first; if there are none (or no nvidia-smi), fall back to ROCm/HIP so
# a working AMD engine isn't planned CPU-only and --gpu N stops failing (#662).
@@ -538,6 +552,10 @@ def build_plan(model, ram_gb=0, context=4096, gpu_indices=None, vram_gb=0,
{"target": "Disk", "reason": "immutable recovery source for cold experts"},
],
"warnings": warnings,
+ # #379: read-only surfacing of the cached Metal-cache storage probe, if
+ # the engine has already measured this model dir. None before the first
+ # Metal+darwin startup -- never re-measured or guessed here.
+ "ssd_probe_gbs": read_ssd_probe(info["path"]),
}
@@ -608,6 +626,8 @@ def format_plan(plan):
f"~{vram['expert_capacity']} experts · {names}")
else:
lines.append("VRAM no NVIDIA device detected · CPU path")
+ if plan.get("ssd_probe_gbs") is not None:
+ lines.append(f"ssd {plan['ssd_probe_gbs']:.1f} GB/s F_NOCACHE (cached probe, #379)")
lines.append(f"limit {plan['expected_bottleneck']}")
hit = plan.get("projected_hit_rate", 0)
lines.append(f"hit {hit:.0%} projected expert residency")
diff --git a/c/tests/test_doctor.py b/c/tests/test_doctor.py
index 958e949f..6c747a46 100644
--- a/c/tests/test_doctor.py
+++ b/c/tests/test_doctor.py
@@ -149,6 +149,18 @@ class DoctorTest(unittest.TestCase):
)
self.assertEqual(report["status"], "error")
+ # #379: doctor surfaces the cached F_NOCACHE probe read-only (S4) -- it
+ # never re-measures storage itself, only reflects what colibri.c already wrote.
+ def test_ssd_probe_check_skips_when_not_yet_cached(self):
+ checks = self.checks_by_id(self.report())
+ self.assertEqual(checks["storage.ssd_probe"]["status"], "skip")
+
+ def test_ssd_probe_check_passes_and_reports_cached_value(self):
+ (self.model / ".coli_ssd").write_text("14.3\n")
+ checks = self.checks_by_id(self.report())
+ self.assertEqual(checks["storage.ssd_probe"]["status"], "pass")
+ self.assertEqual(checks["storage.ssd_probe"]["details"]["gbs"], 14.3)
+
def test_text_format_contains_checks_plan_and_result(self):
output = format_doctor(self.report())
diff --git a/c/tests/test_resource_plan.py b/c/tests/test_resource_plan.py
index f028c314..ee56c7da 100644
--- a/c/tests/test_resource_plan.py
+++ b/c/tests/test_resource_plan.py
@@ -16,6 +16,7 @@ from resource_plan import (
format_plan,
memory_available,
physical_cpu_count,
+ read_ssd_probe,
)
@@ -72,6 +73,43 @@ class ResourcePlanTest(unittest.TestCase):
def test_cpu_socket_count_is_positive(self):
self.assertGreaterEqual(cpu_socket_count(), 1)
+ # #379: read_ssd_probe reads the cached F_NOCACHE measurement colibri.c writes to
+ # <model>/.coli_ssd on its first Metal+darwin startup. This is the read-only
+ # Python-side half of the probe contract (S4) -- never re-measures, never
+ # guesses, so every case here is pure file parsing.
+ def test_ssd_probe_missing_file_returns_none(self):
+ self.assertIsNone(read_ssd_probe(self.model))
+
+ def test_ssd_probe_reads_cached_value(self):
+ (self.model / ".coli_ssd").write_text("14.322\n")
+ self.assertEqual(read_ssd_probe(self.model), 14.322)
+
+ def test_ssd_probe_unparsable_file_returns_none(self):
+ (self.model / ".coli_ssd").write_text("not-a-number\n")
+ self.assertIsNone(read_ssd_probe(self.model))
+
+ def test_ssd_probe_empty_file_returns_none(self):
+ (self.model / ".coli_ssd").write_text("")
+ self.assertIsNone(read_ssd_probe(self.model))
+
+ def test_ssd_probe_negative_value_returns_none(self):
+ # colibri.c never caches a negative number (a failed probe just doesn't
+ # write the file), but a hand-edited/corrupt file should still be
+ # rejected rather than surfaced as a bogus "fast" reading.
+ (self.model / ".coli_ssd").write_text("-1\n")
+ self.assertIsNone(read_ssd_probe(self.model))
+
+ def test_ssd_probe_surfaces_in_plan_and_format(self):
+ (self.model / ".coli_ssd").write_text("14.3\n")
+ plan = build_plan(self.model, available_memory=16 * GB, available_disk=1)
+ self.assertEqual(plan["ssd_probe_gbs"], 14.3)
+ self.assertIn("14.3 GB/s", format_plan(plan))
+
+ def test_ssd_probe_absent_from_plan_and_format_when_not_cached(self):
+ plan = build_plan(self.model, available_memory=16 * GB, available_disk=1)
+ self.assertIsNone(plan["ssd_probe_gbs"])
+ self.assertNotIn("F_NOCACHE", format_plan(plan))
+
def test_builds_bounded_three_tier_plan(self):
gpus = [{"index": 0, "name": "test-gpu", "total_bytes": 12 * GB,
"free_bytes": 10 * GB}]