[GH-ISSUE #2715] --batch on the Metal backend is accepted at boot and exits the engine with code 86 on the first request that runs two sequences together #1085

Closed
opened 2026-11-04 01:48:22 +07:00 by bsakaguchi · 3 comments
Owner

Originally created by @alvarorsouza-arch on GitHub (Oct 16, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/2715

What happened

--batch is accepted on the Metal backend, allocates its slot sessions at boot, and then stops the engine the first time a request actually decodes two sequences together. On a Mac that is worse than a refusal, because the server restarts the engine between requests and the rest of the run fails the same way.

What I ran: setup's own config for the IQ3_S pack plus --batch N in --serve, then the repo's burst client.

python3 tools/serve_load.py http://127.0.0.1:8012 --clients 1,4 --rounds 3 --max-tokens 256

The boot is happy, and it announces itself with the CUDA device name on a Mac build:

strata generate: --batch: 4 slot sessions on CUDA0 (1.73 GiB each); 95.16 GiB free
strata generate: --batch 4: the slot sessions take 6.91 GiB of VRAM on CUDA0 that the expert cache would otherwise hold
strata verify: batch windows of up to 4 sequences (layers [0, -1))

The first concurrent round then writes two lines and the process is gone:

strata batch: slot 0 takes 67 tokens (copied in 12.7 ms)
strata metal: strata::kernels::pdl_supported has no Metal implementation yet

metal/src/engine/missing.cpp documents what follows that message, verbatim: Default: say which one and stop (exit code 86), so a run never continues on outputs nobody wrote. The server's side:

[strata] the engine stopped unexpectedly (exit code 86). ... The next request starts the engine again.
[strata] the engine had stopped (exit code 86); starting it again (a minute or two) ...

In my engine log the restarts after these exits are 6, 25 and 74 s apart. Same at --batch 2 and --batch 3.

Measured with tools/serve_load.py, three rounds, 256 tokens out, one engine boot per row:

--batch one client, total tok/s that many clients, total tok/s first token p50/p95, seconds
2 43.3 0.4 5.12 / 5.21
3 43.3 0.3 5.19 / 5.23
4 44.2 0.4 5.26 / 5.29

One client is normal decode; from two sequences onward the number is the restart cycle, not throughput.

Strata version, GPU, OS

0.1.44.1-metal, source build of main at 296b59d · Apple M3 Max, 40-core GPU, 128 GB unified memory · macOS 26.6, high power mode. Model: original Flash-Next IQ3_S, --max-context 65536, experts resident with --mmap-experts, --spec 2 with the MTP draft layer, everything else at setup defaults.

Engine log

The two relevant lines are quoted above, and the version line in the same log reads strata generate: session is up (engine 0.1.44.1-metal). The full measurement set for this machine is in #2649.

Why it stops at that call

src/core/verify.cpp:901 decides the batch window with pdl_window(G == 1 && pdl_supported()). pdl_supported() is a capability query rather than a kernel, and on Metal it is one of the entry points listed in metal/src/engine/stubs.cpp, so it runs missing() and exits.

How far the batch route is from working on Metal

STRATA_METAL_STUBS=log, which that same file describes as for listing which entry points a code path reaches, never for answers, shows what a four sequence run touches. Seventeen entry points:

pdl_supported, pdl_scope
fused_gr_read_multi, gdn_conv_l2_multi, gdn_ab_multi, gdn_step_norm_multi, shared_expert_multi, broadcast_streams
native_quantize_q8_1, native_mmvq, native_router_top10, quantize_q8_1_rows, iq_embed_rows, bf16_gemv_fp32_mmvf
doorbell_publish_res, copy_from_mapped, copy_i32_from_mapped

Two capability queries, the multi row family a batched window needs, the native helpers, and the expert pool side, which Metal does not use because it reads experts in place from the mapped file.

What I would suggest

  • Refuse --batch on Metal at boot, the way --kv int8 already stops there with strata metal: strata::kernels::kv_block_bytes has no Metal implementation yet, instead of allocating 1.73 GiB per sequence and exiting 86 mid-request.
  • If the intent is to reach batch on Metal, pdl_supported returning false in the stubs moves the stop from a capability query to the kernels that matter, which is where the list above becomes a checklist.
  • docs/MAC.md still names --parallel (batch slots) as not ported. The flag today is --batch (and --slots), so a Mac reader can miss the line, and the boot line's on CUDA0 does not help.
Originally created by @alvarorsouza-arch on GitHub (Oct 16, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/2715 ## What happened `--batch` is accepted on the Metal backend, allocates its slot sessions at boot, and then stops the engine the first time a request actually decodes two sequences together. On a Mac that is worse than a refusal, because the server restarts the engine between requests and the rest of the run fails the same way. What I ran: setup's own config for the IQ3_S pack plus `--batch N` in `--serve`, then the repo's burst client. ```bash python3 tools/serve_load.py http://127.0.0.1:8012 --clients 1,4 --rounds 3 --max-tokens 256 ``` The boot is happy, and it announces itself with the CUDA device name on a Mac build: ```text strata generate: --batch: 4 slot sessions on CUDA0 (1.73 GiB each); 95.16 GiB free strata generate: --batch 4: the slot sessions take 6.91 GiB of VRAM on CUDA0 that the expert cache would otherwise hold strata verify: batch windows of up to 4 sequences (layers [0, -1)) ``` The first concurrent round then writes two lines and the process is gone: ```text strata batch: slot 0 takes 67 tokens (copied in 12.7 ms) strata metal: strata::kernels::pdl_supported has no Metal implementation yet ``` `metal/src/engine/missing.cpp` documents what follows that message, verbatim: `Default: say which one and stop (exit code 86), so a run never continues on outputs nobody wrote.` The server's side: ```text [strata] the engine stopped unexpectedly (exit code 86). ... The next request starts the engine again. [strata] the engine had stopped (exit code 86); starting it again (a minute or two) ... ``` In my engine log the restarts after these exits are 6, 25 and 74 s apart. Same at `--batch 2` and `--batch 3`. Measured with `tools/serve_load.py`, three rounds, 256 tokens out, one engine boot per row: | `--batch` | one client, total tok/s | that many clients, total tok/s | first token p50/p95, seconds | |---:|---:|---:|---| | 2 | 43.3 | 0.4 | 5.12 / 5.21 | | 3 | 43.3 | 0.3 | 5.19 / 5.23 | | 4 | 44.2 | 0.4 | 5.26 / 5.29 | One client is normal decode; from two sequences onward the number is the restart cycle, not throughput. ## Strata version, GPU, OS 0.1.44.1-metal, source build of `main` at `296b59d` · Apple M3 Max, 40-core GPU, 128 GB unified memory · macOS 26.6, high power mode. Model: original Flash-Next IQ3_S, `--max-context 65536`, experts resident with `--mmap-experts`, `--spec 2` with the MTP draft layer, everything else at setup defaults. ## Engine log The two relevant lines are quoted above, and the version line in the same log reads `strata generate: session is up (engine 0.1.44.1-metal)`. The full measurement set for this machine is in #2649. ## Why it stops at that call `src/core/verify.cpp:901` decides the batch window with `pdl_window(G == 1 && pdl_supported())`. `pdl_supported()` is a capability query rather than a kernel, and on Metal it is one of the entry points listed in `metal/src/engine/stubs.cpp`, so it runs `missing()` and exits. ## How far the batch route is from working on Metal `STRATA_METAL_STUBS=log`, which that same file describes as `for listing which entry points a code path reaches, never for answers`, shows what a four sequence run touches. Seventeen entry points: ```text pdl_supported, pdl_scope fused_gr_read_multi, gdn_conv_l2_multi, gdn_ab_multi, gdn_step_norm_multi, shared_expert_multi, broadcast_streams native_quantize_q8_1, native_mmvq, native_router_top10, quantize_q8_1_rows, iq_embed_rows, bf16_gemv_fp32_mmvf doorbell_publish_res, copy_from_mapped, copy_i32_from_mapped ``` Two capability queries, the multi row family a batched window needs, the native helpers, and the expert pool side, which Metal does not use because it reads experts in place from the mapped file. ## What I would suggest - Refuse `--batch` on Metal at boot, the way `--kv int8` already stops there with `strata metal: strata::kernels::kv_block_bytes has no Metal implementation yet`, instead of allocating 1.73 GiB per sequence and exiting 86 mid-request. - If the intent is to reach batch on Metal, `pdl_supported` returning false in the stubs moves the stop from a capability query to the kernels that matter, which is where the list above becomes a checklist. - `docs/MAC.md` still names `--parallel` (batch slots) as not ported. The flag today is `--batch` (and `--slots`), so a Mac reader can miss the line, and the boot line's `on CUDA0` does not help.
Author
Owner

@Spinoza0 commented on GitHub (Oct 18, 2026):

Reproduced on a MacBook Pro M4 Pro 48 GB (engine 0.1.45-metal, built from source) with the IQ2_XS GSQ-RCO pack and "parallel": 2 in the config: same shape — the engine announces strata verify: batch windows of up to 2 sequences at boot, reads the first prompt, then stops on the next batched decode.

strata batch: slot 0 takes 63 tokens (copied in 20.6 ms)
strata metal: strata::kernels::pdl_supported has no Metal implementation yet       (exit 86)
strata metal: strata::kernels::copy_i32_from_mapped has no Metal implementation yet  (exit 86, after the pdl fix)
strata metal: strata::kernels::iq_embed_rows has no Metal implementation yet          (exit 86, after both fixes above)

After the first three stops the run reaches Verifier::record_window and dies with SIGSEGV caught by metal_crash, so the list above matches what I see too: the capability queries come first, then the mapped handoff helpers, then the kernels proper.

Three extra findings from this machine, in case they shorten the checklist:

  • The prompt path stops earlier with ref: unknown type 29 (metal/src/ref_quant.cpp): this GGUF stores three layers' MoE experts (blk.8, blk.13, blk.37 gate/up as IQ1_M inside the IQ2_XS file, a mixed-quant pack), and ref_quant has no IQ1_M. That is the same gap that took IQ2_XS out of setup_mac's menu, so any batch run on this pack trip it first.
  • With that fixed, the parts below are straight non-kernel work and I have them running on my build: pdl_supported/pdl_scope as plain no-ops (Metal never has PDL), copy_from_mapped/copy_i32_from_mapped as memcpy_async blits (on unified memory the CUDA reasons for the copy-kernel handoff apply to WDDM, not to Metal), and iq_embed_rows/iq_dequant_f32/iq_dequant_f16 as host dequantizers over the mapped table.
  • The remaining entry in my trace after those is the multi-kernel family (fused_gr_read_multi, shared_expert_multi, the gdn_*_multi row, broadcast_streams, doorbell_publish_res), which is the real porting work — agreeing with the checklist framing.

Until then I have parallel off in my config; the engine and the solo path work fine (and the IQ1_M-in-pack fix is worth having for the single-request path regardless). Reports welcome from other Mac owners; my full notes live in a local v0.1.44.1-to-v0.1.45 metal port.

<!-- gh-comment-id:6250100302 --> @Spinoza0 commented on GitHub (Oct 18, 2026): Reproduced on a MacBook Pro M4 Pro 48 GB (engine 0.1.45-metal, built from source) with the IQ2_XS GSQ-RCO pack and `"parallel": 2` in the config: same shape — the engine announces `strata verify: batch windows of up to 2 sequences` at boot, reads the first prompt, then stops on the next batched decode. ``` strata batch: slot 0 takes 63 tokens (copied in 20.6 ms) strata metal: strata::kernels::pdl_supported has no Metal implementation yet (exit 86) strata metal: strata::kernels::copy_i32_from_mapped has no Metal implementation yet (exit 86, after the pdl fix) strata metal: strata::kernels::iq_embed_rows has no Metal implementation yet (exit 86, after both fixes above) ``` After the first three stops the run reaches `Verifier::record_window` and dies with SIGSEGV caught by metal_crash, so the list above matches what I see too: the capability queries come first, then the mapped handoff helpers, then the kernels proper. Three extra findings from this machine, in case they shorten the checklist: - The prompt path stops earlier with `ref: unknown type 29` (metal/src/ref_quant.cpp): this GGUF stores three layers' MoE experts (blk.8, blk.13, blk.37 gate/up as IQ1_M inside the IQ2_XS file, a mixed-quant pack), and ref_quant has no IQ1_M. That is the same gap that took IQ2_XS out of setup_mac's menu, so any batch run on this pack trip it first. - With that fixed, the parts below are straight non-kernel work and I have them running on my build: `pdl_supported`/`pdl_scope` as plain no-ops (Metal never has PDL), `copy_from_mapped`/`copy_i32_from_mapped` as `memcpy_async` blits (on unified memory the CUDA reasons for the copy-kernel handoff apply to WDDM, not to Metal), and `iq_embed_rows`/`iq_dequant_f32`/`iq_dequant_f16` as host dequantizers over the mapped table. - The remaining entry in my trace after those is the multi-kernel family (`fused_gr_read_multi`, `shared_expert_multi`, the gdn_\*_multi row, `broadcast_streams`, `doorbell_publish_res`), which is the real porting work — agreeing with the checklist framing. Until then I have `parallel` off in my config; the engine and the solo path work fine (and the IQ1_M-in-pack fix is worth having for the single-request path regardless). Reports welcome from other Mac owners; my full notes live in a local v0.1.44.1-to-v0.1.45 metal port.
Author
Owner

@Niko1221 commented on GitHub (Oct 19, 2026):

Thanks for taking the time to report this.

We're resetting the tracker for 0.2.0-beta. There are more than 1,300 open issues and pull requests, too many for us to read properly, so we're closing everything that isn't being worked on right now. Closed here does not mean rejected.

To reopen it takes about two minutes:

  1. Re-test on 0.2.0-beta. It may already be fixed. Write down what you see.
  2. Start the title with its area: [Engine], [GUI], [TUI], [Benchmark], [Docs] or [Other].
  3. Fill in the parts of the issue form: what happened, the Strata version, your graphics card, memory and system.
  4. Comment /reopen. A check runs and either reopens the issue or lists what is still missing.

The rules are in CONTRIBUTING.md.

<!-- gh-comment-id:6271197887 --> @Niko1221 commented on GitHub (Oct 19, 2026): Thanks for taking the time to report this. We're resetting the tracker for 0.2.0-beta. There are more than 1,300 open issues and pull requests, too many for us to read properly, so we're closing everything that isn't being worked on right now. Closed here does not mean rejected. To reopen it takes about two minutes: 1. Re-test on 0.2.0-beta. It may already be fixed. Write down what you see. 2. Start the title with its area: [Engine], [GUI], [TUI], [Benchmark], [Docs] or [Other]. 3. Fill in the parts of the issue form: what happened, the Strata version, your graphics card, memory and system. 4. Comment `/reopen`. A check runs and either reopens the issue or lists what is still missing. The rules are in [CONTRIBUTING.md](https://github.com/Niko1221/Strata/blob/main/CONTRIBUTING.md).
Author
Owner

@Wolf-Quiteque commented on GitHub (Oct 23, 2026):

Re-confirming this on a different Mac, and adding the number the thread is missing: what the absent batch path actually costs.

What I ran: Strata 0.1.44.1-metal (source build in ~/Strata-local), Apple M4 Max, 128 GB unified memory, macOS 27.0.1, IQ3_S GSQ-RCO pack (78 GB, internal SSD), --serve with --kv q4_0 --max-context 262144 --expert-cache 64 --mtp --spec 2, plus "parallel": 2 in the model config.

The boot is happy, as reported:

strata generate: --batch: 2 slot sessions on CUDA0 (2.25 GiB each); 111.14 GiB free
strata generate: --batch 2: the slot sessions take 4.49 GiB of VRAM on CUDA0 that the expert cache would otherwise hold
strata verify: batch windows of up to 2 sequences (layers [0, -1))

The first concurrent request then stops the engine:

strata batch: slot 0 takes 1656 tokens (copied in 13.7 ms)
strata metal: strata::kernels::pdl_supported has no Metal implementation yet     (exit 86)

Client side, both requests get 503 the engine stopped unexpectedly (exit code 86); the server restarts the engine and the next pair dies identically. Three consecutive attempts: 0 of 6 requests completed.

What it costs. Two concurrent prompts of 1,656 tokens, 150 greedy tokens each, same client, same prompt shape:

arm second finisher outcome
one slot (no parallel) 8.41 s (8.40 / 8.41 / 8.41 over three runs) both complete
"parallel": 2 6.58–6.65 s both slots batched, engine stops on the window

Solo reference on the same box: 4.3–5.3 s per request, decode 66–67 tok/s, prefill ~615 tok/s warm. So one slot is fully serialized (2 concurrent = ~1.9x solo), and the batch path was recovering ~27% of that before it died — on a machine with 59 GB of VRAM sitting free and only 4.49 GiB asked for.

Still current on main, not just on 0.1.44: metal/src/engine/stubs.cpp:288 on main still reads

namespace strata::kernels { bool pdl_supported() { strata::metal_engine::missing("strata::kernels::pdl_supported"); return {}; } }

so a 0.2.2 / engine 0.1.47 build should hit the same stop (relevant given @Spinoza0's follow-ons: copy_i32_from_mapped, iq_embed_rows, then the SIGSEGV at Verifier::record_window).

Ask: is the Metal batch-decode path planned — pdl_supported plus the two follow-on kernels above? If there is a build that has it, name it and I will run the same two-stream probe on it and report the numbers either way.

/reopen

<!-- gh-comment-id:6354108253 --> @Wolf-Quiteque commented on GitHub (Oct 23, 2026): Re-confirming this on a different Mac, and adding the number the thread is missing: what the absent batch path actually costs. **What I ran:** Strata `0.1.44.1-metal` (source build in `~/Strata-local`), Apple **M4 Max**, **128 GB** unified memory, macOS 27.0.1, IQ3_S GSQ-RCO pack (78 GB, internal SSD), `--serve` with `--kv q4_0 --max-context 262144 --expert-cache 64 --mtp --spec 2`, plus `"parallel": 2` in the model config. **The boot is happy, as reported:** ```text strata generate: --batch: 2 slot sessions on CUDA0 (2.25 GiB each); 111.14 GiB free strata generate: --batch 2: the slot sessions take 4.49 GiB of VRAM on CUDA0 that the expert cache would otherwise hold strata verify: batch windows of up to 2 sequences (layers [0, -1)) ``` **The first concurrent request then stops the engine:** ```text strata batch: slot 0 takes 1656 tokens (copied in 13.7 ms) strata metal: strata::kernels::pdl_supported has no Metal implementation yet (exit 86) ``` Client side, both requests get `503 the engine stopped unexpectedly (exit code 86)`; the server restarts the engine and the next pair dies identically. Three consecutive attempts: **0 of 6 requests completed**. **What it costs.** Two concurrent prompts of 1,656 tokens, 150 greedy tokens each, same client, same prompt shape: | arm | second finisher | outcome | | --- | --- | --- | | one slot (no `parallel`) | **8.41 s** (8.40 / 8.41 / 8.41 over three runs) | both complete | | `"parallel": 2` | **6.58–6.65 s** | both slots batched, engine stops on the window | Solo reference on the same box: 4.3–5.3 s per request, decode 66–67 tok/s, prefill ~615 tok/s warm. So one slot is fully serialized (2 concurrent = ~1.9x solo), and the batch path was recovering ~27% of that before it died — on a machine with 59 GB of VRAM sitting free and only 4.49 GiB asked for. **Still current on main, not just on 0.1.44:** `metal/src/engine/stubs.cpp:288` on `main` still reads ```cpp namespace strata::kernels { bool pdl_supported() { strata::metal_engine::missing("strata::kernels::pdl_supported"); return {}; } } ``` so a 0.2.2 / engine 0.1.47 build should hit the same stop (relevant given @Spinoza0's follow-ons: `copy_i32_from_mapped`, `iq_embed_rows`, then the SIGSEGV at `Verifier::record_window`). **Ask:** is the Metal batch-decode path planned — `pdl_supported` plus the two follow-on kernels above? If there is a build that has it, name it and I will run the same two-stream probe on it and report the numbers either way. /reopen
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#1085
No description provided.