Run frontier MoE models on hardware you already own — pure C, zero deps, experts streamed from disk. Tiny engine, immense model. 🐦
C
Makefile: add install/uninstall targets (PREFIX/bin + libexec) (#167, fixes #164)
Sai Saharsh Chittimilla6e9affba2a4a
diff --git a/Makefile b/Makefileindex 4da2ce13..9a20b7ad 100644--- a/Makefile+++ b/Makefile@@ -1,4 +1,4 @@-.PHONY: all glm portable test check cuda-test clean+.PHONY: all glm portable test check cuda-test clean install uninstall-all glm portable test check cuda-test clean:- $(MAKE) -C c $@+all glm portable test check cuda-test clean install uninstall:+ $(MAKE) -C c $@\ No newline at end of filediff --git a/c/Makefile b/c/Makefileindex 24e848e0..dcc92d19 100644--- a/c/Makefile+++ b/c/Makefile@@ -71,6 +71,12 @@ EXE =endifendif+# --- install ---+PREFIX ?= /usr/local+BINDIR ?= $(PREFIX)/bin+LIBEXECDIR ?= $(PREFIX)/libexec/colibri+INSTALL ?= install+# CUDA=1 adds an opt-in backend for resident tensors. The default build remains# pure C and keeps the original zero-dependency runtime.#@@ -222,7 +228,23 @@ check:$(MAKE) portable$(MAKE) test+install: glm$(EXE) olmoe$(EXE)+ $(INSTALL) -d $(DESTDIR)$(BINDIR)+ $(INSTALL) -d $(DESTDIR)$(LIBEXECDIR)+ $(INSTALL) -d $(DESTDIR)$(LIBEXECDIR)/tools+ $(INSTALL) -m 755 coli $(DESTDIR)$(BINDIR)/coli+ $(INSTALL) -m 755 glm$(EXE) $(DESTDIR)$(LIBEXECDIR)/glm$(EXE)+ $(INSTALL) -m 755 olmoe$(EXE) $(DESTDIR)$(LIBEXECDIR)/olmoe$(EXE)+ $(INSTALL) -m 644 resource_plan.py doctor.py openai_server.py $(DESTDIR)$(LIBEXECDIR)/+ $(INSTALL) -m 644 tools/*.py $(DESTDIR)$(LIBEXECDIR)/tools/++uninstall:+ rm -f $(DESTDIR)$(BINDIR)/coli+ rm -rf $(DESTDIR)$(LIBEXECDIR)+clean:$(PYTHON) tools/clean.py-.PHONY: all glm cuda-test cuda-bench cuda-dll portable test-c test-python test check clean+bench: iobench$(EXE)+ @if [ -n "$(ARGS)" ]; then ./iobench$(EXE) $(ARGS); else echo "built iobench$(EXE) — run: ./iobench$(EXE) <file> <MB> <iters> <threads> <direct 0|1>"; fi+.PHONY: all glm cuda-test cuda-bench cuda-dll portable test-c test-python test check clean install uninstall bench\ No newline at end of filediff --git a/c/coli b/c/coliindex 7ff7812c..c12852f6 100755--- a/c/coli+++ b/c/coli@@ -29,8 +29,31 @@ if sys.platform == "win32":except (AttributeError, OSError): passHERE = os.path.dirname(os.path.abspath(__file__))-TOOLS = os.path.join(HERE, "tools")-GLM = os.path.join(HERE, "glm" + (".exe" if sys.platform == "win32" else ""))++# Run-in-place (source checkout, "cd c && ./coli ..."): the engine, the+# support modules (resource_plan.py, doctor.py, openai_server.py) and+# tools/ all live next to this script — unchanged from before.+#+# Installed layout ("make install"): this script is $(PREFIX)/bin/coli,+# while the engine binaries and support files live in+# $(PREFIX)/libexec/colibri, since they aren't meant to be run directly+# by users. COLI_ENGINE overrides the engine path explicitly if neither+# guess is right (e.g. a custom packaging layout).+_EXE = ".exe" if sys.platform == "win32" else ""+_LIBEXEC = os.path.join(os.path.dirname(HERE), "libexec", "colibri")+_here_glm = os.path.join(HERE, "glm" + _EXE)++if os.environ.get("COLI_ENGINE"):+ GLM = os.environ["COLI_ENGINE"]+ TOOLS = os.path.join(os.path.dirname(GLM), "tools")+elif os.path.exists(_here_glm):+ GLM = _here_glm+ TOOLS = os.path.join(HERE, "tools")+else:+ GLM = os.path.join(_LIBEXEC, "glm" + _EXE)+ TOOLS = os.path.join(_LIBEXEC, "tools")+ sys.path.insert(0, _LIBEXEC) # so `import resource_plan`, `doctor`, `openai_server` still resolve+DEF_MODEL = os.environ.get("COLI_MODEL", "/home/vincenzo/glm52_i4")END = b"\x01\x01END\x01\x01\n"READY = b"\x01\x01READY\x01\x01\n"@@ -302,6 +325,9 @@ def stream_turn(p, sentinel, on_bytes):# ---------- comandi ----------def cmd_build(a):banner("build")+ if not os.path.exists(os.path.join(HERE, "Makefile")):+ sys.exit(f"{C.yel}coli build{C.r} only works from a source checkout (this is an installed copy).\n"+ f" Clone https://github.com/JustVugg/colibri and run ./setup.sh, or make -C c glm.")sys.exit(subprocess.call(["make","-C",HERE,"glm"]))def cmd_info(a):