[PR #229] [CLOSED] multi-GPU: second GPU as an opt-in expert-cache tier with P2P rows (--peer-device), part 1 of #204 #2516

Closed
opened 2026-11-04 02:00:54 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/229
Author: @q8atnight
Created: 9/30/2026
Status: ❌ Closed

Base: main ← Head: pr/peer-tier


📝 Commits (1)

  • 5c134ef multi-GPU: a second GPU as an opt-in expert-cache tier (--peer-device N): adaptive peer cache, rows over P2P, the peer computes its experts' prompt rows (compact buffers, pipelined out, streaming ring); default output unchanged

📊 Changes

12 files changed (+1083 additions, -16 deletions)

View changed files

📝 CMakeLists.txt (+1 -1)
📝 include/strata/core/expert_source.hpp (+4 -0)
➕ include/strata/core/peer_experts.hpp (+101 -0)
📝 include/strata/kernels/elementwise.hpp (+2 -0)
📝 include/strata/prefill/prefill.hpp (+7 -0)
📝 src/core/expert_source.cpp (+32 -4)
📝 src/core/mtp.cpp (+1 -1)
➕ src/core/peer_experts.cpp (+320 -0)
📝 src/core/verify.cpp (+1 -1)
📝 src/kernels/cuda/elementwise.cu (+17 -0)
📝 src/prefill/prefill.cpp (+512 -8)
📝 src/program/generate.cpp (+85 -1)

📄 Description

Part 1 of the peer-tier plan agreed in #204: a second GPU as an opt-in expert-cache tier beside --gpus. Part 2 (the QSA query split) is not included — see the note at the end.

What it does (only with --peer-device N)

  • Second expert-cache tier on GPU N: an adaptive cache of its own, filled from the profile after the primary's cache; decode rows come back through the pool's mapped rows (the verify graph is untouched).
  • P2P rows in the prompt path: the peer computes its experts' rows of each prompt chunk (activations in / rows out over P2P), with compact group buffers, the rows returned group by group on a second stream, and a streaming ring that lets the peer stream a share of the primary's streamed experts over its own PCIe link.
  • Peer rows are scattered straight into the pool's mapped rows (those buffers are now cudaHostAllocPortable, the only unconditional change — no behaviour change without a peer).

New flags: --peer-device N (default -1 = off), --peer-reserve-mib (600), --peer-slots (0 = auto), --peer-adapt-swaps (-1), --peer-prefill-rows (-1 = chunk×K/2, 0 = off).
Env switches, all only read when a peer is active: STRATA_PF_PEER_OUT_PIPE, STRATA_PF_PEER_COMPACT, STRATA_PF_PEER_STREAM (0.35), STRATA_PF_PEER_RING (48), STRATA_PEER_DIRECT, STRATA_PEER_HOT (0.45), STRATA_PEER_HOT_AT.

Rebased on 0.1.28; upstream's --expert-cache-device1..3 tier, the D-5 issuer thread and D-1 attention are left intact.

Exactness (#152 method)

Env trio STRATA_NO_IQ512=1 STRATA_NO_IQ256=1 STRATA_NO_IQ4NL=1 + no-stream-k MMQ (local debug patch), greedy, the three gate prompts (chat / code / math), IQ3_S:

  • Default path (no --peer-device) vs plain 0.1.28: byte-identical (PASS).
  • Peer on vs single GPU with the same GPU expert set (single --expert-cache 7846 slots; peer run 3896 primary + 3950 peer, static, STRATA_PEER_HOT=0): byte-identical (PASS).
setup prefill 32K (tok/s) decode 1K decode 32K
single GPU (auto cache) 2,094 91.5 88.8
--gpu1-experts (--expert-cache-device1 10000) 1,425 88.8 86.4
layer split (--layer-split auto) 936 104.2 94.9
this PR (--peer-device 1, auto) 2,566 106.5 106.7

(Peer run: 8,692 primary + 11,168 peer = 19,860 of 24,576 experts on the GPUs. One run per cell.)

About part 2 (QSA query split)

We ported it too, but on 0.1.28 it does not meet the bar: prefill attention now uses the D-1 tensor-core kernel, which our split cannot divide mid-chunk, so the split falls back to the older kernel — not byte-identical, and slower than this PR alone (2,125 vs 2,566 at 32K). So it's left out. We might come back with a redesign that keeps D-1 on both cards; if so it will be a separate PR against this one.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/229 **Author:** [@q8atnight](https://github.com/q8atnight) **Created:** 9/30/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `pr/peer-tier` --- ### 📝 Commits (1) - [`5c134ef`](https://github.com/Niko1221/Strata/commit/5c134ef44506c4fbdb61b56b54a75cb72b699f42) multi-GPU: a second GPU as an opt-in expert-cache tier (--peer-device N): adaptive peer cache, rows over P2P, the peer computes its experts' prompt rows (compact buffers, pipelined out, streaming ring); default output unchanged ### 📊 Changes **12 files changed** (+1083 additions, -16 deletions) <details> <summary>View changed files</summary> 📝 `CMakeLists.txt` (+1 -1) 📝 `include/strata/core/expert_source.hpp` (+4 -0) ➕ `include/strata/core/peer_experts.hpp` (+101 -0) 📝 `include/strata/kernels/elementwise.hpp` (+2 -0) 📝 `include/strata/prefill/prefill.hpp` (+7 -0) 📝 `src/core/expert_source.cpp` (+32 -4) 📝 `src/core/mtp.cpp` (+1 -1) ➕ `src/core/peer_experts.cpp` (+320 -0) 📝 `src/core/verify.cpp` (+1 -1) 📝 `src/kernels/cuda/elementwise.cu` (+17 -0) 📝 `src/prefill/prefill.cpp` (+512 -8) 📝 `src/program/generate.cpp` (+85 -1) </details> ### 📄 Description Part 1 of the peer-tier plan agreed in #204: a second GPU as an **opt-in** expert-cache tier beside `--gpus`. Part 2 (the QSA query split) is not included — see the note at the end. ## What it does (only with `--peer-device N`) - **Second expert-cache tier** on GPU N: an adaptive cache of its own, filled from the profile after the primary's cache; decode rows come back through the pool's mapped rows (the verify graph is untouched). - **P2P rows in the prompt path**: the peer computes its experts' rows of each prompt chunk (activations in / rows out over P2P), with compact group buffers, the rows returned group by group on a second stream, and a streaming ring that lets the peer stream a share of the primary's streamed experts over its own PCIe link. - Peer rows are scattered straight into the pool's mapped rows (those buffers are now `cudaHostAllocPortable`, the only unconditional change — no behaviour change without a peer). New flags: `--peer-device N` (default -1 = off), `--peer-reserve-mib` (600), `--peer-slots` (0 = auto), `--peer-adapt-swaps` (-1), `--peer-prefill-rows` (-1 = chunk×K/2, 0 = off). Env switches, all only read when a peer is active: `STRATA_PF_PEER_OUT_PIPE`, `STRATA_PF_PEER_COMPACT`, `STRATA_PF_PEER_STREAM` (0.35), `STRATA_PF_PEER_RING` (48), `STRATA_PEER_DIRECT`, `STRATA_PEER_HOT` (0.45), `STRATA_PEER_HOT_AT`. Rebased on 0.1.28; upstream's `--expert-cache-device1..3` tier, the D-5 issuer thread and D-1 attention are left intact. ## Exactness (#152 method) Env trio `STRATA_NO_IQ512=1 STRATA_NO_IQ256=1 STRATA_NO_IQ4NL=1` + no-stream-k MMQ (local debug patch), greedy, the three gate prompts (chat / code / math), IQ3_S: - **Default path (no `--peer-device`) vs plain 0.1.28: byte-identical (PASS).** - **Peer on vs single GPU with the same GPU expert set** (single `--expert-cache` 7846 slots; peer run 3896 primary + 3950 peer, static, `STRATA_PEER_HOT=0`): **byte-identical (PASS).** ## Numbers — 2× RTX 3090 (NVLink), IQ3_S, 0.1.28 base, flashbench `--quick` (greedy) | setup | prefill 32K (tok/s) | decode 1K | decode 32K | | --- | ---: | ---: | ---: | | single GPU (auto cache) | 2,094 | 91.5 | 88.8 | | `--gpu1-experts` (`--expert-cache-device1 10000`) | 1,425 | 88.8 | 86.4 | | layer split (`--layer-split auto`) | 936 | 104.2 | 94.9 | | **this PR (`--peer-device 1`, auto)** | **2,566** | **106.5** | **106.7** | (Peer run: 8,692 primary + 11,168 peer = 19,860 of 24,576 experts on the GPUs. One run per cell.) ## About part 2 (QSA query split) We ported it too, but on 0.1.28 it does not meet the bar: prefill attention now uses the D-1 tensor-core kernel, which our split cannot divide mid-chunk, so the split falls back to the older kernel — not byte-identical, and slower than this PR alone (2,125 vs 2,566 at 32K). So it's left out. We might come back with a redesign that keeps D-1 on both cards; if so it will be a separate PR against this one. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-04 02:00:54 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#2516
No description provided.