Skip to content

GLM-5.3-Flash EXL3 on 2x DGX Spark with TensorFold

Python

README, CHANGELOG: rows and entries for patches 0109, 0110, 0112, 0114, 0115 and the new checks; the 64 KiB bound of 0113

MiaAI-Lab447c4cde00a2
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6a501f1..7bf5951 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -36,6 +36,17 @@ Every change to this recipe, newest first. Each release names the image it serve
cold request of 50 full-size pictures (102,118 tokens) answers and resumes. Pictures past the 8th are no longer
downscaled, so they cost up to 2,048 tokens each. `TENSORFOLD_GLM_REQUEST_IMAGE_TOKENS=16384` restores the shared
budget. No patch and no image change. CPU check: `tools/picture_budget_check.py`.
+- **A phone photo (an iPhone MPO JPEG) is accepted** (patch `0110-vision-mpo-first-frame`, issue #201, diagnosed by
+ [robertforbes68](https://github.com/robertforbes68)): the decode guard refused any image whose `n_frames` was not 1, and
+ an MPO (what iPhones and many Android phones save as `.jpg`: the picture plus a preview, depth or gain map) reports 2
+ or more, so a photo straight from the phone got a 400 "animated and multipage images are unsupported". An MPO is now
+ read from its first frame, the only one ever decoded; the size and pixel limits apply as before, and animated WebP and
+ multi-frame PNG are still refused. CPU check: `tools/test_mpo_first_frame.py` (needs Pillow; fails without the patch).
+- **Pictures inside a Responses `function_call_output`** (patch `0109-responses-tool-image`, issue #162, by
+ [StrayDragon](https://github.com/StrayDragon), [pull request #175](https://github.com/MiaAI-Lab/GLM-5.3-Flash-EXL3-2x-DGX-Sparks-TensorFold/pull/175)):
+ an agent that returns a tool's screenshot as `input_image` parts got a 400 ("must be a string or input_text
+ parts"), although the chat route renders tool-result pictures. The `_output` hunk of TensorFold commit 69d0ca9 (v0.6.3)
+ now lets those parts through. CPU check: `tools/test_responses_tool_image.py` (fails without the patch).
- **Streamed replies keep the connection alive while they wait** (patch `0111-server-sse-keepalive`, issue #106,
reported with the first version of the patch by [stevehansen](https://github.com/stevehansen)): a streamed reply
sent nothing between its first event and its first token, so a request waiting for a lane or filling a long prompt
diff --git a/README.md b/README.md
index 96de6ea..d24d4d5 100644
--- a/README.md
+++ b/README.md
@@ -712,7 +712,12 @@ applied with `patch -p0` in filename order); `start.sh` rebuilds or re-pulls the
| 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 |
| Broken engine | `0118-glm-broken-health-exit` | `/health` reports `ok: false` with its first broken cause, `/metrics` exposes `tensorfold_health:ok`, and opt-in `TF_GLM_EXIT_ON_BROKEN=1` exits non-zero on the latch | broken state is visible; default process lifetime unchanged |
| Chunked request bodies | `0094-chunked-request-bodies` | a `Transfer-Encoding: chunked` request body (AI SDK clients, Chatbox, proxies) is read like a `Content-Length` one on the chat, completions, tokenizer and Responses routes and the MLX-style server, each route keeping its own size limit (96 MiB for chat); a refused request's body is consumed so it cannot reach the next one. The reader is `request_body.read_body` from TensorFold's 977f2cc by Jordi Posthumus (@JordiPosthumus), which `0084` adds; this patch uses it at the remaining sites (issues #67, #74) | no dechunking proxy; a validation 400 no longer leaves HTML after the JSON on a keep-alive connection |
-| GET and DELETE bodies | `0113-http-get-delete-body-discard` | `do_GET` and `do_DELETE` read a request's body (Content-Length or chunked, through `0059`'s `_discard_body`) before answering; they read none, so a GET with a body (scanners send them) left its bytes on the keep-alive connection, parsed as the next request on it: a stdlib "Bad request syntax" 400 for whatever came next, behind a pooling proxy often another client's (by [cawilliamson](https://github.com/cawilliamson)) | the next request on the connection is answered as sent |
+| GET and DELETE bodies | `0113-http-get-delete-body-discard` | `do_GET` and `do_DELETE` read a request's body (Content-Length or chunked, through `0059`'s `_discard_body`) before answering; they read none, so a GET with a body (scanners send them) left its bytes on the keep-alive connection, parsed as the next request on it: a stdlib "Bad request syntax" 400 for whatever came next, behind a pooling proxy often another client's (by [cawilliamson](https://github.com/cawilliamson)) | the next request on the connection is answered as sent The read is bounded at 64 KiB for these two methods (a POST may carry 32 MiB): a larger body is refused unread and the connection closed |
+| Tool-result pictures | `0109-responses-tool-image` | a Responses `function_call_output` may carry `input_image` parts (a tool's screenshot) as the chat route's tool results can, instead of the 400 "must be a string or input_text parts" (issue #162); other parts are still refused |
+| Phone photos | `0110-vision-mpo-first-frame` | an iPhone MPO JPEG (the picture plus an auxiliary frame: preview, depth or gain map) is read from its first frame instead of refused as multipage (issue #201); only frame 0 is ever decoded, the size limits apply as before, and animated WebP and multi-frame PNG are still refused |
+| Messages stream head | `0112-anthropic-stream-head-usage` | a streamed `/v1/messages` reply opens with the prompt's token count in `message_start` (it carried zeros, so a client's context indicator read 0% until the end) |
+| Quoted `<tool_call>` | `0114-glm-tool-tag-mention` | a tool call after a quoted `<tool_call>` tag in the reasoning is a call again, and a word the tags enclose with a space is prose, not a call without arguments |
+| Unoffered tool calls | `0115-glm-unoffered-tool-call` | a call to a tool the request did not offer stays text, as before, and is reported in the log (`TF_GLM_TOOL_DIAGNOSTICS`) |
| Streamed admission | `0095-stream-admission` | with `TF_GLM_MAX_QUEUED` set, a streamed request to a full server is answered 429 + `Retry-After: 5` before the stream opens; `0082` checked inside `submit`, after the 200 and the headers had gone out, so a streaming client (opencode, Claude Code) got a 200 with the error as an event and never saw a retryable status (issue #50) | the same refusal for streamed and plain requests |
| Stream keep-alive | `0111-server-sse-keepalive` | a streamed reply that has sent nothing for `TENSORFOLD_SSE_KEEPALIVE_S` seconds (15; `0`: off) writes an SSE comment line, `: keepalive`, on the chat, completions, Messages and Responses streams; a request waiting for a lane or filling a long prompt was silent from its first event to its first token, and a proxy in front cut it as idle (reported behind a Cloudflare Tunnel: every such stream at ~125 s; issue #106, with the first version of this patch by stevehansen) | the same events, byte for byte; no stream silent for longer than the setting |
| Effort line at the tail | `0096-effort-tail` | opt-in `TF_GLM_EFFORT_TAIL=1`: the reasoning-effort line is rendered before the generation prompt, not at token 3, so changing effort or thinking on/off no longer misses the kept prompt and re-prefills the whole conversation (issue #93, reported and measured by jdecker76); off, every prompt is byte-identical to before | the same prompts as before |
@@ -765,6 +770,8 @@ with [sparkDash](https://github.com/MiaAI-Lab/sparkDash) ([Performance](#perform
| `tools/needle.py [label] [size]` | hides a passphrase in a ~195k-token prompt (the prompt comes out at ~0.8 x `size` tokens) and checks the model returns it |
| `tools/toolcheck.py` | makes a tool call with an array parameter and checks it comes back as a JSON array |
| `tools/test_get_bodies.py --source-root DIR` | patch 0113's checks on the CPU, against TensorFold's source with the patches applied: the real CUDA handler on a loopback port, GETs and a DELETE with Content-Length and chunked bodies, each followed by more requests on the same keep-alive connection, and a GET body past the limit closing it; `--expect-stock` reproduces the leaked body's 400 on the unpatched source |
+| `tools/test_responses_tool_image.py --source-root DIR` | patch 0109's checks on the CPU: an `input_image` part in a `function_call_output` reaches the tool message, text outputs keep their shape, other parts are refused; `--expect-stock` shows the old 400 |
+| `tools/test_mpo_first_frame.py --source-root DIR` | patch 0110's checks on the CPU (needs Pillow): an MPO is read from its first frame, an auxiliary frame far over the limits is never decoded, plain JPEG and PNG are unchanged, animated WebP and multi-frame PNG are still refused; `--expect-stock` shows the old 400 |
| `tools/literal_tokens_check.py <checkpoint dir>` | patch 0116's checks, run in the image (CPU only, see the file): on the checkpoint's own tokenizer and template, quoted added tokens encode as text and everything else as before, the exceptions keep the old ids, GLM's kept reasoning is still put back, other families' `App` is unchanged |
| `tools/reply_ids_check.py <checkpoint dir>` | patch 0117's checks, run in the image (CPU only, see the file): through the chat route on the checkpoint's own tokenizer, whole and streamed, spelled markup stays text, real calls and the think split as before, nothing inert reaches a client; the switch on in `GlmApp`, off with `TF_GLM_REPLY_IDS=0` and in other families |
| `tools/display_kv_check.py [--gpu]` | patch 0072's checks, run in the image (`docker run ... --entrypoint python`, see the file): the setting, the span's mapping and unwinding through a fake driver, the carved planes and the pool's copies; with `--gpu`, the real span on a Spark whose display reservation is free |