prefill: the no-P2P peer share sends each token's weighted sum back instead of its rows

The design is eddoursul/Strata's second-GPU prompt path (f8de703, 2acfac4, e8ade66): the second GPU adds its
experts' rows into each token's weighted sum and the first GPU's combine adds that to its own experts' rows.
Over the host route the peer scatter-adds its rows into per-token sums (peer_scatter_add, after the fork's
moe_scatter_add: one launch per expert in a fixed order, so the sums are repeatable) and sends T x N floats
back instead of rows_peer x N (up to K = 10 times more); moe_combine_peer adds them to the primary's rows.  The
2a row buffers are not allocated (3.4 GB of pinned RAM at 32K-token chunks).  STRATA_PF_PEER_SUMS=0: rows.

Same setup, peer stream 0.6, prompt tok/s against the share off: 3.4K 332 -> 805, 8K 762 -> 1,284, 100K
1,712 -> 1,578.  The 8K and 3.4K answers are byte-identical to the share off (greedy, 256 / 3,221 tokens).

Co-Authored-By: Eddoursul <git@eddoursul.win>
This commit is contained in:
ThigandEddoursul authored and Niko1221 committed 2026-10-07 20:24:05 +02:00
1 parent 81af1da0b1
commit f4bfedc5ce
3 files changed
+103 -6

No files matched your search

+9
View File
@@ -88,6 +88,15 @@ void gather_rows16(const uint16_t* x16, const int32_t* src, uint16_t* dst16, int
/// bo[t, :] = shared[t, :] * sigmoid(sg[t]) + sum_k w[t, k] * D[slot[t, k], :]
void moe_combine(const float* D, const int32_t* slot, const float* w, const float* shared, const float* sg, float* bo,
int64_t T, void* stream);
/// --peer-device's prompt share as sums: bo[t, :] = (sum over the k with slot[t, k] < rows_local of w[t, k] *
/// D[slot[t, k], :], in k order) + peer[t, :] + shared[t, :] * sigmoid(sg[t]). `peer` (the peer's per-token sums)
/// may be mapped host memory.
void moe_combine_peer(const float* D, const int32_t* slot, const float* w, const float* shared, const float* sg,
const float* peer, int64_t rows_local, float* bo, int64_t T, void* stream);
/// sum[t, :] += wk[p] * rows[r, :] with p = pair[r], t = p / 10 (the routed pair's token), for n rows of ONE expert
/// (no token twice: launches in a fixed expert order make the sums repeatable). After eddoursul/Strata's
/// moe_scatter_add (f8de703).
void peer_scatter_add(float* sum, const float* rows, const float* wk, const int32_t* pair, int64_t n, void* stream);
// ---- QSA helpers
/// In place: x[r, :] = x[r, :] * rsqrt(mean x^2 + eps) * w over rows of `cols` (row stride `ld`).