Concurrency stage 1: --batch-groups auto (one pipeline group per GPU stage), INFO batch_groups; tools/serve_load.py load generator

This commit is contained in:
Niko1221 committed 2026-10-07 21:07:59 +02:00
1 parent d5ea713374
commit 1bf6344cb3
3 files changed
+186 -3

No files matched your search

+23 -2
View File
@@ -535,6 +535,7 @@ struct Options {
/// The --batch slots in this many groups pipelined through the stages of a layer split (stage k
/// runs one group while stage k+1 runs another). 1 = every slot in one window, stage after stage.
int batch_groups = 1;
bool batch_groups_auto = false; ///< --batch-groups auto (#417 stage 1): one group per stage of a layer split, if it divides --batch
bool batch_mtp = false; ///< --batch-mtp / STRATA_BATCH_MTP=1 (opt-in): one MTP proposal per batch slot
std::string spec_oracle;
int spec_corrupt = 0;
@@ -1729,7 +1730,11 @@ int main(int argc, char** argv) {
else if (a == "--batch") o.batch = std::atoi(next("--batch"));
else if (a == "--slots") o.batch = std::atoi(next("--slots")); // the same as --batch
else if (a == "--trim-stage-weights") o.trim_stage_weights = true;
else if (a == "--batch-groups") o.batch_groups = std::atoi(next("--batch-groups"));
else if (a == "--batch-groups") {
const char* bgv = next("--batch-groups");
if (std::strcmp(bgv, "auto") == 0) o.batch_groups_auto = true;
else o.batch_groups = std::atoi(bgv);
}
else if (a == "--batch-mtp") o.batch_mtp = true;
else if (a == "--spec-oracle") o.spec_oracle = next("--spec-oracle");
else if (a == "--spec-corrupt") o.spec_corrupt = std::atoi(next("--spec-corrupt"));
@@ -3802,6 +3807,20 @@ int main(int argc, char** argv) {
o.batch = cap;
}
}
// --batch-groups auto: the pipeline needs one group per GPU stage to keep every card busy (4 x R9700, 8 clients:
// 90 tok/s in one group, 136 in 2, 166 in 4). The most groups, at most one per stage, that divide the slots.
auto resolve_groups_auto = [&] {
if (!o.batch_groups_auto) return;
int best = 1;
for (int d = 2; d <= (int) stages.size() + 1 && d <= o.batch; ++d)
if (o.batch % d == 0) best = d;
if (stages.empty()) best = 1;
o.batch_groups = best;
std::fprintf(stderr, "strata generate: --batch-groups auto: %d group%s of %d slot%s
", best, best == 1 ? "" : "s",
o.batch / best, o.batch / best == 1 ? "" : "s");
};
if (o.batch > 0) resolve_groups_auto();
if (o.batch > 0 && o.batch_groups > 1 && (stages.empty() || o.batch % o.batch_groups != 0)) {
std::fprintf(stderr, "strata generate: WARNING: --batch-groups %d needs a layer split and to divide --batch %d; "
"one group\n", o.batch_groups, o.batch);
@@ -3849,6 +3868,7 @@ int main(int argc, char** argv) {
o.batch = 0;
} else {
o.batch = fit;
resolve_groups_auto(); // (the slots that fit may not be the ones asked for)
if (o.batch_groups > 1 && o.batch % o.batch_groups != 0) o.batch_groups = 1;
// the sessions' VRAM is the expert cache's: say what it costs (docs/BATCHING.md has the measured trade)
std::fprintf(stderr, "strata generate: --batch %d: the slot sessions take %.2f GiB of VRAM on CUDA0 that the "
@@ -7894,7 +7914,8 @@ int main(int argc, char** argv) {
o.spec_min_p, (long long) o.conversation_cache_mib, o.conversation_cache_slots,
(long long) o.conversation_cache_min_free_mib, (long long) o.tail_role_token, xcache.segmented() ? 1 : 0,
o.batch > 0 ? (" batch_slots=" + std::to_string(o.batch) +
" slot_cache=" + std::to_string(o.prompt_cache > 0 ? 1 : 0)).c_str() : "");
" slot_cache=" + std::to_string(o.prompt_cache > 0 ? 1 : 0) +
(o.batch_groups > 1 ? " batch_groups=" + std::to_string(o.batch_groups) : std::string())).c_str() : "");
}
// issue #29: a request whose heartbeat (tokens, prompt chunks, verify windows) stops for this long is stuck on
// a flag nobody will raise - end the engine with where it was, so the server starts it again instead of the