mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #3648] [Engine] --peer-device host route: STRATA_PF_PEER_PIECES=1 (opt-in) moves the activations and the sums in 8 pieces (+7 % prompt on 2x V100) #4734
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#4734
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/3648
Author: @fks
Created: 10/21/2026
Status: 🔄 Open
Base:
main← Head:feature/peer-early-x📝 Commits (2)
d9b8da9prefill (--peer-device, host route): STRATA_PF_PEER_PIECES=1 moves the activations and the sums in 8 pieces59a55d5docs, bench: STRATA_PF_PEER_PIECES on 2x V100 (host route)📊 Changes
15 files changed (+618 additions, -9 deletions)
View changed files
➕
bench/results/2026-10-21-peer-pieces/README.md(+80 -0)➕
bench/results/2026-10-21-peer-pieces/engine-logs/fin_off-1-t.txt(+67 -0)➕
bench/results/2026-10-21-peer-pieces/engine-logs/fin_off-1.txt(+59 -0)➕
bench/results/2026-10-21-peer-pieces/engine-logs/fin_on-0-smoke.txt(+60 -0)➕
bench/results/2026-10-21-peer-pieces/engine-logs/fin_on-1-t.txt(+67 -0)➕
bench/results/2026-10-21-peer-pieces/engine-logs/fin_on-1.txt(+59 -0)➕
bench/results/2026-10-21-peer-pieces/logpos-vs-main-P2P.txt(+10 -0)➕
bench/results/2026-10-21-peer-pieces/logpos-vs-main-noP2P.txt(+19 -0)➕
bench/results/2026-10-21-peer-pieces/runs.jsonl(+16 -0)➕
bench/results/2026-10-21-peer-pieces/scripts/abpr.py(+29 -0)➕
bench/results/2026-10-21-peer-pieces/scripts/logpos_compare.py(+41 -0)➕
bench/results/2026-10-21-peer-pieces/scripts/lp.py(+22 -0)📝
docs/SECOND_GPU.md(+6 -0)📝
src/prefill/kernels.cu(+2 -2)📝
src/prefill/prefill.cpp(+81 -7)📄 Description
Problem and result
With
--peer-deviceand no P2P between the two cards, every MoE layer of a prompt chunk makes two transfers through mapped host memory. This is the host route:STRATA_PEER_NO_P2P=1, or a pair whose P2P test fails (#2666). The primary waits through both transfers:With
STRATA_PF_PEER_PIECES=1(opt-in), both transfers go in 8 pieces. The activations start down before the router, and the peer converts each piece as it lands, while the router, the shared expert and the host grouping still run. The sums come back piece by piece, and the primary copies each piece into its own memory as it lands.On 2x Tesla V100-PCIE-32GB without P2P (Qwen3.8-Flash-Next IQ3_S, 16,384-token chunks):
STRATA_PF_PEER_PIECES=1The values are medians of 4 rounds. The combine phase, which includes the wait for the peer, went from 3,131 to 1,196 ms on a 37,808-token prompt. The output is bit for bit the same as
main's. Without the variable, and on the P2P route, nothing changes.Related discussion
none. The host route with per-token sums and FP16 transfers came with #1251. This adds an opt-in way to overlap its two transfers and changes no default.
Approach
x_stream) then copiesmixed_htohost_x16in 8 pieces, with an event after each piece. On the peer,f16_to_f32_wideconverts each piece intoP.mixedonce its event has fired. These are the same values the existing copy after the grouping produces, so that copy and conversion are skipped for this layer.ev_doneis therefore recorded on the peer stream after the last conversion. If the layer turns out to have no peer rows, the primary waits on that event before the next layer can overwritehost_x16ormixed_h. Otherwise the existing waits cover it.sums_to_f16per piece, then the D2H copy). A stream on the primary (s_h) reads each piece withf16_to_f32_wideintobo.bois free until the combine writes it, and the stream's first wait already orders it after the previous layer'sgr_write. The combine waits for the last piece (ev_h) and readsbothroughmoe_combine_peer. The conversions are exact (FP16 to FP32), and the additions keep their order, so the result is bit for bit the same asmoe_combine_peer16readinghost_sum16.moe_combine_peeris now called withpeer == bo, so I removed__restrict__from those two parameters. Each thread reads its element before it writes it. The kernel's other caller (FP32 sums) gives the same results.handoff_piece().Validation
All runs were on 2x Tesla V100-PCIE-32GB (PCIe 3.0 x16 each, no NVLink,
SYSinnvidia-smi topo), an Intel Core i9-7960X with 125 GiB RAM, Ubuntu (Linux 6.8.0-51), driver 550.120 and CUDA 12.8. The model was Qwen3.8-Flash-Next GSQ-RCO IQ3_S with a native pack, run with--prefill auto:16384 --kv int8 --ple-io ram --peer-device 1. The full command, the environment, the raw runs and the logs are inbench/results/2026-10-21-peer-pieces/.Passed:
main011c9e60.runs.jsonl, the medians are in the table above, and the variable was faster in every round. Earlier the same day, unchangedmainmeasured 1,596 / 1,672 tok/s on the same prompts, the same as this branch without the variable.STRATA_PREFILL_TIMING=1, one server start per arm:STRATA_LOGPOS: five prompts of ~34K/24K/16K/8K/3K tokens, top-20 log probabilities at 2,493 positions.STRATA_PEER_NO_P2P=1, this branch is bit for bit identical tomainat every position, both without and withSTRATA_PF_PEER_PIECES=1(logpos-vs-main-noP2P.txt).main(logpos-vs-main-P2P.txt).engine-logs/fin_on-0-smoke.txt).ctest -j 8in the CUDA build: 62 passed, 3 skipped, 4 failed (next list). Run alone afterwards,vmm_testandkv_window_paritypassed.Failed:
ctest -j 8:pf_wmma_parityandple_parityfail on this machine on unchangedmain011c9e60too (checked the same day), so they are not from this change; I did not investigate them.kv_window_parityfailed under-j 8on both this branch andmain, and passed when run alone on both.vmm_testfailed once under-j 8on this branch (it passed inmain's-j 8run), and passed when run alone on this branch and onmain. Both look like contention between tests sharing the GPUs; I did not investigate further.Not run:
src/prefill/prefill.cppandsrc/prefill/kernels.cuare part of them, so the change is unverified there, and this PR stays a draft until they are built.Limits
STRATA_PF_PEER_F16on, the default there). The FP32 transfers and the P2P route are unchanged.🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.