Run frontier MoE models on hardware you already own — pure C, zero deps, experts streamed from disk. Tiny engine, immense model. 🐦
C
feat(api): accept and ignore a per-request seed
monotophic7d79ad1b1c36
diff --git a/c/openai_server.py b/c/openai_server.pyindex f094e3eb..1daf8eab 100644--- a/c/openai_server.py+++ b/c/openai_server.py@@ -2836,8 +2836,8 @@ def generation_options(body, limit):raise APIError(400, "Log probabilities are not supported yet.", "logprobs", "unsupported_parameter")if body.get("frequency_penalty", 0) or body.get("presence_penalty", 0):raise APIError(400, "Token penalties are not supported yet.", None, "unsupported_parameter")- if body.get("seed") is not None:- raise APIError(400, "Per-request seeds are not supported yet.", "seed", "unsupported_parameter")+ # `seed` is accepted for request-shape compatibility and silently discarded:+ # this server puts no per-request seed on the wire, at any temperature.# response_format -> optional per-request grammar for the engine's grammar-forced# draft source (#70/#148). NEVER a sampling constraint: drafts are verified, so a# schema the engine cannot compile degrades to "no speedup", not to an error anddiff --git a/c/tests/golden_fixture_capture.py b/c/tests/golden_fixture_capture.pyindex 9ae6424e..3633c738 100644--- a/c/tests/golden_fixture_capture.py+++ b/c/tests/golden_fixture_capture.py@@ -4,9 +4,11 @@Captures full HTTP responses for a battery of NON-logprobs requests against aRUNNING colibri server, normalizes the volatile fields (ids, timestamps), andbyte-diffs two capture directories. The engine-channel change (U7a) is opt-in-and no server request path opts in, so a pre-U7a capture and a post-U7a capture-of the same battery on the same box/backend/model must be byte-identical ---this script is the mechanism proving that, not reviewer inspection.+and no server request path opts in: for the battery's generation-bearing+cases, which all run at temperature 0, a capture taken before the change+under test and one taken after it, on the same box/backend/model, must be+byte-identical after that normalization -- this script is the mechanism+proving that, not reviewer inspection.Usage:# 1. start the server on the CURRENT (pre-change) build, then:@@ -22,8 +24,15 @@ Usage:python3 tests/golden_fixture_capture.py diff fixtures_pre fixtures_postBattery: chat, chat+tools, chat streaming, completions without logprobs, and-the error cases whose behavior must not move (seed 400, array-prompt 400,-logprobs 400, out-of-range temperature 400) plus /v1/models.+the error cases whose behavior must not move (array-prompt 400, logprobs 400,+out-of-range temperature 400), plus one case that is a no-op from this change+on (seed accepted-and-ignored), plus /v1/models.++A pre/post diff spanning this change prints `err_seed.json: MISSING on one+side` and `seed_accepted.json: MISSING on one side`, then exits 1: the+rename means the two captures carry different keys for this one case, so+`diff()` cannot pair them under either name. That pair is expected across+this change and is the only expected difference.Normalization: every "id"/"created" field (recursively, and per SSE event) isreplaced with a constant; nothing else is touched. Generation-bearing requests@@ -76,8 +85,8 @@ def battery(model):("completions_stop", "POST", "/v1/completions",{"model": model, "prompt": "Count: one, two,","max_tokens": 16, "temperature": 0, "stop": ["five"]}),- ("err_seed", "POST", "/v1/completions",- {"model": model, "prompt": "hello", "max_tokens": 1, "seed": 1234}),+ ("seed_accepted", "POST", "/v1/completions",+ {"model": model, "prompt": "hello", "max_tokens": 1, "temperature": 0, "seed": 1234}),("err_array_prompt", "POST", "/v1/completions",{"model": model, "prompt": [1, 2, 3], "max_tokens": 1}),("err_logprobs", "POST", "/v1/completions",diff --git a/c/tests/test_openai_server.py b/c/tests/test_openai_server.pyindex 3bea0a79..82629310 100644--- a/c/tests/test_openai_server.py+++ b/c/tests/test_openai_server.py@@ -1405,6 +1405,101 @@ class DispatcherTest(unittest.TestCase):self.assertEqual(process.writes[-1].split(), [b"STOP", request_id])+def _capture_frames(body, path="/v1/completions"):+ """Sends `body` to `path` against a FakeProcess-backed Engine/APIServer+ and returns (status, parsed_response, frames_written_to_the_engine).+ Shared by the test classes below so the harness lives in one place.+ """+ frames = []++ def respond(process, frame):+ frames.append(frame)+ rid = frame.split()[1]+ process.stdout.feed(b"DATA " + rid + b" 5\nHello\n")+ process.stdout.feed(b"DONE " + rid + b" STAT 1 2.5 0 1.0 4 0\n")++ process = FakeProcess(respond)+ with patch("openai_server.subprocess.Popen", return_value=process):+ engine = Engine("glm", "model")+ server = APIServer(("127.0.0.1", 0), engine, "test-model", "secret", 16)+ thread = threading.Thread(target=server.serve_forever, args=(0.01,), daemon=True)+ thread.start()+ try:+ data = json.dumps(body).encode()+ headers = {"Authorization": "Bearer secret", "Content-Type": "application/json"}+ request = Request(f"http://127.0.0.1:{server.server_port}{path}",+ data=data, headers=headers)+ with urlopen(request, timeout=2) as response:+ status = response.status+ parsed = json.load(response)+ finally:+ server.scheduler.close()+ server.shutdown()+ server.server_close()+ thread.join(timeout=2)+ engine.close()+ return status, parsed, frames+++class BaseWireContractTest(unittest.TestCase):+ """Pins the SUBMIT frame written for a request that uses none of the+ optional fields; any change here is a wire-format change and must be+ deliberate.+ """++ def test_no_new_fields_request_emits_the_base_submit_header(self):+ _, _, frames = _capture_frames(+ {"model": "test-model", "prompt": "Complete me", "temperature": 0, "max_tokens": 4})+ self.assertEqual(frames, [b"SUBMIT 1 0 11 4 0 0.9\nComplete me\n"])+++class SeedOptionTest(unittest.TestCase):+ """`generation_options()` accepts a `seed` field without raising."""++ def test_seed_is_accepted_by_generation_options(self):+ generation_options({"seed": 1234, "prompt": "hi"}, 16) # must not raise+++class SeedWireFrameTest(unittest.TestCase):+ """`seed` is accepted and ignored. A stub-response equality check alone+ is vacuous here (the scripted `respond` closure inside `_capture_frames`+ always returns the same canned text regardless of any request field) --+ the real proof is that the byte-exact SUBMIT frames the dispatcher+ writes to the engine process (see DispatcherTest above) never carry the+ seed value at all, seeded or not.+ """++ def test_seed_accepted_and_absent_from_submit_frame(self):+ base = {"model": "test-model", "prompt": "Complete me", "temperature": 0, "max_tokens": 4}+ status_plain, body_plain, frames_plain = _capture_frames(base)+ status_seeded, body_seeded, frames_seeded = _capture_frames({**base, "seed": 1234})+ self.assertEqual(status_plain, 200)+ self.assertEqual(status_seeded, 200)+ self.assertEqual(body_seeded["choices"][0], body_plain["choices"][0])+ # Each call uses a freshly-constructed Engine, so both first requests are+ # assigned request id "1" -- the wire frames are directly byte-comparable,+ # no field needs normalizing. Comparing the whole frame list (not just+ # the first frame) closes "reaches no wire frame" literally: if `seed`+ # ever leaked onto any frame, this equality would break.+ self.assertEqual(frames_seeded, frames_plain)++ def test_seed_accepted_and_absent_from_chat_submit_frame(self):+ # Same proof as above, on /v1/chat/completions: generation_options()+ # is shared by both endpoints, but the SUBMIT frame is built from+ # the chat-rendered prompt, so this is not implied by the completions+ # case above -- a divergence between the two call sites would only+ # show up here.+ base = {"model": "test-model", "messages": [{"role": "user", "content": "Hi"}],+ "temperature": 0, "max_tokens": 4}+ status_plain, body_plain, frames_plain = _capture_frames(base, path="/v1/chat/completions")+ status_seeded, body_seeded, frames_seeded = _capture_frames(+ {**base, "seed": 1234}, path="/v1/chat/completions")+ self.assertEqual(status_plain, 200)+ self.assertEqual(status_seeded, 200)+ self.assertEqual(body_seeded["choices"][0], body_plain["choices"][0])+ self.assertEqual(frames_seeded, frames_plain)++class CapSentinelShimTest(unittest.TestCase):# #379 cap-sentinel shim, arch-keyed (#386 r2, F3): an absent cap is# "platform-auto" only for the glm engine (colibri.c coli_resolve_cap);diff --git a/docs/api.md b/docs/api.mdindex 18bfbd36..3dc8680c 100644--- a/docs/api.md+++ b/docs/api.md@@ -49,10 +49,17 @@ The server serves one generation at a time: the model stays in one persistentprocess, so concurrent HTTP requests queue instead of loading duplicate modelcopies. Tool calling depends on the active engine; see the support matrix below.Images, log probabilities, and token penalties return an explicit error rather-than being silently ignored. Audio is accepted only by Inkling checkpoints with+than being silently ignored. `seed` is accepted and ignored (see below).+Audio is accepted only by Inkling checkpoints withaudio support. The default bind address is localhost; set `COLI_API_KEY` beforeexposing the server beyond the machine.+### `seed`++`seed` is accepted (not rejected) for OpenAI-API request-shape compatibility;+the value is not validated. This server sends no per-request seed on the+wire, so the value has no effect at any temperature.+### Tool-calling support| Engine | OpenAI `tools` | Anthropic `tool_use` | Native format |