From bcd3603e3c7eda6ea01427a8d8b19e2c18736085 Mon Sep 17 00:00:00 2001 From: Niko1221 Date: Sun, 4 Oct 2026 07:58:15 +0200 Subject: [PATCH] #583 default on (owner): STRATA_RING_BYTES=0 opts out; DETAILS.md with the measured quality Changes default output on long prompts of native packs against 0.1.39 (expected; gate notes in the S40 report). --- docs/DETAILS.md | 15 +++++++++------ include/strata/prefill/prefill.hpp | 4 ++-- src/prefill/prefill.cpp | 11 ++++++----- src/program/generate.cpp | 6 +++--- 4 files changed, 20 insertions(+), 16 deletions(-) diff --git a/docs/DETAILS.md b/docs/DETAILS.md index 5218890a..62563f85 100644 --- a/docs/DETAILS.md +++ b/docs/DETAILS.md @@ -1031,12 +1031,15 @@ the document, +0.4% on the chat. Details: `bench/results/2026-09-27-esp/`. 0.1.7) drafts up to 5 tokens from the earlier copy, but only where its measured acceptance and cost say it pays: code edits 6-11% faster, other text unchanged. The drafts are checked like the MTP's, so the output is the same. - **Prompts** are processed in chunks of up to 8,192 tokens (`--prefill auto`; 32,768 opt-in) with the experts - streamed to the GPU over PCIe. `STRATA_RING_BYTES=1` (opt-in, engine 0.1.39b, #583) sizes the streamed ring in - bytes for the pack and picks the largest auto chunk that keeps that ring full: an RTX 5070 with IQ3_XXS and a - partly pinned arena read a 32K prompt 14-26% faster (4K: 1-4% slower). It changes the bits of a long prompt - (the experts go through a different mix of cached and streamed groups), which is why it is not the default; in a - teacher-forced check against the FP16 prompt path its KL and top-1 agreement match the default's (8K KL 0.042 vs - 0.054, 32K 0.020 vs 0.019). + streamed to the GPU over PCIe. Since engine 0.1.39b (#583) the streamed ring is sized in bytes for the pack (a + native pack with bigger blobs gets fewer ring slots and keeps more cache slots) and `--prefill auto` picks the + largest chunk that keeps that ring full: an RTX 5070 with IQ3_XXS and a partly pinned arena reads a 32K prompt + 14-26% faster (1,045 -> 1,190 tok/s at a 1,500-slot cache, -> 1,315 at 2,400; a 4K prompt 1-4% slower). Q2_0 + keeps its 384-slot ring. It changes the bits of a long prompt against 0.1.39 (the experts go through a different + mix of cached and streamed groups). Measured quality, teacher-forced over the next 2,001 tokens of a long document + against the FP16 prompt path (IQ3_XXS, `--prefill auto`): 8K prompt KL 0.042 (0.1.39: 0.054), top-1 agreement + 93.5% (92.2%); 32K prompt KL 0.020 (0.019), top-1 95.3% (95.0%) - the same band as before. `STRATA_RING_BYTES=0` + restores 0.1.39's ring, loan and chunk choice. The full story, with measurements, bottlenecks and what comes next: **[docs/paper/Strata-Paper.pdf](paper/Strata-Paper.pdf)**. diff --git a/include/strata/prefill/prefill.hpp b/include/strata/prefill/prefill.hpp index 73bfa5a4..ed633fd1 100644 --- a/include/strata/prefill/prefill.hpp +++ b/include/strata/prefill/prefill.hpp @@ -98,8 +98,8 @@ public: /// Monitor tab shows the pair the run really got, not what it asked for. static int64_t ring_slots_for(int64_t chunk); - /// 0.1.39b: STRATA_RING_BYTES=1 (opt-in): the ring as a byte budget, the loan's corrected count and the auto chunk - /// scan that keeps the ring full (#583). Off: 0.1.39's ring, loan and chunk list. + /// 0.1.39b (#583, the default): the ring as a byte budget, the loan's corrected count and the auto chunk scan that + /// keeps the ring full. STRATA_RING_BYTES=0: 0.1.39's ring, loan and chunk list. static bool ring_bytes_enabled(); /// Positions [pos0, pos0 + n) holding `tokens`; `ss.ple_prev` must be the two tokens before pos0 (oldest diff --git a/src/prefill/prefill.cpp b/src/prefill/prefill.cpp index 4242ed26..6af1ea55 100644 --- a/src/prefill/prefill.cpp +++ b/src/prefill/prefill.cpp @@ -156,11 +156,12 @@ inline uint64_t ring_bytes() { // ...and what that buys on THIS pack, never past ring_cap(): the slot count `init` lays out, and what the auto // chunk scan treats as a full ring. A pack whose blobs are larger than Q2_0's gets fewer slots for the same // bytes, which is the point - the ring competes with the expert cache for the same VRAM. -// 0.1.39b: opt-in (STRATA_RING_BYTES=1). It moves the prompt path's loan on a native pack (fewer ring slots, the -// rest kept as cache slots), so a long prompt's experts are read through a different mix of resident and streamed -// groups and its bits differ from the default's (RTX 5070, IQ3_XXS, 32K prompt: +14% to +26%). +// 0.1.39b: on by default (#583); STRATA_RING_BYTES=0 restores 0.1.39's ring, loan and auto chunk list. It moves the +// prompt path's loan on a native pack (fewer ring slots, the rest kept as cache slots, a larger auto chunk), so a long +// prompt's experts are read through a different mix of resident and streamed groups and its bits differ from 0.1.39's +// (RTX 5070, IQ3_XXS, 32K prompt: +14% to +26%; teacher-forced against the FP16 prompt path in the same band). inline bool ring_bytes_on() { - static const bool on = [] { const char* v = std::getenv("STRATA_RING_BYTES"); return v != nullptr && v[0] == '1'; }(); + static const bool on = [] { const char* v = std::getenv("STRATA_RING_BYTES"); return v == nullptr || v[0] != '0'; }(); return on; } inline int ring_budget_slots() { @@ -1360,7 +1361,7 @@ uint64_t Prefill::bytes_needed(const core::ModelGeometry& g, const core::Session f(T * N); f(T * D); if (gr_unfused()) f(T * D); f(T * HC); - } else { // 0.1.39's count (the default loan stays as it was) + } else { // STRATA_RING_BYTES=0: 0.1.39's count f(T * N); f(T * D); f(T * D); } o.take(T * D, ok); f(T * LR); o.take(T * LR, ok); diff --git a/src/program/generate.cpp b/src/program/generate.cpp index 12660dcf..6d98693b 100644 --- a/src/program/generate.cpp +++ b/src/program/generate.cpp @@ -4335,7 +4335,7 @@ int main(int argc, char** argv) { }; auto plan_lend = [&](int64_t& chunk) -> int64_t { auto slots_for = lend_slots; - if (o.prefill_auto && !strata::prefill::Prefill::ring_bytes_enabled()) { // 0.1.39's list (the default) + if (o.prefill_auto && !strata::prefill::Prefill::ring_bytes_enabled()) { // STRATA_RING_BYTES=0: 0.1.39's list static constexpr int64_t kAutoChunks[] = {32768, 16384, 8192, 6144, 4096, 3072, 2048, 1024, 512, 256}; for (const int64_t c : kAutoChunks) { // above 8192: only when asked for, and only when a prompt of the context can use it @@ -4345,7 +4345,7 @@ int main(int argc, char** argv) { } return 0; } - if (o.prefill_auto) { // STRATA_RING_BYTES=1 (#583) + if (o.prefill_auto) { // the default since 0.1.39b (#583) // The chunk and the ring are one budget, and the ring is the better buy. Measured on this 4-way // IQ3_S rig (2x RTX 3060 + 2x RTX 5060, CUDA3 lending at its 90% cap) on a 120K prompt: 8960 tokens // with the 17-slot ring that leaves reads at 963 tok/s, 8192/130 at 1,008, 7168 with the ring full at @@ -4606,7 +4606,7 @@ int main(int argc, char** argv) { if (fits(c, false, only)) return c; return 0; } - if (!strata::prefill::Prefill::ring_bytes_enabled()) { // 0.1.39's list (the default) + if (!strata::prefill::Prefill::ring_bytes_enabled()) { // STRATA_RING_BYTES=0: 0.1.39's list static constexpr int64_t kAutoChunks[] = {32768, 16384, 8192, 6144, 4096, 3072, 2048, 1024, 512, 256}; for (const int64_t c : kAutoChunks) { if (c > 8192 && (c > o.prefill_auto_max || c > o.max_context)) continue; // #282, as plan_lend