Run frontier MoE models on hardware you already own — pure C, zero deps, experts streamed from disk. Tiny engine, immense model. 🐦
C
coli convert: refuse an output directory that already holds a checkpoint
JustVugg41b45448c51b
diff --git a/c/coli b/c/coliindex 06804f1e..87764b75 100755--- a/c/coli+++ b/c/coli@@ -2075,6 +2075,41 @@ def checkpoint_family(repo):return None+CONVERT_DEFAULT_REPO = "zai-org/GLM-5.2-FP8"++def convert_output_refusal(out_dir):+ """Why `coli convert --model out_dir` must not run, or None. A checkpoint+ already living there is the tell: --model names the OUTPUT directory,+ and a family that runs its official checkpoint as is needs no conversion+ at all, which is the usual reason someone points convert at one."""+ if not os.path.isdir(out_dir):+ return None+ try:+ shards = [x for x in os.listdir(out_dir) if x.endswith(".safetensors")]+ except OSError:+ return None+ has_config = os.path.isfile(os.path.join(out_dir, "config.json"))+ if not shards and not has_config:+ return None+ what = f"{len(shards)} shard(s)" if shards else "a config.json"+ family = None+ if has_config:+ try:+ family = resolve_model(out_dir).descriptor+ except (FamilyConfigError, UnknownFamilyError):+ family = None+ head = (f"{C.yel}{out_dir} already holds a checkpoint ({what}"+ f"{', ' + family.display_name if family else ''}).{C.r}\n"+ f" --model is the OUTPUT directory of coli convert; the source is --repo <hf repo>.\n"+ f" Nothing was written.")+ if family and not family.converter:+ return (head + f"\n {family.display_name} runs its official checkpoint as it is: no conversion needed.\n"+ f" Point the engine at it: coli chat --model {out_dir}")+ if family and family.converter:+ return (head + f"\n To convert shards already on disk, run the family's converter on them:\n"+ f" python3 tools/{family.converter} --indir {out_dir} --outdir <new dir>")+ return head + "\n To convert into a fresh directory: coli convert --repo <hf repo> --model <new dir>"+def cmd_convert(a):banner("convert")# here --model is the DESTINATION the converted weights are written to, not an@@ -2082,6 +2117,16 @@ def cmd_convert(a):if not a.model:sys.exit(f"{C.yel}no output directory given.{C.r}\n"f" --model <dir> is where the converted model is written")+ # A support case ran `coli convert --model <dir of a downloaded Qwen3.8>`,+ # read --model as "the model to convert", and watched coli start fetching+ # the default repo (GLM-5.2) INTO that directory. --model is the output:+ # refuse to write into a directory that already holds a checkpoint, and+ # say what the user most likely wanted instead.+ refusal = convert_output_refusal(a.model)+ if refusal:+ sys.exit(refusal)+ if a.repo is None:+ a.repo = CONVERT_DEFAULT_REPO# python con torch/safetensors: l'ambiente del progetto se c'e', altrimenti quello correntepy = project_python()@@ -2292,7 +2337,10 @@ def main():_cache_root = os.environ.get("XDG_CACHE_HOME", os.path.expanduser("~/.cache"))_bench_cache = os.path.join(_cache_root, "colibri", "bench")pb.add_argument("--data",default=_bench_cache)- pc=sub.add_parser("convert", parents=[common]); pc.add_argument("--repo",default="zai-org/GLM-5.2-FP8")+ pc=sub.add_parser("convert", parents=[common])+ pc.add_argument("--repo",default=None,+ help="HF repo to download and convert (default zai-org/GLM-5.2-FP8). "+ "--model is the OUTPUT directory, not a checkpoint to convert.")# default=None e non il valore: cosi' e' argparse a dire se l'opzione e'# stata SCRITTA (--ebits 3, --ebits=3, o abbreviata), e cmd_convert puo'# rifiutarla su un convertitore che non la prende invece di ignorarla.diff --git a/c/tests/test_convert_routing.py b/c/tests/test_convert_routing.pyindex be99666b..825b88b5 100644--- a/c/tests/test_convert_routing.py+++ b/c/tests/test_convert_routing.py@@ -157,6 +157,51 @@ class ConvertRoutingTest(unittest.TestCase):self.assertEqual(command[command.index(flag) + 1], value)self.assertNotIn("--xbits", command, "xbits defaults to 0 and is omitted")+ def test_an_output_directory_holding_a_checkpoint_is_refused(self):+ """`coli convert --model <downloaded checkpoint>` used to start fetching+ the default repo into that directory. Refuse, and say what the user+ most likely wanted: nothing for a family that runs its official+ checkpoint, the family's converter with --indir for one that converts."""+ cli = self.cli+ with tempfile.TemporaryDirectory() as out:+ (Path(out) / "model-00001-of-00002.safetensors").write_bytes(b"\0" * 8)+ (Path(out) / "config.json").write_text(json.dumps({"model_type": "qwen4_exp", "text_config": {}}))+ text = cli.convert_output_refusal(out)+ self.assertIsNotNone(text)+ self.assertIn("already holds a checkpoint", text)+ self.assertIn("no conversion needed", text)+ self.assertIn("coli chat --model", text)+ with tempfile.TemporaryDirectory() as out:+ (Path(out) / "config.json").write_text(json.dumps({"model_type": "glm5_next", "text_config": {}}))+ text = cli.convert_output_refusal(out)+ self.assertIn("convert_glm53.py --indir", text)+ with tempfile.TemporaryDirectory() as out:+ (Path(out) / "model-00001-of-00001.safetensors").write_bytes(b"\0" * 8)+ text = cli.convert_output_refusal(out)+ self.assertIn("1 shard(s)", text)+ self.assertIn("--repo <hf repo> --model <new dir>", text)+ with tempfile.TemporaryDirectory() as out:+ self.assertIsNone(cli.convert_output_refusal(out))+ self.assertIsNone(cli.convert_output_refusal("/nonexistent/dir/for/convert"))++ def test_cmd_convert_stops_before_any_subprocess_on_a_checkpoint_dir(self):+ directory = tempfile.TemporaryDirectory()+ self.addCleanup(directory.cleanup)+ (Path(directory.name) / "model-00001-of-00001.safetensors").write_bytes(b"\0" * 8)+ calls = []+ with mock.patch.object(self.cli, "subprocess") as subprocess_module, \+ mock.patch.object(self.cli, "project_python", return_value="python3"), \+ mock.patch.object(self.cli, "checkpoint_family", return_value=None):+ subprocess_module.call = lambda command: calls.append(command) or 0+ with self.assertRaises(SystemExit) as stop:+ self.cli.cmd_convert(Args(directory.name, repo=None))+ self.assertIn("already holds a checkpoint", str(stop.exception))+ self.assertEqual(calls, [])++ def test_the_default_repo_is_applied_when_none_is_written(self):+ calls = self.run_convert("glm", repo=None)+ self.assertEqual(calls[0][calls[0].index("--repo") + 1], "zai-org/GLM-5.2-FP8")+def test_an_unresolvable_family_keeps_the_old_command(self):"""A metadata fetch that fails is not a reason to refuse a conversionthat would have worked. The converter's own guard downloads the same