Summary
A normal Pi coding-agent tool round crashes the MTPLX OpenAI-compatible server with a tensor broadcast error. The server stays alive, but Pi receives the error and stops the agent. This is not an out-of-memory event and should not require callers to shorten/split an otherwise ordinary coding task.
The server advertises a 66,560-token context window, but the failing tensors show a 16,384-token buffer being combined with a 19,295-token sequence.
Error: [broadcast_shapes] Shapes (16384,4,256) and (19295,4,256) cannot be broadcast.
Environment
- Hardware: MacBook Pro, Apple M5 Max, 128 GB unified memory
- OS: macOS 26.6.2 (25G83), arm64
- MTPLX app/runtime: 2.9.0 (build 2009001)
- MLX: 0.32.1; mlx-lm: 0.31.3
- Model:
Youssofal/Qwen3.8-27B-MTPLX-Optimized-Quality
- Served model id:
mtplx-qwen38-27b-optimized-quality
- Client: Pi 0.84.2, OpenAI-compatible chat-completions provider at
http://127.0.0.1:8001/v1
- Pi model setting at reproduction:
contextWindow=66560, maxTokens=16384, reasoning=true
Relevant server configuration resolved by the MTPLX app:
backend-id qwen3_next
generation-mode mtp
profile turbo
scheduler-mode ar_batch
batching-preset agent
context-window 66560
paged-kv-quantization q8
reasoning-mode off
The server process also has MTPLX_DYNAMIC_PAGED_KV_MAX_INITIAL_NEW_TOKENS=4096.
Reproduction
- Launch the MTPLX app with the model above and its Pi/agent target.
- Start Pi with
mtplx/mtplx-qwen38-27b-optimized-quality.
- Give it a normal multi-file UI task: create an HTML/CSS/JS future-city energy-control dashboard with an interactive SVG map, animations, chart, controls and modal.
- Pi creates the project directory, then emits a
write tool call for index.html.
- The response contains a normal 233-line HTML document. The write payload itself is only 9,905 characters / 3,379 Qwen tokenizer tokens.
- Immediately after this tool round, Pi receives the broadcast-shape error and stops. MTPLX remains listening on port 8001.
Pi side:
Now creating the three files.
write .../arcology-control-room/index.html
... (223 more lines, 233 total)
Error: [broadcast_shapes] Shapes (16384,4,256) and (19295,4,256) cannot be broadcast.
Released pi-caffeinate (agent finished).
Warning: pi-lens deferred format: 0 changed, 1 failed
The pi-lens warning is downstream: the inference exception ended the agent round.
Why this looks like a server bug
Pi sends a standard OpenAI-compatible tool-call flow. A coding agent emitting one substantial file is normal usage, and the visible write payload is far below the advertised context window. The service must either grow/repage its MTP/KV state correctly, cap the request using a truthful capability limit, or reject it cleanly before inference. A low-level broadcast_shapes exception is not recoverable by the client.
The 2.9.0 server source includes a dynamic paged-KV reservation path that derives a reservation from prompt_tokens + reserved_new_tokens + mtp_depth, and the active process uses a 4,096 initial-new-token cap. The observed (16384, ...) versus (19295, ...) failure suggests that a fixed or compiled 16K state is still being reused for a longer request/continuation. Please confirm the exact path and whether it is related to ar_batch, MTP verification, or a warmup/compiled-cache bucket.
Expected
- A standard Pi tool-call turn should complete without a tensor-shape crash.
- The effective safe request/output budget should honor the advertised 66,560 context window, or the model endpoint should publish/enforce the real limit.
- If a request cannot fit, return a structured, actionable API error before entering MLX kernels.
- Please add a regression test for a Pi/OpenAI tool-call round containing a 3K+ token file write followed by the next agent continuation.
Related but not duplicate: #282 reports unexpected MTPLX manipulation/truncation of Pi tool behavior. This report is specifically a server-side tensor shape crash in that normal agent workflow.
Summary
A normal Pi coding-agent tool round crashes the MTPLX OpenAI-compatible server with a tensor broadcast error. The server stays alive, but Pi receives the error and stops the agent. This is not an out-of-memory event and should not require callers to shorten/split an otherwise ordinary coding task.
The server advertises a 66,560-token context window, but the failing tensors show a 16,384-token buffer being combined with a 19,295-token sequence.
Environment
Youssofal/Qwen3.8-27B-MTPLX-Optimized-Qualitymtplx-qwen38-27b-optimized-qualityhttp://127.0.0.1:8001/v1contextWindow=66560,maxTokens=16384,reasoning=trueRelevant server configuration resolved by the MTPLX app:
The server process also has
MTPLX_DYNAMIC_PAGED_KV_MAX_INITIAL_NEW_TOKENS=4096.Reproduction
mtplx/mtplx-qwen38-27b-optimized-quality.writetool call forindex.html.Pi side:
The pi-lens warning is downstream: the inference exception ended the agent round.
Why this looks like a server bug
Pi sends a standard OpenAI-compatible tool-call flow. A coding agent emitting one substantial file is normal usage, and the visible write payload is far below the advertised context window. The service must either grow/repage its MTP/KV state correctly, cap the request using a truthful capability limit, or reject it cleanly before inference. A low-level
broadcast_shapesexception is not recoverable by the client.The 2.9.0 server source includes a dynamic paged-KV reservation path that derives a reservation from
prompt_tokens + reserved_new_tokens + mtp_depth, and the active process uses a 4,096 initial-new-token cap. The observed(16384, ...)versus(19295, ...)failure suggests that a fixed or compiled 16K state is still being reused for a longer request/continuation. Please confirm the exact path and whether it is related toar_batch, MTP verification, or a warmup/compiled-cache bucket.Expected
Related but not duplicate: #282 reports unexpected MTPLX manipulation/truncation of Pi tool behavior. This report is specifically a server-side tensor shape crash in that normal agent workflow.