batch: with --batch-groups a second request goes to the other pipeline group, and idle slots no longer cost rows in a group's window (#1249)

On a layer split with --batch-groups, two concurrent requests ran at about half speed: the slot choice could put both in
one group, and a group's window carried a row for every slot, active or not. Slot choice now prefers the group with the
fewest busy slots (a held prefix of 512 tokens or more still wins), and a window covers the slots up to its last active
one. Without --batch-groups the slot choice is exactly as before.

Co-authored-by: crazyaimachine <209005491+crazyaimachine@users.noreply.github.com>
This commit is contained in:
Niko1221andcrazyaimachine committed 2026-10-07 03:02:56 +02:00
1 parent 09e5ab4f6e
commit e21dc577a8
3 files changed
+37 -5

No files matched your search

+6 -3
View File
@@ -8099,6 +8099,7 @@ int main(int argc, char** argv) {
int32_t tok[strata::kernels::kVerifyMaxT] = {};
int64_t pos[strata::kernels::kVerifyMaxT] = {};
int64_t since = 0; ///< tick it started waiting (fairness)
int S = 0; ///< slots in its window: up to its last active one (idle ones cost rows)
};
std::vector<PGroup> pg((size_t) (piped ? o.batch_groups : 0));
std::vector<int> stage_group((size_t) n_pipe, -1);
@@ -8129,7 +8130,7 @@ int main(int argc, char** argv) {
if (k + 1 < n_pipe) { G.stage = k + 1; G.since = pipe_tick; continue; }
// the last stage: the group's picks
const int32_t* outb = vk.batch_out();
for (int t = 0; t < GS; ++t) {
for (int t = 0; t < G.S; ++t) {
BSlot& sl = bs[(size_t) (gi * GS + t)];
if (!sl.active) continue;
const int32_t y = outb[t];
@@ -8173,7 +8174,9 @@ int main(int argc, char** argv) {
if (pick < 0) continue;
rr = pick + 1;
PGroup& G = pg[(size_t) pick];
for (int t = 0; t < GS; ++t) {
G.S = 0;
for (int t = 0; t < GS; ++t) if (bs[(size_t) (pick * GS + t)].active) G.S = t + 1;
for (int t = 0; t < G.S; ++t) {
BSlot& sl = bs[(size_t) (pick * GS + t)];
G.tok[t] = sl.active ? sl.x : 0;
G.pos[t] = sl.active ? sl.p : 0;
@@ -8186,7 +8189,7 @@ int main(int argc, char** argv) {
}
PGroup& G = pg[(size_t) pick];
strata::core::progress().busy.store(true);
if (!stage_verifier(k).batch_launch(pick * GS, GS, G.tok, G.pos, err)) {
if (!stage_verifier(k).batch_launch(pick * GS, G.S, G.tok, G.pos, err)) {
std::printf("ERR %s\n", err.c_str());
return false;
}