GLM-5.3-Flash EXL3 on 2x DGX Spark with TensorFold
Python
Responses: accept and ignore OpenAI's include values (patch 0092, issue #73)
MiaAI-Lab81c282d5423b
diff --git a/README.md b/README.mdindex c930a5c..d9151fc 100644--- a/README.md+++ b/README.md@@ -654,6 +654,7 @@ applied with `patch -p0` in filename order); `start.sh` rebuilds or re-pulls the| Checked draft candidates | `0092-glm-draft-candidates-checked` | the drafter checks each block pass's candidate ids against the vocabulary; on an id outside it (issue #80: a float's bits read as an id) it logs the value, copies the rows again once the device is idle, and fails only if they are still bad | a rare drafter `IndexError` is retried (and its cause logged) instead of killing a rank || Spill tier | `0088-glm-spill-tier` | kept prompt states written to local disk on every Spark when they leave the pool (early, in the background, past `SPILL_HIGHWATER`) and read back beside decoding streams, also after a clean restart (`SPILL_GIB`, off by default; authored by Robert Wojciechowski, [wojo](https://github.com/wojo), #78) | [Spill tier](#spill-tier-optional) || Kept-state limits | `0089-glm-kept-state` | `TF_GLM_KEPT_BYTES_GIB` (a byte budget for the kept states, with the freed blocks handed back to the driver) and `TF_GLM_KEEP_PER_CHAT` (a per-conversation quota of turn-boundary states), both off by default; `/health` `kept_bytes`, `kept_mix` (authored by Thomas Wade, [ThomasWadeZ](https://github.com/ThomasWadeZ), #65) | with both at 0, nothing changes |+| Responses `include` | `0093-responses-include` | `/v1/responses` accepts OpenAI's `include` values and ignores them (reasoning already comes as text, nothing is encrypted); an unknown value or a non-list is still a 400 (issue #73) | the AI SDK's `include: ["reasoning.encrypted_content"]` no longer fails every request || Concurrent fill | `0062-glm-sliced-fill` | a new prompt's chunks run in layer slices (`FILL_BUDGET_MS`) with decode rounds between them, drafted as usual (`FILL_DRAFTS`), both ranks on the same layer boundaries; the chunk's buffers kept between slices, grouped fills, cache moves and cancellation mid-fill; whole forwards when nothing else decodes | with smooth streaming, the other replies' pauses during a 25k-token fill 630-690 ms -> 81-149 ms (table below) |Concurrent prompt fill and smooth streaming on two Sparks (`PARALLEL=4`, DFlash2, 1,024-row chunks): three 400-tokendiff --git a/patches/0093-responses-include.patch b/patches/0093-responses-include.patchnew file mode 100644index 0000000..f552518--- /dev/null+++ b/patches/0093-responses-include.patch@@ -0,0 +1,46 @@+diff --git tensorfold/server/responses_translate.py tensorfold/server/responses_translate.py+index a5c1122..d1c020a 100644+--- tensorfold/server/responses_translate.py++++ tensorfold/server/responses_translate.py+@@ -155,6 +155,30 @@ def _format(text: Any) -> dict[str, Any] | None:+ raise RequestError("text.format must be text, json_object or json_schema")++++# OpenAI's ``include`` values. Each asks for more output this server has nothing to add to: reasoning comes as text in++# its reasoning item and nothing is encrypted, no tool runs on the server, and the logprobs are the empty lists they++# always are. Clients (the AI SDK sends reasoning.encrypted_content on every reasoning-model request) set them by++# habit, so they are accepted and ignored; a value OpenAI does not define is still refused, as OpenAI does.++INCLUDE = frozenset({"reasoning.encrypted_content", "message.output_text.logprobs", "message.input_image.image_url",++ "file_search_call.results", "web_search_call.results", "web_search_call.action.sources",++ "code_interpreter_call.outputs", "computer_call_output.output.image_url"})++_included: set[str] = set()++++++def _include(given: Any) -> None:++ if given is None:++ return++ if not isinstance(given, list) or not all(isinstance(v, str) for v in given):++ raise RequestError("include must be a list of strings")++ unknown = [v for v in given if v not in INCLUDE]++ if unknown:++ raise RequestError(f"include has no value {', '.join(map(repr, unknown))}: the values are {', '.join(sorted(INCLUDE))}")++ for value in given:++ if value not in _included: # said once a value, not on every request++ _included.add(value)++ print(f"[tensorfold] responses: include {value!r} is accepted and has no effect here", flush=True)+++++ def translate(body: Any, store: Store) -> Request:+ """A Responses request as the chat completion that runs it; RequestError where it asks what this server lacks."""++@@ -164,9 +188,7 @@ def translate(body: Any, store: Store) -> Request:+ for name, reason in REFUSED.items():+ if body.get(name):+ raise RequestError(reason)+- if body.get("include"):+- raise RequestError(f"include is not supported ({', '.join(map(str, body['include']))}): reasoning comes as "+- "text in its reasoning item, and nothing is encrypted")++ _include(body.get("include"))+ if body.get("truncation") not in (None, "disabled"):+ raise RequestError('truncation must be "disabled": a prompt too long for the context is refused')+ if body.get("top_logprobs"):diff --git a/tools/test_responses_include.py b/tools/test_responses_include.pynew file mode 100644index 0000000..46d0a04--- /dev/null+++ b/tools/test_responses_include.py@@ -0,0 +1,49 @@+"""CPU-only check of the Responses translator's ``include`` handling (issue #73).++ python3 -B tools/test_responses_include.py --source-root /path/to/patched/src+Use --expect-stock on the unpatched source to see the 400 the issue reports. Needs no torch, GPU or sockets.+"""+from __future__ import annotations++import argparse+import sys+++class Store:+ def conversation(self, _id):+ return []+++def main():+ ap = argparse.ArgumentParser()+ ap.add_argument("--source-root", required=True)+ ap.add_argument("--expect-stock", action="store_true")+ args = ap.parse_args()+ sys.path.insert(0, args.source_root)+ from tensorfold.server.errors import RequestError+ from tensorfold.server.responses_translate import translate++ body = {"model": "x", "store": False, "input": [{"role": "user", "content": [{"type": "input_text", "text": "Say OK."}]}]}++ def run(include):+ try:+ translate({**body, "include": include}, Store())+ return None+ except RequestError as exc:+ return str(exc)++ if args.expect_stock:+ assert run(["reasoning.encrypted_content"]), "stock source accepted include"+ print("stock: include refused, as reported")+ return+ for ok in ([], None, ["reasoning.encrypted_content"], ["reasoning.encrypted_content", "message.output_text.logprobs"]):+ assert run(ok) is None, (ok, run(ok))+ for bad in (["nope"], "reasoning.encrypted_content", [1], {"a": 1}):+ assert run(bad), f"{bad!r} was accepted"+ assert translate({**body, "include": ["reasoning.encrypted_content"]}, Store()).chat["messages"] == \+ translate(body, Store()).chat["messages"], "include changed the chat request"+ print("include: known values accepted and ignored, unknown or malformed ones refused")+++if __name__ == "__main__":+ main()