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++
batch-groups: --adapt-async 1 also keeps the 0.1.41 auto default at one group (said once)
noon-at-cgnb5d520313a3f
diff --git a/docs/BATCHING.md b/docs/BATCHING.mdindex 4217c60b2..c739615e6 100644--- a/docs/BATCHING.md+++ b/docs/BATCHING.md@@ -84,7 +84,7 @@ With a layer split, the engine options go into the config's `args`:| --- | --- || `"parallel": N` / `--batch N` / `--slots N` (2..8 normally) | up to N conversations have batch slots; more requests wait for a free slot. Each slot gets its own state (a session carved like the stage's own: GDN recurrence, QSA K/V and indexer, PLE history) on every GPU of the split. With grouped MTP, more than 8 slots can rotate through eight-row windows if memory permits. || `--batch-groups G` | with a layer split (default: auto, below): the N slots in G groups that flow through the GPUs as a pipeline (GPU k runs one group while GPU k+1 runs another). G must divide N. 1 = all slots in one window, GPU after GPU. |-| `--batch-groups auto` | the default on a layer split since 0.1.41 (give no `--batch-groups`): the engine pipelines one group per GPU stage (the most that divide the slots; 8 slots on 4 GPUs = 4 groups of 2) and says so (`INFO batch_groups=G`). `--batch-groups 1` turns it off (all slots in one window, GPU after GPU). Measured, 8 clients, total tok/s against one group: 4 x R9700 166 against 86, 2 GPUs 109 against 78, 3 GPUs 110 against 78. With `--batch-mtp` and no `--batch-groups` the default is one group (the slots' MTP drafts do not run in pipelined groups) and the log says so; `--batch-groups G` or `--batch-groups auto` given with `--batch-mtp` pipelines the groups and turns `--batch-mtp` off. |+| `--batch-groups auto` | the default on a layer split since 0.1.41 (give no `--batch-groups`): the engine pipelines one group per GPU stage (the most that divide the slots; 8 slots on 4 GPUs = 4 groups of 2) and says so (`INFO batch_groups=G`). `--batch-groups 1` turns it off (all slots in one window, GPU after GPU). Measured, 8 clients, total tok/s against one group: 4 x R9700 166 against 86, 2 GPUs 109 against 78, 3 GPUs 110 against 78. With `--batch-mtp` or `--adapt-async 1` and no `--batch-groups` the default is one group (the slots' MTP drafts and the adaptive tier between batch windows do not run in pipelined groups) and the log says so; `--batch-groups G` or `--batch-groups auto` given with `--batch-mtp` pipelines the groups and turns `--batch-mtp` off, and given with `--adapt-async 1` pipelines the groups and turns `--adapt-async` off (the pipelined path does not adapt). || `--trim-stage-weights` | with an **explicit** `--layer-split` (e.g. `12,24,36`, not `auto`): every GPU loads only the dense weights of its own layers instead of the whole model's (the same as `STRATA_STAGE_TRIM=1`, PR #639). The VRAM this frees goes to the expert cache. Useful without `--batch` too. |The engine never refuses a count it cannot run: it says so in its log and runs what it can - at most 8 slots bydiff --git a/include/strata/program/batch_groups.hpp b/include/strata/program/batch_groups.hppindex 0cc7c1d9e..e0d875897 100644--- a/include/strata/program/batch_groups.hpp+++ b/include/strata/program/batch_groups.hpp@@ -2,9 +2,10 @@//// `--batch-groups N` pipelines N groups of slots through the stages of a layer split; `--batch-groups auto` picks the// most groups (at most one per stage) that divide the slots. Since 0.1.41 a layer split with `--batch` >= 2 and no-// `--batch-groups` at all means `auto`. The pipelined path does not run `--batch-mtp`'s drafts, so when `--batch-mtp`-// is asked for and the number of groups was NOT given, `auto` resolves to one group (the serial windows the drafts run-// in) and says why. A number or `auto` given on the command line is honoured as before.+// `--batch-groups` at all means `auto`. The pipelined path does not run `--batch-mtp`'s drafts or the batch+// adaptive tier (`--adapt-async 1` between batch windows), so when one of those is asked for and the number of groups+// was NOT given, `auto` resolves to one group (the serial windows they run in) and says why. A number or `auto`+// given on the command line is honoured as before.//// Pure (no GPU, no environment read): generate.cpp passes in what it knows.#pragma once@@ -12,7 +13,7 @@namespace strata::program::batch_groups {/// What kept `auto` from pipelining.-enum class Serial { None, BatchMtp };+enum class Serial { None, BatchMtp, AdaptAsync };struct Input {bool set = false; ///< --batch-groups was given (a number or `auto`)@@ -21,12 +22,13 @@ struct Input {int batch = 0; ///< the slotsint later_stages = 0; ///< the layer split's stages after CUDA0 (0: no layer split)bool batch_mtp = false; ///< --batch-mtp is on (it passed the gates that do not concern the groups)+ bool adapt_async = false; ///< --adapt-async 1 was asked for};struct Result {int groups = 1;bool from_auto = false; ///< the number came from `auto` (given or the 0.1.41 default)- Serial serial = Serial::None; ///< `auto` would have pipelined, but --batch-mtp needs the serial windows+ Serial serial = Serial::None; ///< `auto` would have pipelined, but this feature needs the serial windowsint would_be = 1; ///< what `auto` would have picked without it (== groups unless `serial`)};@@ -48,15 +50,16 @@ inline Result resolve(const Input& in) {r.from_auto = true;r.would_be = auto_groups(in.later_stages, in.batch);r.groups = r.would_be;- if (!in.set && r.would_be > 1 && in.batch_mtp) { // only the default gives way; `--batch-groups auto` asked for the pipeline- r.serial = Serial::BatchMtp;- r.groups = 1;+ if (!in.set && r.would_be > 1) { // only the default gives way; `--batch-groups auto` asked for the pipeline+ if (in.batch_mtp) r.serial = Serial::BatchMtp;+ else if (in.adapt_async) r.serial = Serial::AdaptAsync;+ if (r.serial != Serial::None) r.groups = 1;}return r;}inline const char* serial_what(Serial s) {- return s == Serial::BatchMtp ? "--batch-mtp" : "";+ return s == Serial::BatchMtp ? "--batch-mtp" : s == Serial::AdaptAsync ? "--adapt-async 1" : "";}} // namespace strata::program::batch_groupsdiff --git a/src/program/batch_groups_test.cpp b/src/program/batch_groups_test.cppindex 065fd5f66..191456385 100644--- a/src/program/batch_groups_test.cpp+++ b/src/program/batch_groups_test.cpp@@ -2,8 +2,8 @@//// 1. `auto` picks the most groups, at most one per stage, that divide the slots;// 2. a layer split with --batch >= 2 and no --batch-groups means `auto` (0.1.41);-// 3. --batch-mtp turns that default into one group, and says which feature did it;-// 4. a number or `auto` given explicitly is honoured, with or without --batch-mtp;+// 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.#include "strata/program/batch_groups.hpp"@@ -46,7 +46,7 @@ int main() {check(r.groups == 1 && !r.from_auto, "no layer split: one group");}- { // the shape this is for: parallel 2 on a 2-GPU split with --batch-mtp+ { // the production shape: parallel 2 on a 2-GPU split with --batch-mtpbg::Input i = in(2, 1);i.batch_mtp = true;const auto r = bg::resolve(i);@@ -54,6 +54,18 @@ int main() {"--batch-mtp, nothing given: one group, because of --batch-mtp");check(bg::serial_what(r.serial)[0] == '-', "the reason names the feature");}+ {+ bg::Input i = in(2, 1);+ i.adapt_async = true;+ const auto r = bg::resolve(i);+ check(r.groups == 1 && r.serial == bg::Serial::AdaptAsync, "--adapt-async 1, nothing given: one group");+ }+ {+ bg::Input i = in(2, 1);+ i.batch_mtp = true;+ i.adapt_async = true;+ check(bg::resolve(i).serial == bg::Serial::BatchMtp, "both: --batch-mtp is named");+ }{ // nothing to give way: the slots do not divide, so auto is one group anyway and there is nothing to saybg::Input i = in(3, 1);i.batch_mtp = true;@@ -65,6 +77,7 @@ int main() {i.set = true;i.given = 2;i.batch_mtp = true;+ i.adapt_async = true;const auto r = bg::resolve(i);check(r.groups == 2 && !r.from_auto && r.serial == bg::Serial::None, "--batch-groups 2 with --batch-mtp: 2");i.given = 1;diff --git a/src/program/generate.cpp b/src/program/generate.cppindex 7b89e141e..5619988d8 100644--- a/src/program/generate.cpp+++ b/src/program/generate.cpp@@ -4125,9 +4125,9 @@ int main(int argc, char** argv) {// With a layer split the slots' drafters live on the LAST stage's GPU (where the solo drafter, the head and the final// residual rows are); the windows are the ones --batch runs, two rows per slot, through every stage.// --batch-groups: given as a number or auto, or (0.1.41) auto by default for a layer split with --batch >= 2. The- // pipelined slot groups do not run --batch-mtp's drafts, so when it is asked for and the groups were not given, the- // default is one group (batch_groups.hpp). Evaluated again once the slots that fit are known, and BEFORE the- // --batch-mtp gate below, which must see the resolved number.+ // pipelined slot groups run neither --batch-mtp's drafts nor the batch adaptive tier (--adapt-async 1), so when one of+ // them is asked for and the groups were not given, the default is one group (batch_groups.hpp). Evaluated again+ // once the slots that fit are known, and BEFORE the --batch-mtp gate below, which must see the resolved number.auto batch_groups_for = [&](bool mtp_on) {strata::program::batch_groups::Input bin;bin.set = o.batch_groups_set;@@ -4136,6 +4136,7 @@ int main(int argc, char** argv) {bin.batch = o.batch;bin.later_stages = (int) stages.size();bin.batch_mtp = mtp_on;+ bin.adapt_async = o.adapt_async != 0;return strata::program::batch_groups::resolve(bin);};const char* batch_mtp_env = std::getenv("STRATA_BATCH_MTP");@@ -4174,7 +4175,7 @@ int main(int argc, char** argv) {// --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.// The default (0.1.41: a layer split with --batch pipelines one group per stage; --batch-groups 1 opts out) gives- // way to --batch-mtp, which needs the serial windows: one group, said once.+ // way to --batch-mtp and --adapt-async 1, which need the serial windows: one group, said once.int groups_said = 0;auto resolve_groups_auto = [&] {const auto r = batch_groups_for(batch_mtp);