diff --git a/src/program/generate.cpp b/src/program/generate.cpp index d7625efc..cb704d36 100644 --- a/src/program/generate.cpp +++ b/src/program/generate.cpp @@ -164,6 +164,17 @@ std::string vram_free_note() { return buf; } +// STRATA_PIPE_BYIELD_NODRAIN=1 (read once; off by default): with the pipelined groups, a BYIELD that reaches the main +// loop is dropped without draining the groups first. A pipelined read never gives way (batch_read_piece), so the +// BYIELD is for a read that has ended, and the drain (and the refill after it) did nothing for it +bool pipe_byield_nodrain_env() { + static const bool on = [] { + const char* v = std::getenv("STRATA_PIPE_BYIELD_NODRAIN"); + return v && v[0] != '0'; + }(); + return on; +} + // perf-review D-4: the lent slots are refilled with queued copies and one wait; STRATA_REFILL_BLOCKING=1 waits on each // A file-backed arena on AMD (STRATA_ARENA_MMAP; the engine raises ROCclr's pin-in-place threshold, see main): an // adaptive swap copies one expert straight from the mapped file. Through ROCclr's staging that copy blocks the host @@ -10466,7 +10477,9 @@ int main(int argc, char** argv) { continue; } // a request reads its prompt through every stage: the groups in flight finish first - if (piped && line.rfind("BSTOP ", 0) != 0) { + // (STRATA_PIPE_BYIELD_NODRAIN: not for a BYIELD, which is dropped below) + if (piped && line.rfind("BSTOP ", 0) != 0 && + !(pipe_byield_nodrain_env() && line.rfind("BYIELD", 0) == 0)) { const int in_flight = trace ? (int) std::count_if(pg.begin(), pg.end(), [](const PGroup& G) { return G.inflight; }) : 0; const auto td = Clock::now();