#282 follow-up: chunks above 8192 are opt-in (--prefill auto:16384 / auto:32768, or STRATA_PREFILL_AUTO_MAX)

A bigger chunk reads a long prompt in a different order of chunks (other expert loans, other rounding of the
batched path), so it stays out of the default: plain --prefill auto picks from 8192 down exactly as 0.1.31 did (the
PR's "no chunk past the context" rule, which also moved the choice below 8192 for small contexts, now applies only
to the new sizes). auto:N (16384 or 32768) or STRATA_PREFILL_AUTO_MAX with auto sets the ceiling; o.prefill_chunk
starts at that ceiling for the buffer estimates. Both kAutoChunks lists - plan_lend and the serve path's per-stage
fits() - take the same sizes under the same rule.
This commit is contained in:
Niko1221 committed 2026-10-01 08:39:58 +02:00
1 parent 1e5e84d919
commit da95ad29d8
1 file changed
+22 -9
+22 -9
View File
@@ -319,9 +319,12 @@ struct Options {
int vram_reserve_mib = 700;
/// Plan v0.3 P5: batched prompt processing in chunks of this many tokens (0 = the token path).
int64_t prefill_chunk = 0;
/// `--prefill auto`: the largest chunk (up to 32768) whose buffers the expert cache can lend. Every expert a chunk
/// `--prefill auto`: the largest chunk (up to 8192) whose buffers the expert cache can lend. Every expert a chunk
/// routes to is streamed once per chunk, so a bigger chunk streams fewer bytes per token (the "ubatch" effect).
bool prefill_auto = false;
/// #282, opt-in: the largest chunk `--prefill auto` may take - 8192 by default; `--prefill auto:16384` or
/// `auto:32768` (or STRATA_PREFILL_AUTO_MAX) lets it go further, never past the context
int64_t prefill_auto_max = 8192;
bool no_split_rows = false; ///< plan v0.3 P4 A/B: one whole expert per pool thread
/// Plan v0.3 P5: the prompt path borrows the top expert-cache slots for its buffers and refills them after
/// the prompt (default); `--no-prefill-borrow` reserves the buffers' VRAM for the whole session instead.
@@ -501,7 +504,8 @@ void usage() {
" --no-token-graph A/B: two graphs per layer (the host launches each) instead of one per token\n"
" --no-fused-gr A/B: the six-kernel hyper-connection read and a separate write (native)\n"
" --prefill CHUNK batched prompt processing in chunks of CHUNK tokens (needs --native); auto =\n"
" the largest chunk up to 32768 whose buffers the expert cache can lend\n"
" the largest chunk up to 8192 whose buffers the expert cache can lend;\n"
" auto:16384 / auto:32768 (or STRATA_PREFILL_AUTO_MAX) allow bigger ones\n"
" --no-pool skip the CPU expert pool (the GPU-only floor)\n"
" --sync-every-layer debug: synchronise after every layer\n"
" --ple-gguf PATH the n-gram/PLE shard. WITHOUT IT LAYER 1's PLE IS SILENTLY SKIPPED,\n"
@@ -1092,8 +1096,13 @@ int main(int argc, char** argv) {
else if (a == "--vram-reserve-mib") o.vram_reserve_mib = std::atoi(next("--vram-reserve-mib"));
else if (a == "--prefill") {
const std::string v = next("--prefill");
o.prefill_auto = v == "auto";
o.prefill_chunk = o.prefill_auto ? 8192 : std::atoll(v.c_str());
o.prefill_auto = v == "auto" || v.rfind("auto:", 0) == 0;
// #282: auto:N (N = 16384 or 32768) or STRATA_PREFILL_AUTO_MAX lets auto take chunks above 8192
const char* env_max = std::getenv("STRATA_PREFILL_AUTO_MAX");
const long long want_max = v.rfind("auto:", 0) == 0 ? std::atoll(v.c_str() + 5)
: (o.prefill_auto && env_max != nullptr ? std::atoll(env_max) : 8192);
o.prefill_auto_max = want_max >= 32768 ? 32768 : want_max >= 16384 ? 16384 : 8192;
o.prefill_chunk = o.prefill_auto ? o.prefill_auto_max : std::atoll(v.c_str());
}
else if (a == "--no-split-rows") o.no_split_rows = true;
else if (a == "--no-prefill-borrow") o.no_prefill_borrow = true;
@@ -3603,13 +3612,15 @@ int main(int argc, char** argv) {
: (int64_t) (strata::prefill::Prefill::pinned_share() >= 0.9 ? 90 : 85);
}();
auto plan_lend = [&](int64_t& chunk) -> int64_t {
// 32768 and 16384: a 32K prompt with IQ2_XS (RTX 5090, 64K context) read at 5,624 tok/s in 8192-token chunks
// and 6,465 in one 32768 chunk (40K -> 18K experts streamed; an NVFP4 pack at 262K: 3,535 -> 5,201)
// 32768 and 16384 (#282, opt-in: --prefill auto:32768): a 32K prompt with IQ2_XS (RTX 5090, 64K context)
// read at 5,624 tok/s in 8192-token chunks and 6,465 in one 32768 chunk (40K -> 18K experts streamed; an
// NVFP4 pack at 262K: 3,535 -> 5,201)
static constexpr int64_t kAutoChunks[] = {32768, 16384, 8192, 6144, 4096, 3072, 2048, 1024, 512, 256};
auto slots_for = lend_slots;
if (o.prefill_auto) {
for (const int64_t c : kAutoChunks) {
if (c > o.max_context && c > 256) continue; // no prompt is longer than the context
// above 8192: only when asked for, and only when a prompt of the context can use it
if (c > 8192 && (c > o.prefill_auto_max || c > o.max_context)) continue;
const int64_t k = slots_for(c);
if (k + 128 <= xcache.slots() && k * 100 <= kAutoLendPct * xcache.slots()) { chunk = c; return k; }
}
@@ -3728,11 +3739,13 @@ int main(int argc, char** argv) {
}
return true;
};
static constexpr int64_t kAutoChunks[] = {8192, 6144, 4096, 3072, 2048, 1024, 512, 256};
static constexpr int64_t kAutoChunks[] = {32768, 16384, 8192, 6144, 4096, 3072, 2048, 1024, 512, 256};
int64_t chunk = 0;
if (o.prefill_auto) {
for (const int64_t c : kAutoChunks)
for (const int64_t c : kAutoChunks) {
if (c > 8192 && (c > o.prefill_auto_max || c > o.max_context)) continue; // #282, as plan_lend
if (fits(c, true)) { chunk = c; break; }
}
} else {
for (int64_t c = o.prefill_chunk; c >= 256; c /= 2)
if (fits(c, false)) { chunk = c; break; }