[PR #2989] [Engine] batch-groups: a prompt with pictures is read beside the decoding slots too, stall 5.7 -> 0.4 s (opt-in) #4384

Open
opened 2026-11-07 15:35:19 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/2989
Author: @SuperDistance
Created: 10/18/2026
Status: 🔄 Open

Base: main ← Head: pr/piped-concurrent-pictures


📝 Commits (1)

  • b3e7d69 batch-groups: the concurrent read takes prompts with pictures too

📊 Changes

6 files changed (+116 additions, -23 deletions)

View changed files

📝 docs/BATCHING.md (+4 -2)
📝 include/strata/prefill/prefill.hpp (+6 -5)
➕ include/strata/prefill/prompt_uploads.hpp (+34 -0)
📝 src/prefill/prefill.cpp (+9 -9)
📝 src/program/generate.cpp (+18 -6)
📝 tests/program/batch_read_test.cpp (+45 -1)

📄 Description

Problem and result

With STRATA_PIPED_CONCURRENT=1 a text prompt is read on a thread of its own while the other slots keep decoding, but a prompt with pictures is still read the usual way, so every slot stops for it (docs/BATCHING.md: "A prompt with pictures is read the usual way"). Coding agents send screenshots, and 0.2.0 turns pictures on by default. With this change a prompt with pictures is read the same way as a text prompt. On 0.2.0-beta, 2x RTX 5090, while a 50K-token prompt with a picture is read beside four decoding streams, the streams keep 20.8-23.7 tok/s instead of 6.0-7.1 tok/s and their longest pause goes from 5.7 s to 0.14-0.43 s. Without STRATA_PIPED_CONCURRENT=1 nothing changes.

#2326 (the concurrent read; in main since 0.1.45). #1242 (the per-device image-position table; not touched here). Rebased onto 0.2.0-beta (no conflicts) after the tracker reset; the earlier description's 0.1.45 numbers are kept under Validation.

Approach

Pictures were kept out because a picture's rows go up through the prompt path's pinned ring (core::PinnedRing, #1996), whose size was taken to be known only at the upload; the read's thread could then grow a slot, and a pinned allocation takes the driver's lock (#31). That size is bounded: the gather sends a picture's rows in runs of at most 4 MiB.

  • include/strata/prefill/prompt_uploads.hpp (new, header-only arithmetic): picture_run_rows() is the gather's run (the same expression as before), prompt_upload_bytes() the largest upload a chunk can send, pictures included.
  • Before a concurrent read, Prefill::reserve_uploads(T, pictures) grows the ring to that, as the concurrent read already does for a text chunk. Only the first stage takes picture rows.
  • A prompt with pictures does not give way to a shorter request (as before), and the engine ignores a BYIELD during its read (with a log line) instead of stopping a run that would not be resumed.
  • STRATA_PIPED_CONCURRENT_PICTURES=0 keeps the usual way, for an A/B.

The embeddings, the conversation cache's picture keys and the vision encoder are untouched. The default path differs in one line only: the gather's run size, which batch_read_test checks equals the old expression for every row width up to 8 MiB.

Validation

Passed:

  • Build, 0.2.0-beta (main e88ee39d) + this commit (b3e7d696), Windows 11, MSVC 2022, CUDA 13.0, sm_120: cmake --build <dir> --target batch_read_test strata and batch_read_test.exe -> batch_read_test: ok. The same for main e88ee39d (control engine).
  • 2x RTX 5090 (Windows 11), Swift 1.5 IQ3_S, --layer-split 25 --trim-stage-weights --batch 6 --batch-groups 2 --resident-experts --kv-resident 32768, the vision encoder on GPU 0 (the same encoder binary in every arm), a fresh engine per arm, temperature 0. A cold prompt of about 49,800 tokens with one picture, read alone, then beside four decoding streams (D arms once, P arms twice). Order D0, D1, P0, P1, P1b:
main, default (D0) this, default (D1) CONCURRENT=1, PICTURES=0 (P0) CONCURRENT=1, this (P1, P1b)
each stream during the read 6.1-6.4 tok/s 5.9-6.0 tok/s 6.0-7.1 tok/s 20.8-23.7 tok/s
longest pause of a stream 5.74-5.75 s 6.00 s 5.66-5.67 s 0.14-0.43 s
picture prompt beside the streams, first token 6.21 s 6.46 s 6.13, 6.16 s 6.60, 6.65, 6.70, 6.65 s
picture prompt alone, first token 6.34 s 6.33 s 8.90 s 10.29, 6.44 s

The engine logged each concurrent picture read as about 49,890 tokens in 6.13-6.21 s with the slots decoding 71-77 rows/s meanwhile; P1b then read six more picture prompts beside the four streams (6.70-6.90 s to the first token). No stall or error lines in any arm.

  • Exactness: the picture answer was the same in every arm in each position (alone: all five; beside, round 1: all five; round 2: P0, P1 and P1b).
  • Before the rebase, on 0.1.45 (477ac13c), same rig: streams 33.9-36.8 against 4.5-6.1 tok/s, pause 0.07-0.16 s against 5.9-6.0 s; HIP on Windows (gfx1100): the engine and batch_read_test built and passed; Linux (gcc 13.3, CUDA 13.0 headers): prefill.cpp and generate.cpp compiled.

Failed: none observed.

Not run: HIP, Linux and SYCL builds on 0.2.0 (done on 0.1.45 only; SYCL never: no oneAPI here); AMD or Linux on a GPU; Mac (no concurrent read there); --mtp with pictures; --batch-groups 1.

Limits

  • The prompt with pictures waits about 0.5 s longer for its first token when slots decode beside it (6.6-6.7 s against 6.1-6.2 s for 50K tokens beside four streams): its read shares the GPUs with them. The solo first token was 8.9 s in P0 (without this change) and 10.3 s in P1, against 6.3-6.4 s in D0, D1 and P1b: the first prompt after the engine start, not reproduced in P1b with the same settings.
  • About 16 MiB more pinned RAM on the first device, once, the first time a prompt with pictures is read this way.
  • A prompt with pictures still never gives way to a shorter request. The image-position table stays one per device (#1242).

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/2989 **Author:** [@SuperDistance](https://github.com/SuperDistance) **Created:** 10/18/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `pr/piped-concurrent-pictures` --- ### 📝 Commits (1) - [`b3e7d69`](https://github.com/Niko1221/Strata/commit/b3e7d696abd6bbe4e8b359b0e69119876604a159) batch-groups: the concurrent read takes prompts with pictures too ### 📊 Changes **6 files changed** (+116 additions, -23 deletions) <details> <summary>View changed files</summary> 📝 `docs/BATCHING.md` (+4 -2) 📝 `include/strata/prefill/prefill.hpp` (+6 -5) ➕ `include/strata/prefill/prompt_uploads.hpp` (+34 -0) 📝 `src/prefill/prefill.cpp` (+9 -9) 📝 `src/program/generate.cpp` (+18 -6) 📝 `tests/program/batch_read_test.cpp` (+45 -1) </details> ### 📄 Description ## Problem and result With `STRATA_PIPED_CONCURRENT=1` a text prompt is read on a thread of its own while the other slots keep decoding, but a prompt with pictures is still read the usual way, so every slot stops for it (docs/BATCHING.md: "A prompt with pictures is read the usual way"). Coding agents send screenshots, and 0.2.0 turns pictures on by default. With this change a prompt with pictures is read the same way as a text prompt. On 0.2.0-beta, 2x RTX 5090, while a 50K-token prompt with a picture is read beside four decoding streams, the streams keep 20.8-23.7 tok/s instead of 6.0-7.1 tok/s and their longest pause goes from 5.7 s to 0.14-0.43 s. Without `STRATA_PIPED_CONCURRENT=1` nothing changes. ## Related discussion #2326 (the concurrent read; in main since 0.1.45). #1242 (the per-device image-position table; not touched here). Rebased onto 0.2.0-beta (no conflicts) after the tracker reset; the earlier description's 0.1.45 numbers are kept under Validation. ## Approach Pictures were kept out because a picture's rows go up through the prompt path's pinned ring (`core::PinnedRing`, #1996), whose size was taken to be known only at the upload; the read's thread could then grow a slot, and a pinned allocation takes the driver's lock (#31). That size is bounded: the gather sends a picture's rows in runs of at most 4 MiB. - `include/strata/prefill/prompt_uploads.hpp` (new, header-only arithmetic): `picture_run_rows()` is the gather's run (the same expression as before), `prompt_upload_bytes()` the largest upload a chunk can send, pictures included. - Before a concurrent read, `Prefill::reserve_uploads(T, pictures)` grows the ring to that, as the concurrent read already does for a text chunk. Only the first stage takes picture rows. - A prompt with pictures does not give way to a shorter request (as before), and the engine ignores a `BYIELD` during its read (with a log line) instead of stopping a run that would not be resumed. - `STRATA_PIPED_CONCURRENT_PICTURES=0` keeps the usual way, for an A/B. The embeddings, the conversation cache's picture keys and the vision encoder are untouched. The default path differs in one line only: the gather's run size, which `batch_read_test` checks equals the old expression for every row width up to 8 MiB. ## Validation **Passed:** - Build, 0.2.0-beta (main e88ee39d) + this commit (b3e7d696), Windows 11, MSVC 2022, CUDA 13.0, sm_120: `cmake --build <dir> --target batch_read_test strata` and `batch_read_test.exe` -> `batch_read_test: ok`. The same for main e88ee39d (control engine). - 2x RTX 5090 (Windows 11), Swift 1.5 IQ3_S, `--layer-split 25 --trim-stage-weights --batch 6 --batch-groups 2 --resident-experts --kv-resident 32768`, the vision encoder on GPU 0 (the same encoder binary in every arm), a fresh engine per arm, temperature 0. A cold prompt of about 49,800 tokens with one picture, read alone, then beside four decoding streams (D arms once, P arms twice). Order D0, D1, P0, P1, P1b: | | main, default (D0) | this, default (D1) | `CONCURRENT=1`, `PICTURES=0` (P0) | `CONCURRENT=1`, this (P1, P1b) | | --- | ---: | ---: | ---: | ---: | | each stream during the read | 6.1-6.4 tok/s | 5.9-6.0 tok/s | 6.0-7.1 tok/s | 20.8-23.7 tok/s | | longest pause of a stream | 5.74-5.75 s | 6.00 s | 5.66-5.67 s | 0.14-0.43 s | | picture prompt beside the streams, first token | 6.21 s | 6.46 s | 6.13, 6.16 s | 6.60, 6.65, 6.70, 6.65 s | | picture prompt alone, first token | 6.34 s | 6.33 s | 8.90 s | 10.29, 6.44 s | The engine logged each concurrent picture read as about 49,890 tokens in 6.13-6.21 s with the slots decoding 71-77 rows/s meanwhile; P1b then read six more picture prompts beside the four streams (6.70-6.90 s to the first token). No stall or error lines in any arm. - Exactness: the picture answer was the same in every arm in each position (alone: all five; beside, round 1: all five; round 2: P0, P1 and P1b). - Before the rebase, on 0.1.45 (477ac13c), same rig: streams 33.9-36.8 against 4.5-6.1 tok/s, pause 0.07-0.16 s against 5.9-6.0 s; HIP on Windows (gfx1100): the engine and `batch_read_test` built and passed; Linux (gcc 13.3, CUDA 13.0 headers): `prefill.cpp` and `generate.cpp` compiled. **Failed:** none observed. **Not run:** HIP, Linux and SYCL builds on 0.2.0 (done on 0.1.45 only; SYCL never: no oneAPI here); AMD or Linux on a GPU; Mac (no concurrent read there); `--mtp` with pictures; `--batch-groups 1`. ## Limits - The prompt with pictures waits about 0.5 s longer for its first token when slots decode beside it (6.6-6.7 s against 6.1-6.2 s for 50K tokens beside four streams): its read shares the GPUs with them. The solo first token was 8.9 s in P0 (without this change) and 10.3 s in P1, against 6.3-6.4 s in D0, D1 and P1b: the first prompt after the engine start, not reproduced in P1b with the same settings. - About 16 MiB more pinned RAM on the first device, once, the first time a prompt with pictures is read this way. - A prompt with pictures still never gives way to a shorter request. The image-position table stays one per device (#1242). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
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#4384
No description provided.