mirror of
https://github.com/mw00/project-maya.git
synced 2026-12-03 21:08:26 +07:00
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
mw00/project-maya#609
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/mw00/project-maya/pull/587
Author: @mrsirg97-rgb
Created: 10/28/2026
Status: ❌ Closed
Base:
main← Head:ds4-pieces📝 Commits (4)
1b3c66cDeepSeek --parallel: prompts read a piece at a time (a chunk per pipeline stage), every answer a token between pieces, a one-piece prompt ahead of longer reads; MAYA_DS4_READ_ORDER=arrival keeps the old order. agent_bench 4x8 on 3 GPUs: first token 5.23 s mean / 13.5 s p95 against 6.14 / 29.1, turn done and wall the same; parallel_test --lanes 4 token for token8185908DeepSeek --parallel on events (ds4_evt.hpp, #557's): the reader's lines and the turns - a round of tokens or a prompt's piece - each queueing the next; a line outranks a turn, nothing polls (Lines::poll goes). parallel_test --lanes 4 and 2 every check; agent_bench 4x8 first token 5.20 s mean / 13.4 s p95, wall 190.3 s (as before)e90b747DeepSeek --parallel: a prompt read alone goes in one run and yields to a request at the next chunk all stages reach (Model::set_yield: the Stop's cut, keeping what it read); a piece tells the model how much of its prompt follows, so the long prompt's skip counts from the prompt's end; MAYA_DS4_READ_PIECE (chunks a stage) and MAYA_DS4_READ_ROUNDS (tokens each between pieces). 3 GPUs: a 101K prompt alone 49.2 s, against 58.7 s before and 49.1 s read whole; a question 5 s into it, first token 19.3 s (47 s read whole); parallel_test --lanes 4 and 2 every check; agent_bench 4x8 first token 5.21 s mean / 13.6 s p95, wall 190.4 s (as before)86a3757DeepSeek --parallel: a yield lands sooner - in a run that may yield, no GPU starts chunk k before chunk k - (stages + 1) is through every layer (a host ran ~2 chunks ahead of its GPU and each stage ~2 ahead of the next: the cut came 5 chunks past the done ones); MAYA_DS4_READ_SHARE= lets running answers write for that share of the time between pieces (off: on agent_bench it made first tokens later). 3 GPUs: a question 5 s into a 101K read, first token 15.7 s (19.3 s before); the read alone 49.0 s; agent_bench 4x8 first token 5.27 s mean / 13.6 s p95, wall 188.2 s; parallel_test --lanes 4 and 2 every check📊 Changes
7 files changed (+1266 additions, -126 deletions)
View changed files
📝
docs/SETTINGS.md(+22 -3)➕
src/ds4/ds4_evt.hpp(+162 -0)📝
src/ds4/ds4_main.cpp(+298 -104)📝
src/ds4/ds4_model.cu(+68 -17)📝
src/ds4/ds4_model.hpp(+12 -2)➕
tools/ds4/agent_bench.py(+283 -0)➕
tools/ds4/parallel_test.py(+421 -0)📄 Description
#557's event scheduler on v1.1.34's batched
--parallel, as discussed in #557.The loop runs on events (
ds4_evt.hpp). The reader's lines and the turns are eventsrun one at a time; a line outranks a turn, each turn queues the next as it ends, and with nothing running the loop
waits for a line instead of polling between steps.
What it schedules: in v1.1.34 a new request's prompt is read whole while every other conversation waits. Now the
prompts being read take turns, a piece each - a chunk per pipeline stage, so a split's GPUs all stay busy - and
every running request writes a token (one
step_multi) between two pieces. A prompt whole in one piece goes ahead ofthe longer reads, so a short question doesn't wait behind them.
MAYA_DS4_READ_ORDER=arrivalkeeps v1.1.34's orderfor A/B runs.
Results
3 GPUs (2x RTX 5090 + RTX 3090, layer split), DeepSeek-V4.1-Flash GSQ-RCO IQ2_XXS (about half the experts in RAM),
--parallel 4, the same binary for both rows.Agent workload (
tools/ds4/agent_bench.py: 4 agents x 8 turns at once - 4-12K-token first prompts, tool results of150-2,000 tokens, one in ten 5-20K, answers of 64-400 tokens, 0.5-5 s of tool time between):
MAYA_DS4_READ_ORDER=arrival)The first token 15% sooner on the mean and 2.2x sooner at p95; a turn done and the wall the same. A second run of
the default gave 5.22 / 13.5 / 190.4, and the final build (the loop on events) 5.20 / 13.4 / 190.3: v1.1.34 hands
every answer's token back in one call, so the events change the shape, not these numbers - they are what the in-read
gaps (below) build on. Pieces of one chunk were slower (first token 7.13 s, wall 212.1 s): every piece
fills the pipeline again, so a piece is a chunk per stage.
Real agent traffic (
--trace: a 10-minute window of rig's.servedlog, 4 conversations, 73 turns, a turn's newtokens median 235): a tie, first token 1.91 against 1.86 s, wall 473.5 against 473.6 s. Nearly every turn there fits
in one piece, so pieces and whole reads are the same reads; the gain is where long prompts meet.
What's in it
src/ds4/ds4_main.cpp: the prompt reader in three steps -prompt_begin(pictures, reuse, slots),prompt_piece(the next tokens, PP lines, a STOP),prompt_end(checkpoints). The one-conversation path callsthem back to back, as before. In
--parallela request's prompt is begun at admission and read in turn; a STOPwhile it waits for its turn ends it there and keeps the conversation it continued. A prompt with pictures is read
whole (the images the model holds are not per conversation).
src/ds4/ds4_evt.hpp(#557's, rig's evt in C++, 140 lines): the--parallelloop runs on its events - thereader's lines, and the turns (a round of tokens or a prompt's piece), each queueing the next as it ends. A line
outranks a turn, so every request that came is admitted before the next turn; with nothing running the loop waits
for a line instead of polling.
Lines::pollgoes (nothing reads between steps any more).Model::prompt_chunk()andModel::pipeline_stages()(the piece's size).docs/SETTINGS.md: the DeepSeek--parallelsection.tools/ds4/parallel_test.pyandtools/ds4/agent_bench.pyfrom #557 (the checks and the tables above), trimmed tothis engine.
Each piece is a whole number of the uncut read's chunks, so a prompt reads through the same chunk boundaries as before.
Tested
tools/ds4/parallel_test.py --lanes 4and--lanes 2(greedy): the conversations at once each answer token for token what theyanswer alone; a STOP ends one alone and the other's answer is whole and its own; a kept conversation's next turn
reuses its lane (2023 of 2032 tokens); a small request sent during a ~100K-token read gets 4 of its 16 tokens before
the read's last piece (with
arrivalthe long prompt is read whole before the small one starts).tools/test_ds4_*.pyandtools/test_maya_parallel.py.Next, if wanted
#557 also decoded inside a piece (the answers' gaps at a read's chunk boundaries), which is the rest of the first-token
gain on the agent workload and why its reading check got 16 of 16; that needs
ds4_model.cuand would be its own PR.With the loop on events, those gaps are one more event: a read's chunk boundary hands the devices to a round.
Reproducing
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.