Run frontier MoE models on hardware you already own — pure C, zero deps, experts streamed from disk. Tiny engine, immense model. 🐦
C
web: open the dashboard when the engine is ready, however long that takes (#854)
JustVugg4c35c2134396
diff --git a/c/coli b/c/coliindex 6f6942a9..d735ce29 100755--- a/c/coli+++ b/c/coli@@ -1223,13 +1223,30 @@ def cmd_web(a):if not getattr(a, "no_browser", False):import threading, urllib.request, webbrowserdef opener():- for _ in range(600): # the 744B engine takes minutes to load- time.sleep(2)+ # No iteration cap. It used to be `for _ in range(600)` with a 2 s sleep --+ # a 20-minute budget, sized when "the engine takes minutes to load" meant+ # GLM. #854 reported Kimi K3 never opening the browser on a 256 GB Windows+ # box, and the log explains itself: `[K3] init done in 2540.5s`. The thread+ # gave up 22 minutes before the server first answered /health, so the+ # message promising it opens automatically was simply false.+ #+ # A ceiling here can only ever be wrong in one direction: too low fails+ # silently on a slow load, too high costs a sleeping daemon thread. The+ # thread is a daemon, so it cannot outlive the server it is waiting for --+ # there is nothing for the cap to protect against.+ waited = 0+ while True:+ time.sleep(2); waited += 2try:- urllib.request.urlopen(f"http://{a.host}:{a.port}/health", timeout=2)- webbrowser.open(url); return+ urllib.request.urlopen(f"http://{a.host}:{a.port}/health", timeout=5)except OSError:+ # Say something once, rather than looking hung. A 93-layer K3 load+ # is 40+ minutes and the user has no way to tell waiting from stuck.+ if waited == 300:+ print(f"still loading; the dashboard will open at {url} when the "+ f"engine is ready (Ctrl-C to stop, or --no-browser to skip)")continue+ webbrowser.open(url); returnthreading.Thread(target=opener, daemon=True).start()print(f"dashboard: {url} (opens automatically when the engine is ready)")cmd_serve(a)diff --git a/c/openai_server.py b/c/openai_server.pyindex f58f2cfb..27d0fa6e 100644--- a/c/openai_server.py+++ b/c/openai_server.py@@ -1910,7 +1910,14 @@ class APIHandler(BaseHTTPRequestHandler):% self.address_string())self.close_connection = Truereturn- except (BrokenPipeError, ConnectionResetError):+ except ConnectionError:+ # ConnectionError, not (BrokenPipeError, ConnectionResetError): those two+ # are SIBLINGS of ConnectionAbortedError under it, so the pair caught the+ # POSIX spellings and let the Windows one through. #854's log is pages of+ # `ConnectionAbortedError: [WinError 10053] An established connection was+ # aborted by the software in your host machine` escaping to socketserver,+ # from a `coli web` start that was otherwise healthy.+ ## The client hung up mid-response. That is not an error here, it is# how HTTP clients behave: `coli chat` polls /health while the model# loads and drops each connection as soon as it has its answer, and@@ -2187,8 +2194,8 @@ class APIHandler(BaseHTTPRequestHandler):self._fail(error, request_id)except ClientCancelled:pass- except (BrokenPipeError, ConnectionResetError):- pass+ except ConnectionError:+ pass # same widening as handle_one_request, same reasonexcept Exception as error:self.log_error("request failed: %s", error)try:diff --git a/c/tests/test_openai_server.py b/c/tests/test_openai_server.pyindex ed38568c..8e1605da 100644--- a/c/tests/test_openai_server.py+++ b/c/tests/test_openai_server.py@@ -938,6 +938,47 @@ class ClientHangupTest(unittest.TestCase):timeout=2) as response:self.assertEqual(json.load(response)["status"], "ok")+ def _abort(self, *args):+ """Windows' spelling of the same disconnect, raised where it really lands.++ In #854's log the traceback runs do_GET -> send_json -> end_headers ->+ flush_headers -> wfile.write -> sendall, so raising from end_headers+ reproduces the exact shape on any platform.+ """+ raise ConnectionAbortedError(+ 10053, "An established connection was aborted by the software in your "+ "host machine")++ def test_windows_aborted_connection_is_not_an_error(self):+ """ConnectionAbortedError is a SIBLING of BrokenPipeError and+ ConnectionResetError under ConnectionError, not a subclass of either --+ so catching the pair caught the POSIX spellings and let the Windows one+ escape. #854 is pages of WinError 10053 tracebacks from a healthy start.+ """+ self.assertFalse(+ issubclass(ConnectionAbortedError, (BrokenPipeError, ConnectionResetError)),+ "the old except clause would have covered this; the test proves nothing")+ with patch.object(APIHandler, "end_headers", self._abort):+ try:+ urlopen(f"http://127.0.0.1:{self.server.server_port}/health", timeout=2)+ except Exception:+ pass # the client sees a broken response; that is fine+ time.sleep(0.3)+ self.assertEqual(self.errors, [],+ "WinError 10053 surfaced as a server error (#854)")++ def test_the_server_survives_an_aborted_connection(self):+ """Same as the hangup case: the damage is a lost handler, not the log."""+ with patch.object(APIHandler, "end_headers", self._abort):+ try:+ urlopen(f"http://127.0.0.1:{self.server.server_port}/health", timeout=2)+ except Exception:+ pass+ time.sleep(0.3)+ with urlopen(f"http://127.0.0.1:{self.server.server_port}/health",+ timeout=2) as response:+ self.assertEqual(json.load(response)["status"], "ok")+class StaticServingTest(unittest.TestCase):def setUp(self):