Skip to content

Qwen3.8-Flash-Next on any consumer hardware: one-click install for Windows / Linux. Strata inference engine, OpenAI/Anthropic API on localhost, optional image input.

C++

prefill: --peer-device's prompt share without P2P, through the layer split helper's mapped host route

Thig81af1da0b16b
diff --git a/src/prefill/prefill.cpp b/src/prefill/prefill.cpp
index 23eaf1ddf..6105b9355 100644
--- a/src/prefill/prefill.cpp
+++ b/src/prefill/prefill.cpp
@@ -1444,10 +1444,14 @@ bool Prefill::bind_stage_helper(int64_t T) {
bool Prefill::set_peer(core::PeerExperts* peer, int64_t cap_rows, std::string& err) {
Impl& m = *impl_;
if (peer == nullptr || !peer->valid()) { m.pp.reset(); return true; }
- if (!peer->p2p()) { err = "prefill peer: the two GPUs cannot access each other (no P2P)"; return false; }
+ // Without P2P the activations and the result rows take the mapped host route of the layer split's helper
+ // (STRATA_PF_PEER_HOST=0: refuse as before, the prompt path then stays on the primary)
+ const bool host_route_ok = [] { const char* v = std::getenv("STRATA_PF_PEER_HOST"); return v == nullptr || std::atoi(v) != 0; }();
+ if (!peer->p2p() && !host_route_ok) { err = "prefill peer: the two GPUs cannot access each other (no P2P)"; return false; }
if (!mmq_plan().any) { err = "prefill peer: needs the MMQ prompt path"; return false; }
auto pp = std::make_unique<PeerPrefill>();
pp->peer = peer;
+ pp->p2p = peer->p2p();
pp->T_max = m.T_max;
pp->cap_rows = std::max<int64_t>(1, std::min<int64_t>(cap_rows, m.T_max * K));
const int64_t R = pp->cap_rows;
@@ -1477,7 +1481,7 @@ bool Prefill::set_peer(core::PeerExperts* peer, int64_t cap_rows, std::string& e
pp->mixed = (float*) take((size_t) m.T_max * N * 4);
{
const char* v = std::getenv("STRATA_PF_PEER_COMPACT");
- pp->compact = v == nullptr || std::atoi(v) != 0;
+ pp->compact = (v == nullptr || std::atoi(v) != 0) || !pp->p2p; // the layer-sized path copies over P2P only
}
if (pp->compact) {
pp->cap_rows = m.T_max * K; // no row cap: only the row tables grow with it
@@ -1527,12 +1531,35 @@ bool Prefill::set_peer(core::PeerExperts* peer, int64_t cap_rows, std::string& e
mmq::iota(pp->ident, pp->cap_rows, pp->s);
ok = cudaStreamSynchronize(pp->s) == cudaSuccess;
}
+ if (ok && !pp->p2p) { // the host route's mapped buffers, sized for the largest chunk
+ auto host = [&](auto*& ptr, size_t& cap, size_t n) {
+ if (cudaHostAlloc((void**) &ptr, n * sizeof(*ptr), cudaHostAllocPortable | cudaHostAllocMapped) != cudaSuccess) {
+ cudaGetLastError();
+ ptr = nullptr;
+ ok = false;
+ return;
+ }
+ cap = n;
+ };
+ size_t bounds_cap = 0;
+ host(pp->host_x, pp->host_x_cap, (size_t) m.T_max * N);
+ if (ok) host(pp->host_rows, pp->host_rows_cap, (size_t) pp->cap_rows * N);
+ if (ok) host(pp->host_src, pp->host_src_cap, (size_t) pp->cap_rows);
+ if (ok) host(pp->host_bounds, bounds_cap, PeerPrefill::kHostBounds);
+ if (!ok) {
+ cudaSetDevice(prev);
+ err = "prefill peer: the host route's pinned buffers (" +
+ std::to_string(((size_t) pp->cap_rows * N * 4 + (size_t) m.T_max * N * 4) >> 20) + " MiB) do not fit in RAM";
+ return false;
+ }
+ }
size_t fb = 0, tb = 0;
cudaMemGetInfo(&fb, &tb);
cudaSetDevice(prev);
if (!ok) { err = "prefill peer: the peer's buffers do not fit (raise --peer-reserve-mib or lower --peer-prefill-rows)"; return false; }
std::fprintf(stderr, "strata prefill: peer GPU %d computes its experts' rows of each prompt chunk (up to %lld rows per "
- "layer%s); %zu MiB left free on it\n", pp->dev, (long long) pp->cap_rows,
+ "layer%s%s); %zu MiB left free on it\n", pp->dev, (long long) pp->cap_rows,
+ pp->p2p ? "" : ", no P2P: through mapped host memory",
pp->compact ? (pp->ps_frac > 0.0 ? (", compact group buffers, streams " + std::to_string((int) (pp->ps_frac * 100 + 0.5)) +
"% of the primary's streamed experts through a " + std::to_string(pp->RP) + "-slot ring").c_str()
: ", compact group buffers") : "", fb >> 20);