[PR #4538] [Engine] preserve periodic retry after a low-benefit prefetch closure #5080

Open
opened 2026-11-07 16:32:32 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/4538
Author: @cmdruid
Created: 10/28/2026
Status: 🔄 Open

Base: main ← Head: bench/prefetch-benefit-retry


📝 Commits (1)

  • 48f6fd4 [Engine] retain benefit closure reason for periodic prefetch retry

📊 Changes

3 files changed (+162 additions, -1 deletions)

View changed files

📝 docs/DETAILS.md (+2 -0)
📝 src/core/expert_source.cpp (+3 -1)
➕ tools/test_prefetch_gate.py (+157 -0)

📄 Description

A prefetch gate closed for low benefit can stay closed indefinitely at a stable cache-room ratio inside the 0.55–0.65 hysteresis band. The next decision incorrectly clears the benefit reason by applying the capacity-reopening threshold. Preserve that reason so the existing 256-window probe runs; a real capacity drop still cancels the probe and requires recovery above the high watermark.

Fixes #4537.

This changes one decision expression, documents the distinction, and adds a CPU regression test that compiles the production decision method with synthetic capacity/counter inputs. No new state, switches, defaults or call sites are introduced.

Validation at commit 48f6fd4, based on release 5e8a4cca7d690ac60ca37eb09e7d0e010099ad6d:

  • Passed: python3 tools/test_prefetch_gate.py: 31 checks, 0 failures. Includes exact threshold edges, a real capacity drop during a pending benefit retry, repeated benefit closures, unknown room and disabled gating.
  • Expected failure reproduced: the same test against unpatched release source: 31 checks, 14 failing assertions. These are assertions across scenarios, not 14 independent production incidents.
  • Passed: CUDA Release build with STRATA_ENABLE_CUDA=ON, CMAKE_CUDA_ARCHITECTURES=120; unchanged toolchain and flags for unpatched/patched controls, GGML 3cf03257f219afbe7334045ff7c6a06ac68c627d.
  • Passed: conversation_cache_test, conversation_split_failure_test, conversation_memory_test, conversation_file_test, session_save_reclaim_test (5/5).
  • Passed: python3 -B -m unittest serve.test_context_overflow serve.test_chat_tool_results serve.test_quiet_cancel serve.test_request_accounting serve.test_session_save_retry (39 tests).
  • Not run: HIP/SYCL builds or execution; those toolchains/devices are unavailable. Kept draft pending the backend checks required by CONTRIBUTING.md.

Hardware qualification on two RTX 5070 Ti cards is ongoing and will be reported separately from CPU proof. No measured speedup or broad output-equivalence claim is made at submission. The state-transition test does not exercise the full expert source, concurrency or real memory pressure. Targeted HIP/SYCL build help would be useful before marking this ready for review.

AI assistance was used for investigation and implementation; the results above were executed locally and checked against retained output.

Local CUDA qualification results (2026-10-28)

Four independent-boot U/P pairs, ordered UP, PU, PU, UP, on two RTX 5070 Ti 16 GiB cards. U and P use the same CUDA 13.2 Release build, architecture 120, serving layer, weights, expert seed, 262144 context/int8 KV, native MTP spec 4 / threshold 0.5, mmap, prompt checkpoints, and RAM conversation parking. Each boot had cold ~16K input, a natural ~24K appended input with 4096 output tokens, a cached 512-token follow-up, another session, and return to the first. OS caches were preserved; the memory guard was 40 GiB / no swap.

Pair Long decode U / P, tokens/s Cached follow-up U / P, tokens/s
1 32.0 / 69.9 29.7 / 59.7
2 72.7 / 76.9 61.2 / 61.4
3 76.1 / 76.9 62.0 / 59.6
4 72.7 / 72.0 60.3 / 62.3

The median paired changes are +3.41% / +1.82%, below the predeclared 10% target. An identical-build four-boot check with identical inputs and outputs ranged from 667.8 to 1202.7 tokens/s in cold prefill and 49.8 to 70.8 tokens/s in 512-token decode. No meaningful throughput improvement is established.

The first slow U run had an open gate with zero closures, 540.4 GB of OS reads and 83.4 seconds of fetch wait; later runs read much less. Other U and P runs both closed and reopened their gates. The GPU sequence did not isolate the stable-band retry failure proven by the CPU regression test. Aggregate end-of-request ratios/flip counts do not prove the reason for a particular closure.

A frozen 16-task quality panel compared native token IDs: all 21 matched U/P generations had identical input and output token IDs. This is a bounded regression check, not broad quality equivalence. Both builds failed mandatory strict-output cases (mostly Markdown fences or extra prose; two schema rubrics were also underspecified), so the campaign did not advance either to full-context, additional lifecycle or gateway candidate qualification. No runtime safety failure occurred in the U/P comparison, and the original production configuration was restored. The patch remains an upstream correctness contribution, not a qualified production performance recommendation.

HIP/SYCL builds are still untested; this PR remains draft. The independent Linux md/NVMe planner assumption is reported separately and is not part of this patch.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/4538 **Author:** [@cmdruid](https://github.com/cmdruid) **Created:** 10/28/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `bench/prefetch-benefit-retry` --- ### 📝 Commits (1) - [`48f6fd4`](https://github.com/Niko1221/Strata/commit/48f6fd4f68f9320caa0619cb6b007aab48fbaa22) [Engine] retain benefit closure reason for periodic prefetch retry ### 📊 Changes **3 files changed** (+162 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `docs/DETAILS.md` (+2 -0) 📝 `src/core/expert_source.cpp` (+3 -1) ➕ `tools/test_prefetch_gate.py` (+157 -0) </details> ### 📄 Description A prefetch gate closed for low benefit can stay closed indefinitely at a stable cache-room ratio inside the 0.55–0.65 hysteresis band. The next decision incorrectly clears the benefit reason by applying the capacity-reopening threshold. Preserve that reason so the existing 256-window probe runs; a real capacity drop still cancels the probe and requires recovery above the high watermark. Fixes #4537. This changes one decision expression, documents the distinction, and adds a CPU regression test that compiles the production decision method with synthetic capacity/counter inputs. No new state, switches, defaults or call sites are introduced. Validation at commit `48f6fd4`, based on release `5e8a4cca7d690ac60ca37eb09e7d0e010099ad6d`: - Passed: `python3 tools/test_prefetch_gate.py`: **31 checks, 0 failures**. Includes exact threshold edges, a real capacity drop during a pending benefit retry, repeated benefit closures, unknown room and disabled gating. - Expected failure reproduced: the same test against unpatched release source: **31 checks, 14 failing assertions**. These are assertions across scenarios, not 14 independent production incidents. - Passed: CUDA Release build with `STRATA_ENABLE_CUDA=ON`, `CMAKE_CUDA_ARCHITECTURES=120`; unchanged toolchain and flags for unpatched/patched controls, GGML `3cf03257f219afbe7334045ff7c6a06ac68c627d`. - Passed: `conversation_cache_test`, `conversation_split_failure_test`, `conversation_memory_test`, `conversation_file_test`, `session_save_reclaim_test` (5/5). - Passed: `python3 -B -m unittest serve.test_context_overflow serve.test_chat_tool_results serve.test_quiet_cancel serve.test_request_accounting serve.test_session_save_retry` (39 tests). - Not run: HIP/SYCL builds or execution; those toolchains/devices are unavailable. Kept draft pending the backend checks required by CONTRIBUTING.md. Hardware qualification on two RTX 5070 Ti cards is ongoing and will be reported separately from CPU proof. No measured speedup or broad output-equivalence claim is made at submission. The state-transition test does not exercise the full expert source, concurrency or real memory pressure. Targeted HIP/SYCL build help would be useful before marking this ready for review. AI assistance was used for investigation and implementation; the results above were executed locally and checked against retained output. ## Local CUDA qualification results (2026-10-28) Four independent-boot U/P pairs, ordered UP, PU, PU, UP, on two RTX 5070 Ti 16 GiB cards. U and P use the same CUDA 13.2 Release build, architecture 120, serving layer, weights, expert seed, 262144 context/int8 KV, native MTP spec 4 / threshold 0.5, mmap, prompt checkpoints, and RAM conversation parking. Each boot had cold ~16K input, a natural ~24K appended input with 4096 output tokens, a cached 512-token follow-up, another session, and return to the first. OS caches were preserved; the memory guard was 40 GiB / no swap. | Pair | Long decode U / P, tokens/s | Cached follow-up U / P, tokens/s | |---|---:|---:| | 1 | 32.0 / 69.9 | 29.7 / 59.7 | | 2 | 72.7 / 76.9 | 61.2 / 61.4 | | 3 | 76.1 / 76.9 | 62.0 / 59.6 | | 4 | 72.7 / 72.0 | 60.3 / 62.3 | The median paired changes are +3.41% / +1.82%, below the predeclared 10% target. An identical-build four-boot check with identical inputs and outputs ranged from 667.8 to 1202.7 tokens/s in cold prefill and 49.8 to 70.8 tokens/s in 512-token decode. **No meaningful throughput improvement is established.** The first slow U run had an open gate with zero closures, 540.4 GB of OS reads and 83.4 seconds of fetch wait; later runs read much less. Other U and P runs both closed and reopened their gates. The GPU sequence did not isolate the stable-band retry failure proven by the CPU regression test. Aggregate end-of-request ratios/flip counts do not prove the reason for a particular closure. A frozen 16-task quality panel compared native token IDs: **all 21 matched U/P generations had identical input and output token IDs**. This is a bounded regression check, not broad quality equivalence. Both builds failed mandatory strict-output cases (mostly Markdown fences or extra prose; two schema rubrics were also underspecified), so the campaign did not advance either to full-context, additional lifecycle or gateway candidate qualification. No runtime safety failure occurred in the U/P comparison, and the original production configuration was restored. The patch remains an upstream correctness contribution, not a qualified production performance recommendation. HIP/SYCL builds are still untested; this PR remains draft. The independent Linux md/NVMe planner assumption is reported separately and is not part of this patch. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#5080
No description provided.