batch-groups: opt-in adaptive-tier rounds in the pipelined loop, STRATA_PIPE_ADAPT_EVERY (#4010)
With --batch-groups above 1 on a layer split the pipelined batch loop never starts a round of the adaptive VRAM tier (the serial batch windows start one every --adapt-every windows). While the slots are busy the tier only moves when they go back to the solo path, so a fresh engine keeps its start-up profile for minutes. STRATA_PIPE_ADAPT_EVERY=N (opt-in; unset, 0 or not a number is off): after N group windows pump starts no new group on the first stage, lets the groups in flight finish, then runs one round as batch_step does between serial windows, adapt() and apply_pending(true), so nothing in flight reads a cache slot while experts swap and the new experts have landed before the next launch. Not while a prompt is read beside the slots (in_prompt_read, its loan of cache slots), not with --adapt-async, not while the last round's copies are in flight, not with the tier off. The rule is two pure functions in include/strata/program/batch_groups.hpp (pipe_adapt_every, pipe_adapt_due) with 12 new cases in batch_groups_test. With the switch set the engine says so once at start and the "strata batch (pipelined ...)" line adds the rounds, the experts swapped in and the time spent. docs/BATCHING.md documents the switch with the author's table (2x RTX 5090, six streams, 309 to 410 rows/s over eight bursts after a fresh start, two engines per setting). Reviewed: unset costs one counter increment per group window and one false check where a group starts, and prints no new line. A due round cannot wait forever: no new group starts, the groups in flight finish, then the round runs. A prompt read sets in_prompt_read before the reader thread starts (including STRATA_PIPED_CONCURRENT) and clears it after the reader joined; the drain after the read runs the round if it is due. Tests: batch_groups_test (the new cases). Not covered and still the author's to show (the PR is a draft): a soak with prompts read beside the slots, a Linux run, another GPU pair, more than two stages, and exactness settings with the switch set. The model gate is written down.
This commit is contained in:
1 parent
2b13a44933
commit
a3bb38ec45
4 files changed
+148
-5
No files matched your search
@@ -4,7 +4,9 @@
|
||||
// 2. a layer split with --batch >= 2 and no --batch-groups means `auto` (0.1.41);
|
||||
// 3. --batch-mtp (or --adapt-async 1) turns that default into one group, and says which feature did it;
|
||||
// 4. a number or `auto` given explicitly is honoured, with or without those features;
|
||||
// 5. no layer split: the number given (1) stays.
|
||||
// 5. no layer split: the number given (1) stays;
|
||||
// 6. STRATA_PIPE_ADAPT_EVERY: off unless a positive number; a round is due after N group windows, never with the tier
|
||||
// off, beside --adapt-async, while a prompt is read or while the last round's copies are in flight.
|
||||
#include "strata/program/batch_groups.hpp"
|
||||
|
||||
#include <cstdio>
|
||||
@@ -126,6 +128,41 @@ int main() {
|
||||
check(bg::resolve(i).groups == 2, "an explicit number without a split is returned (the engine warns)");
|
||||
}
|
||||
|
||||
// STRATA_PIPE_ADAPT_EVERY
|
||||
check(bg::pipe_adapt_every(nullptr) == 0 && bg::pipe_adapt_every("") == 0 && bg::pipe_adapt_every("0") == 0,
|
||||
"pipe adapt: unset, empty or 0 is off");
|
||||
check(bg::pipe_adapt_every("-5") == 0 && bg::pipe_adapt_every("off") == 0, "pipe adapt: negative or not a number is off");
|
||||
check(bg::pipe_adapt_every("128") == 128 && bg::pipe_adapt_every("1") == 1, "pipe adapt: a positive number is the interval");
|
||||
{
|
||||
bg::PipeAdapt p;
|
||||
p.every = 128;
|
||||
p.tier_on = true;
|
||||
p.windows = 127;
|
||||
check(!bg::pipe_adapt_due(p), "pipe adapt: not before N group windows");
|
||||
p.windows = 128;
|
||||
check(bg::pipe_adapt_due(p), "pipe adapt: due after N group windows");
|
||||
p.last = 128;
|
||||
p.windows = 200;
|
||||
check(!bg::pipe_adapt_due(p), "pipe adapt: counted again from the last round");
|
||||
p.windows = 256;
|
||||
check(bg::pipe_adapt_due(p), "pipe adapt: due N windows after the last round");
|
||||
bg::PipeAdapt q = p;
|
||||
q.every = 0;
|
||||
check(!bg::pipe_adapt_due(q), "pipe adapt: never when off");
|
||||
q = p;
|
||||
q.tier_on = false;
|
||||
check(!bg::pipe_adapt_due(q), "pipe adapt: never with the adaptive tier off");
|
||||
q = p;
|
||||
q.async_tier = true;
|
||||
check(!bg::pipe_adapt_due(q), "pipe adapt: never beside --adapt-async 1");
|
||||
q = p;
|
||||
q.prompt_read = true;
|
||||
check(!bg::pipe_adapt_due(q), "pipe adapt: never while a prompt is read beside the slots");
|
||||
q = p;
|
||||
q.swaps_pending = true;
|
||||
check(!bg::pipe_adapt_due(q), "pipe adapt: never while the last round's copies are in flight");
|
||||
}
|
||||
|
||||
std::printf("%s\n", g_fail == 0 ? "batch_groups_test: all passed" : "batch_groups_test: FAILED");
|
||||
return g_fail == 0 ? 0 : 1;
|
||||
}
|
||||
Reference in new issue
Block a user