mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #5002] [Engine] prompt path: opt-in dual data-parallel prompt read for two-GPU layer splits (STRATA_DP_PREFILL) #5284
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#5284
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/5002
Author: @orochifj
Created: 11/2/2026
Status: 🔄 Open
Base:
main← Head:pr/dp-prompt-path📝 Commits (4)
634dc2f[Engine] prompt path: opt-in dual data-parallel prompt read for two-GPU layer splits (STRATA_DP_PREFILL)e64a076[Engine] prompt path: the DP read stays off with --draft dflash28b0c63edocs: the DP prompt path's limits - checkpoints, DFlash2, and what STRATA_KV_HOST_DMA does on CUDAd4fbe2d[Engine] prompt path: the DP read stays off when the spill walk trims the stage weights📊 Changes
8 files changed (+603 additions, -28 deletions)
View changed files
📝
docs/MULTI_GPU.md(+53 -0)📝
include/strata/core/layer.hpp(+3 -1)📝
include/strata/core/session.hpp(+3 -1)📝
include/strata/prefill/prefill.hpp(+29 -0)📝
src/core/layer.cpp(+2 -2)📝
src/core/session.cpp(+2 -2)📝
src/prefill/prefill.cpp(+337 -22)📝
src/program/generate.cpp(+174 -0)📄 Description
Problem and result
On a two-GPU layer split a long prompt is read by the layer pipeline, and on 24 GB cards the layer-major walk does not run (2x RTX 3090:
no VRAM for a super-chunk, 587 MiB free). WithSTRATA_DP_PREFILL=1both cards read the prompt at once: each runs every layer on every other chunk and hands each layer's state to the other card. Measured on 2x RTX 3090: prompts of 12K-123K tokens read 16-67 % faster (engine timing, medians of three alternating rounds). The cost: the extra sessions take 308 expert-cache slots a card, so prompts DP does not take (1.5K-4K) read up to 4 % slower. Unset, nothing changes.Rebased onto v0.2.11 on 2026-11-06 (engine 0.1.57). One commit is new: 0.2.11's layer-split spill walk can trim a short card's dense weights by itself, and the DP read now stays off for that trim too. Since v0.2.10 it also stays off with
--draft dflash2, and the limits below take in what the review found. The speed table was measured on the v0.2.9 base and has not been re-run. On 0.2.11 we ran a local build that carries this path plus our own changes. On the same 2x RTX 3090 it read 43K-123K prompts at the same speed as on 0.2.10 (5,118-5,312 against 5,158-5,347 tok/s).Related discussion
Opened as a draft so the code can be read beside #4875: it waits for your scope decision there and is not asking to be merged before that.
#4875: the proposal, the scope of this first PR, and rafatxf's findings on a low-RAM 2x RTX 2080 Ti box. The design is nicejunjie's (nicejunjie/Strata-rdna3, MIT); he asked to be co-author, and the commit carries his
Co-authored-by. rafatxf has the peer-slot residency for low-RAM boxes and DP with stage trim on rafatxf/Stratadp-followups(one commit each; rebased onto the v0.2.10 head of this PR, so it needs a rebase onto this one). lyesrock ran it on 2x Tesla P40 without peer access: DP linked and read 16K prompts about 19 % faster once warm.Approach
session_init/qsa_state_inittakekv_host(default true). #4875 measured 2.3 GiB of pinned RAM thrown away at 384K without this, and a 13-19 % decode loss on a 56 GB box. The stage's foreign session holds layer 1, so it gets its own PLE run.Prefill::run_dpcuts a segment into an even number of balanced chunks (multiples of 256, at most the prompt chunk). The last one runs on the drafter's card and has at least 4224 tokens.run_implwalks the plan's boundaries in place of its per-run chunk (step_at/next_mine), skips the other card's chunks, and bypasses the layer-major walk.cudaMemcpyPeerAsyncon its stream and records a per-layer event: the GDN state, the chunk's indexer rows, the indexer tail, dead slot and block position, and the PLE history at layer 1. Chunk k+1 waits for it, on the host through a condition variable and on the device withcudaStreamWaitEvent. The foreign sessions start each prompt from the owners' state at its start position.STRATA_DP_MIN(8000) tokens whose plan qualifies is read by DP, after a head up to the next K/V block boundary. Anything else, and a continuation that starts inside a K/V block, goes to the layer pipeline as before.--batch,--peer-device, stage trim (asked for, or the spill walk's on a short card),--draft dflash2(its prompt taps are kept per card, while a DP read runs every layer on one card), K/V not streamed orSTRATA_KV_HOST_DMAnot 1, or not every expert in RAM (--mmap-experts,--resident-experts, a file-backed arena that hands the GPU-held experts back). A DP read streams the experts the other card caches, which there would come from the model file (#4875: 82 GB read for a 16K prompt).docs/MULTI_GPU.md: the switch, how it works, its limits and the measurements.Validation
Passed
86-real;86-virtualwith the Dockerfile's CMake options plus-DSTRATA_BUILD_TESTS=ON -DSTRATA_BUILD_CONVERSATION_TESTS=ON: engine andconversation_validation_test(972 host-only checks passed).-DSTRATA_ENABLE_HIP=ON -DSTRATA_ENABLE_CUDA=OFF -DCMAKE_HIP_ARCHITECTURES=gfx1201in a ROCm 10.1 (HIP 7.16) container: the engine builds and links.serve/server.py, 2026-11-02:--max-context 524288 --rope-scaling yarn --rope-scale 2 --kv int8 --kv-resident 32768 --spec 4 --spec-min-p 0.5 --pipeline-windows 2 --pcie-frac 0, envSTRATA_KV_HOST_DMA=1 STRATA_PREFILL_AUTO_MAX=16384 STRATA_HC_Q8=1 STRATA_ROUTE_TAIL_SKIP=0 STRATA_DECODE_TIMING=1in both arms. The only change between arms isSTRATA_DP_PREFILL=1.max_tokens1. Two reads per size up to 12K, one per size from 19K, three rounds ordered A B / B A / A B.strata serve: prompt N tokens = 0 reused + N read in X msline, tokens/s, median (min-max):STRATA_DP_PREFILL=1kv_hostfalse they would add their own.STRATA_QSA_DUMPfiles (1,622,817,216 bytes, sha1 a4cb2cf7). Its bits differ from the layer pipeline's, because the chunk boundaries differ.STRATA_DP_PREFILL=1with--mmap-expertslogsSTRATA_DP_PREFILL is off: a DP read streams the experts the other GPU caches, ...and serves through the layer pipeline.Measured limit (not a failure): the drafter gap. Only the drafter card's chunks reach the draft layer, so after a DP read its cells for the other card's chunks are not filled. Test: a ~48K-token prompt of C++ source and an answer that copies 30 of its lines, greedy, six requests per cell:
The tokens are the target's either way. Feeding the other card's final rows to the drafter would close this gap; it is left for a follow-up.
Failed: none observed.
Not run
STRATA_HIP_GFX906): every changed file compiles, but the link stops insrc/core/dflash2.cpp, which this PR does not touch:hip_compat/strata_hip.hhas nocudaDeviceGetStreamPriorityRange/cudaStreamCreateWithPriority. It fails the same way on main.Limits
--batchslots yet, not with stage trim (rafatxf's follow-up), and off with--draft dflash2. Two cards only.run_dpclearson_stage_chunk, which a layer split's mid-prompt checkpoints come from (rafatxf: 1 checkpoint against the pipeline's 4 on a 64K read). A turn that extends the conversation is unaffected; an edited earlier message, a regenerate or a compaction reads from the start again.STRATA_KV_HOST_DMA=1is one of DP's conditions. On CUDA it selects nothing else (its K/V append, one DMA a chunk to the host copy, is HIP-only), so it costs nothing where DP does not run.Prepared with AI assistance (Claude); every measurement above comes from the runs described, and the logs are available.
🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.