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

fix(coli): set SNAP for non-glm engines in env_for_engine (#1600)

Frank_zhube198895103a
diff --git a/c/coli b/c/coli
index 6c416ce5..83a91061 100755
--- a/c/coli
+++ b/c/coli
@@ -477,9 +477,10 @@ def env_for_engine(a, arch, plan=None):
# sets it for GLM and openai_server.py sets it for the gateway, so `coli
# chat` and `coli serve` worked while `coli run` handed the sister engines
# an environment without it: OLMoE exited with "started without a model"
- # (#1501). Set it here, once, for all of them.
+ # (#1501, #1600). Set it here, once, for all of them. --model is the
+ # directory, same as env_for(): a leftover SNAP must not load another model.
if getattr(a, "model", None):
- env.setdefault("SNAP", os.path.abspath(a.model))
+ env["SNAP"] = os.path.abspath(a.model)
if arch == "olmoe":
env["CHAT"] = "1"
env["MAX_NEW"] = str(ngen_for(a, family=arch))
diff --git a/c/tests/test_v4_cli.py b/c/tests/test_v4_cli.py
index 402fe50f..46896681 100644
--- a/c/tests/test_v4_cli.py
+++ b/c/tests/test_v4_cli.py
@@ -106,6 +106,7 @@ class V4CliTest(unittest.TestCase):
self.assertNotIn("text", captured)
self.assertEqual(captured["env"]["CHAT"], "1")
self.assertEqual(captured["env"]["MAX_NEW"], "32")
+ self.assertEqual(captured["env"]["SNAP"], os.path.abspath(str(root)))
finally:
directory.cleanup()
@@ -117,18 +118,22 @@ class V4CliTest(unittest.TestCase):
self.assertEqual(env["CTX"], "4096")
def test_sister_engines_get_snap_from_the_model_flag(self):
- """#1501: `coli run` handed olmoe (and every non-GLM engine) an
+ """#1501 / #1600: `coli run` handed olmoe (and every non-GLM engine) an
environment without SNAP, so the engine exited with "started without
- a model" while chat and serve, which set it elsewhere, worked."""
+ a model" while chat and serve, which set it elsewhere, worked.
+ SNAP is the model directory, same as env_for() for glm: --model wins
+ over a leftover SNAP in the parent environment."""
from family_registry import family_ids
for arch in [f for f in family_ids() if f != "glm"]:
args = argparse.Namespace(ngen=8, temp=None, ram=0, ctx=None, model="models/demo")
env = self.cli.env_for_engine(args, arch)
- self.assertEqual(env.get("SNAP"), os.path.abspath("models/demo"), arch)
- # an explicit SNAP in the caller's environment still wins
+ self.assertEqual(env.get("SNAP"), os.path.abspath(args.model), arch)
with mock.patch.dict(os.environ, {"SNAP": "/elsewhere"}):
args = argparse.Namespace(ngen=8, temp=None, ram=0, ctx=None, model="models/demo")
- self.assertEqual(self.cli.env_for_engine(args, "olmoe")["SNAP"], "/elsewhere")
+ self.assertEqual(
+ self.cli.env_for_engine(args, "olmoe")["SNAP"],
+ os.path.abspath(args.model),
+ )
def test_kimi_engine_environment_forwards_ram(self):
"""#855: `--ram` reached the environment for deepseek_v4 only, so on Kimi