Skip to content

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++

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

Niko1221da95ad29d844
diff --git a/src/program/generate.cpp b/src/program/generate.cpp
index 2a9a97e4e..18668d669 100644
--- a/src/program/generate.cpp
+++ b/src/program/generate.cpp
@@ -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; }