mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[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
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#4384
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 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)
b3e7d69batch-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=1a 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. WithoutSTRATA_PIPED_CONCURRENT=1nothing 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.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.BYIELDduring its read (with a log line) instead of stopping a run that would not be resumed.STRATA_PIPED_CONCURRENT_PICTURES=0keeps 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_testchecks equals the old expression for every row width up to 8 MiB.Validation
Passed:
e88ee39d) + this commit (b3e7d696), Windows 11, MSVC 2022, CUDA 13.0, sm_120:cmake --build <dir> --target batch_read_test strataandbatch_read_test.exe->batch_read_test: ok. The same for maine88ee39d(control engine).--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:CONCURRENT=1,PICTURES=0(P0)CONCURRENT=1, this (P1, P1b)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.
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 andbatch_read_testbuilt and passed; Linux (gcc 13.3, CUDA 13.0 headers):prefill.cppandgenerate.cppcompiled.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);
--mtpwith pictures;--batch-groups 1.Limits
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.