mirror of
https://github.com/mw00/project-maya.git
synced 2026-12-03 19:04:50 +07:00
[PR #641] DeepSeek --parallel, every conversation drafting: two verify windows in flight on a two-GPU layer split (MAYA_DS4_MD_PIPE, off by default) #643
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#643
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/641
Author: @somnergy
Created: 10/28/2026
Status: 🔄 Open
Base:
main← Head:pr/ds4-md-pipe📝 Commits (4)
4698ec5DeepSeek --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 token93aa1f9DeepSeek --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)9423c9fDeepSeek --parallel: every conversation drafts (MAYA_DS4_MULTI_DRAFT=1, off by default) - each answering conversation's DSpark drafts and token verified together in one window3fa3cb7DeepSeek --parallel, every conversation drafting: two verify windows in flight on a two-GPU layer split (MAYA_DS4_MD_PIPE=1, off by default) - one window's second GPU's layers and head run while the other window's first GPU's layers do📊 Changes
9 files changed (+3871 additions, -259 deletions)
View changed files
📝
docs/SETTINGS.md(+79 -4)➕
src/ds4/ds4_evt.hpp(+162 -0)📝
src/ds4/ds4_kernels.cu(+92 -0)📝
src/ds4/ds4_kernels.cuh(+7 -0)📝
src/ds4/ds4_main.cpp(+1569 -126)📝
src/ds4/ds4_model.cu(+1166 -129)📝
src/ds4/ds4_model.hpp(+70 -0)➕
tools/ds4/agent_bench.py(+283 -0)➕
tools/ds4/parallel_test.py(+443 -0)📄 Description
DeepSeek
--parallelwith every conversation drafting, on a two-GPU layer split: two verify windows in flight at once. One window's second GPU's layers and head run while the other window's first GPU's layers do. One window at a time left each GPU idle through the other's stage. Off by default (MAYA_DS4_MD_PIPE=1). Without the setting, nothing changes.Depends on #636 (every conversation drafting,
MAYA_DS4_MULTI_DRAFT), which depends on #587. Of this branch's commits, only the last is this PR: the ones before it are #587's two and #636's one, and they drop out as those are merged. Draft until #636 lands. Overlap with #611: this PR builds on the previous PR'sverify_multi/draft_multi, not #611's. If #611's core goes in instead, this would be rebased onto it.What it does
Issue and take (
Model::verify_multi_issue/verify_multi_take).verify_multi_issuemakes the window asverify_multidoes and runs its first GPU's layers.verify_multi_takeruns the second GPU's layers and the head, waits, and gives each conversation its verdict, rollback and drafter seeding exactly asverify_multidoes.A window's second stage is enqueued at the next window's issue, after the first window's logits were sampled and the drafter ran, so all three queue on the head's stream. Otherwise it is enqueued at its own take.
A slot per window (
WinPlan::pslot). Whatever a second window would collide with gets a slot of its own:Slot 0 is byte for byte where every other path has these. The rows, kernels and reduction orders are the one window's.
A request ring per GPU. Experts on the CPU lane are served through a request ring per GPU: each GPU's layers publish into their own ring, in their own sequence, and the service thread polls the rings in turn. With one ring answered in order, the second window's first-stage requests queued behind the first window's second-stage ones.
The expert cache. The cache never ticks while a window is in flight. A tick switches the host's expert tables at once and the devices' tables in stream order, queues swaps into the slot it just freed, and takes the CPU lane's hit lists from under the service thread. The serve loop holds the cache for the round (
Model::cache_hold) and ticks once at the round's end.The serve loop. The answering conversations are split into two groups. Each group has its own plan, drafter pass and window, and runs
MAYA_DS4_MD_PIPE_WINDOWS(3) windows a round: issue A, issue B, take A, issue A′, take B, issue B′, and so on. A landed window's tokens are written at once, except the last, which is the group's next window's input. A request whose next token ends it leaves its group.Pricing the overlapping windows (
MAYA_DS4_MD_PIPE_PRICE). The windows overlap, so the cost policy needs a price per window:stage(the default): the slower of the window's two stages' GPU time, from events on each GPU's stream (the second stage's wait for the first is left out), plus an equal share of what the round spent beyond the stages and the drafter.share: the round's time less the drafter's, split in proportion to the cost model's cost of each window's rows.equal: the same time in equal parts.MAYA_DS4_MD_PIPE_DRAFT_PRICE=gpuprices the drafter's passes by their GPU time instead of the host's wait for them. A pass drafted beside the other window's first stage queues behind that stage.The reference (
MAYA_DS4_MD_PIPE_SERIAL=1). It runs the same groups and windows one at a time and ticks the cache at the same points. A pipelined run must match it token for token.pipe_oksays what a layout lacks: two GPUs in threads mode, a layer split with the head second, no tensor-parallel group, a request ring per GPU, no layer streaming over the PCIe lane, no helper, no dumps. The engine prints the missing piece at start and runs one window at a time.--multi-check. The check holds the experts where the load put them for its whole run, so every comparison counts on any placement. With the setting on, its drafting phase:NOT CHECKEDif the setting is asked for and refused, rather than passing on what it did not compare.tools/ds4/parallel_test.pygains--ref-lanes N --ref-env K=V: the same comparison against a reference engine, through the serve protocol.Logs. The drafter pass's GPU time is timed (blocks and head apart). With
MAYA_DS4_MULTI_DRAFT_LOG=1:pipe:line per round and a line per window (rows, stage times, price, mode, expected rates);Memory cost: a second set of the verify backups, hand-off buffers and request rings, plus 32 logits rows.
Settings
MAYA_DS4_MD_PIPEMAYA_DS4_MULTI_DRAFT=1, a two-GPU layer split,--threads on)MAYA_DS4_MD_PIPE_WINDOWSMAYA_DS4_MD_PIPE_PRICEstagestage,shareorequalMAYA_DS4_MD_PIPE_DRAFT_PRICEwallgpu: the drafter's passes priced by their GPU timeMAYA_DS4_MD_PIPE_SERIALExactness
Each window's rows, kernels and reduction orders are the one window's, so two windows in flight give the same tokens as the same windows one at a time. Greedy, with windows of up to 8 rows, both give each conversation's tokens alone.
--multi-checkwith the setting on compares the pipe against the serial reference inside one process, plus the drafter pass in flight against the same pass with none. It holds the expert cache for the whole run, so on a CPU-lane placement every comparison counts too.parallel_test.py --ref-lanes N --ref-env MAYA_DS4_MD_PIPE_SERIAL=1there is a smoke test, not a certificate. The serving path itself never moves an expert while a window is in flight.Measured at 512K with the expert cache on, the drafter in VRAM, and ~300-540 of the trunk's experts on the CPU lane:
parallel_test.py --lanes 4and--lanes 2pass every check.Results
Setup: two 72 GB Blackwell cards (GPU peer copies at 54 GB/s each way), a 64-core Zen 4 host. DeepSeek-V4.1-Flash, IQ2_XXS GSQ-RCO pack, DSpark drafter on (in VRAM). Layer split, 512K context, ~300-540 of the trunk's experts on the CPU lane,
--parallel 4 --tp 1 --threads on,MAYA_DS4_MULTI_DRAFT=1. "Off" is the same build and settings withoutMAYA_DS4_MD_PIPE. Pooled tok/s, greedy (T=0), 1/2/3/4 conversations started together.Verdict by hardware class:
pipe_okrefuses a TP group); the previous PR's path applies.pipe_okrefuses a streaming layer).Essay (prose, ~60% of drafts kept)
MAYA_DS4_MD_PIPE_SERIAL=1)Copy prompt (~95-100% of drafts kept)
Coding-agent windows. Each run is 6 minutes: 32-64K-token code prompts, 700-token answers, T 0.7. The table gives the tokens written in all; "pipe on" is the range over the runs.
Window pricing (
MAYA_DS4_MD_PIPE_PRICE). The same build in each mode; pooled tok/s greedy, then the coding-agent windows (tokens written, two runs each):stage(default)equalsharestage,DRAFT_PRICE=gpuThe modes agree within run-to-run noise here: one mode's two runs differ by up to 4,000 tokens, more than any gap between modes.
stagestays the default because it prices each window by what it used. Other hardware, where the two stages are less even, may separate them.Suggested settings
MAYA_DS4_MULTI_DRAFT=1 MAYA_DS4_MD_PIPE=1,--threads onMAYA_DS4_MULTI_DRAFT=1)Not in this PR
MAYA_DS4_MD_PIPE_WINDOWS=3amortizes that.Checks
maya-ds4(sm_120, CUDA 13.4) with no new warnings.tools/check_hip_compat.py: passes.serve/test_multi.py(13),tools/test_maya_parallel.py(11) andtools/test_ds4*.py(33) pass.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.