mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 23:08:36 +00:00
Batch decode: log which batch-row switches are on at start-up
STRATA_BATCH_ATTN_ROWS and STRATA_BATCH_GDN_GROUPS (#2234) were read in three places and said nothing when set, so a user could not tell from the log whether they took effect. Both are now read once next to the other batch switches in verify.cpp, and init_slots prints one line when either is on, saying which, and that attention keeps one launch per row when a slot's KV streams (--kv-resident). Off, nothing is printed and nothing changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e88ee39d1d
commit
0f31ba6ead
2 files changed
+27
-15
No files matched your search
@@ -487,6 +487,12 @@ params, so the graph captured per row layout stays valid):
|
||||
|
||||
Both are off by default; off, the engine runs the same launches as before. On, the arithmetic per row is the same:
|
||||
4 concurrent prompts at temperature 0 gave the same bytes as without them, with `--batch 4` and `--batch 8`.
|
||||
With either one on, the engine log says which at start-up (once per stage of a layer split), and whether the KV
|
||||
streams, in which case attention keeps one launch per row and only the GDN switch acts:
|
||||
|
||||
```
|
||||
strata verify: batch rows in one launch: attention on (STRATA_BATCH_ATTN_ROWS), GDN on (STRATA_BATCH_GDN_GROUPS); the KV streams (--kv-resident), so attention keeps one launch per row
|
||||
```
|
||||
|
||||
One RTX PRO 6000 Blackwell (96 GB), IQ3_S, all 24,576 experts in VRAM, `--kv int8`, 262144 context, `--mtp`,
|
||||
`--spec 4`, through the HTTP server: C different stories sent at once, 1024 tokens each, temperature 0.7, mean of
|
||||
|
||||
+21
-15
@@ -239,6 +239,13 @@ const bool g_batch_self_commit = env_on("STRATA_BATCH_SELF_COMMIT");
|
||||
// one call per row; every row is computed by the same kernel with the same arithmetic as its own call. Not with a
|
||||
// streamed KV cache (a row's block resolve could evict the blocks an earlier row of the same slot selected).
|
||||
const bool g_qsa_slots = env_on("STRATA_QSA_SLOTS");
|
||||
// STRATA_BATCH_ATTN_ROWS=1 / STRATA_BATCH_GDN_GROUPS=1 (opt-in, #2234): see record_window and capture_commit_batch
|
||||
bool env_nonzero(const char* name) {
|
||||
const char* v = std::getenv(name);
|
||||
return v != nullptr && std::atoi(v) != 0;
|
||||
}
|
||||
const bool g_batch_attn_rows = env_nonzero("STRATA_BATCH_ATTN_ROWS");
|
||||
const bool g_batch_gdn_groups = env_nonzero("STRATA_BATCH_GDN_GROUPS");
|
||||
|
||||
// every row of a batch window is another slot's (no slot has proposal rows)
|
||||
bool one_row_per_slot(const int* rows, int S) {
|
||||
@@ -1419,11 +1426,7 @@ bool Verifier::record_window(int T, cudaStream_t cs, std::string& err) {
|
||||
}
|
||||
}
|
||||
// the recurrence from the untouched state over tokens [0, te); outputs only for this group's
|
||||
static const bool gdn_groups_on = [] { // STRATA_BATCH_GDN_GROUPS=1, all slots in one launch
|
||||
const char* v = std::getenv("STRATA_BATCH_GDN_GROUPS");
|
||||
return v != nullptr && std::atoi(v) != 0;
|
||||
}();
|
||||
if (batch_rec_ && gdn_groups_on && te - tb <= 8) {
|
||||
if (batch_rec_ && g_batch_gdn_groups && te - tb <= 8) {
|
||||
strata::kernels::GdnGroups gg;
|
||||
for (int t = tb; t < te;) {
|
||||
const int first = t;
|
||||
@@ -1715,11 +1718,7 @@ bool Verifier::record_window(int T, cudaStream_t cs, std::string& err) {
|
||||
// own indexer keys, the top-k over all rows (row-independent), attention with each row's own pools -
|
||||
// instead of 3-4 one-row launches per row; the same per-row arithmetic. Not with KV streaming
|
||||
// (qsa_kv_resolve has work per slot then).
|
||||
static const bool attn_rows = [] {
|
||||
const char* v = std::getenv("STRATA_BATCH_ATTN_ROWS");
|
||||
return v != nullptr && std::atoi(v) != 0;
|
||||
}();
|
||||
bool rows_ok = batch_rec_ && attn_rows && te - tb <= strata::kernels::kAttnRowsMax;
|
||||
bool rows_ok = batch_rec_ && g_batch_attn_rows && te - tb <= strata::kernels::kAttnRowsMax;
|
||||
for (int t = tb; rows_ok && t < te; ++t) rows_ok = slot_ss(t).qsa_states[qi].kv_mode != 1;
|
||||
if (rows_ok) {
|
||||
const int n_rows = te - tb;
|
||||
@@ -3296,6 +3295,17 @@ bool Verifier::init_slots(const std::vector<SessionState*>& slots, std::string&
|
||||
slot_sp_.assign(slots.size(), sampling_); // greedy until set_slot_sampling
|
||||
std::fprintf(stderr, "strata verify: batch windows of up to %lld sequences (layers [%lld, %lld))%s\n", (long long) S,
|
||||
(long long) lb_, (long long) le_, g_batch_self_commit ? ", one-row windows keep their rows" : "");
|
||||
if (g_batch_attn_rows || g_batch_gdn_groups) { // #2234: which are on, and when attention cannot use its own
|
||||
bool streamed = false; // a slot whose KV streams (kv_mode 1) keeps the per-row attention launches
|
||||
for (const SessionState* x : slots)
|
||||
for (int64_t j = 0; j < x->qsa_alloc && !streamed; ++j)
|
||||
streamed = x->qsa_states[x->qsa_ord0 + j].kv_mode == 1;
|
||||
std::fprintf(stderr, "strata verify: batch rows in one launch: attention %s (STRATA_BATCH_ATTN_ROWS), "
|
||||
"GDN %s (STRATA_BATCH_GDN_GROUPS)%s\n", g_batch_attn_rows ? "on" : "off",
|
||||
g_batch_gdn_groups ? "on" : "off",
|
||||
g_batch_attn_rows && streamed ? "; the KV streams (--kv-resident), so attention keeps one launch "
|
||||
"per row" : "");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -3362,10 +3372,6 @@ bool Verifier::capture_commit_batch(const int* rows, int S, int hbase, std::stri
|
||||
if (!wnm) { ok = false; break; }
|
||||
// STRATA_BATCH_GDN_GROUPS=1: one-row groups (no --batch-mtp proposals) commit their recurrence
|
||||
// in one launch for all slots; the conv commits stay per slot
|
||||
static const bool gdn_groups_on = [] {
|
||||
const char* v = std::getenv("STRATA_BATCH_GDN_GROUPS");
|
||||
return v != nullptr && std::atoi(v) != 0;
|
||||
}();
|
||||
bool one_row = S <= 8;
|
||||
for (int t = 1; one_row && t < S; ++t) one_row = rows[t] != rows[t - 1];
|
||||
strata::kernels::GdnGroups gg;
|
||||
@@ -3378,7 +3384,7 @@ bool Verifier::capture_commit_batch(const int* rows, int S, int hbase, std::stri
|
||||
float* conv = state + (uint64_t) g.ssm_state_size * g.ssm_v_heads * g.ssm_state_size;
|
||||
gdn_conv_commit(conv, qkv_L_ + (size_t) gdn_index * MT * C + (size_t) first * C,
|
||||
(int) C, keep, cs_);
|
||||
if (gdn_groups_on && one_row) {
|
||||
if (g_batch_gdn_groups && one_row) {
|
||||
gg.state[gg.n] = state;
|
||||
gg.keep[gg.n] = keep;
|
||||
gg.first[gg.n] = first;
|
||||
|
||||
Reference in new issue
Block a user