[GH-ISSUE #4537] [Engine] benefit-triggered prefetch closure loses its periodic retry inside the capacity hysteresis band #2049

Closed
opened 2026-11-04 01:56:14 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @cmdruid on GitHub (Oct 28, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/4537

A benefit-triggered prefetch closure can lose its periodic retry while the cache-room ratio stays between the low and high watermarks. I reproduced this with the actual FileExpertSource::gate_capacity() method compiled into a small CPU state-transition test. This is a reproduced controller defect; its contribution to GPU throughput is still being measured.

Affected code checked: 011c9e600a93bbc9fd451c563501b5831c32bbca (installed 0.2.2 / engine 0.1.47), release 5e8a4cca7d690ac60ca37eb09e7d0e010099ad6d (v0.2.7 / Linux engine 0.1.52), and main 46c152a1310f77cd2f0ce2c7cd213962df14fe83. The decision method is identical in these revisions.

Reproduction:

  1. Start with an open gate, default watermarks 0.55/0.65, and a constant cache-room ratio of 0.62 or 0.64.
  2. Supply prefetch counters with low usefulness, or sufficiently low volume, to trigger a benefit closure.
  3. Continue decode windows with capacity unchanged.

Expected: retain the benefit closure reason and probe again after 256 windows, unless actual capacity falls below the low watermark.

Actual: on the next decision after closure, open is false, so room_ok requires the high watermark. Inside the hysteresis band this is false and clears gate_useless_. The retry branch is then unreachable until capacity rises above the high watermark. In the test, it never reopens across 3,000 windows. Above the high watermark, the same benefit closure retries as intended.

The focused candidate uses the low watermark while a benefit closure is pending, preserving the existing high-watermark requirement for a real capacity closure. A drop below the low watermark cancels the pending benefit retry. The test covers threshold edges, a capacity drop during the retry interval, repeated benefit closures, unknown capacity and a disabled gate.

Reproducible test and candidate: tools/test_prefetch_gate.py.

python3 tools/test_prefetch_gate.py
git show 5e8a4cca7d690ac60ca37eb09e7d0e010099ad6d:src/core/expert_source.cpp > /tmp/expert_source_unpatched.cpp
python3 tools/test_prefetch_gate.py --source /tmp/expert_source_unpatched.cpp

Observed: patched 31 checks, 0 failures; unpatched 31 checks, 14 failing assertions. The test extracts the production method verbatim; the surrounding capacity/counter inputs are synthetic. It is not a full-engine or GPU throughput test.

Environment for the ongoing hardware qualification: Linux, two RTX 5070 Ti 16 GiB cards, Qwen3.8-Flash-Next UD-IQ4_XS, native MTP 4, 262144 context, int8 KV, mmap experts, prompt checkpoints and RAM conversation caching enabled, 40 GiB cgroup memory limit and zero swap. Earlier production logs showed persistent closure and slower decode, but did not establish the original closure reason. No throughput improvement is claimed here.

Validation completed: CUDA sm_120 release builds of both controls; five focused C++ conversation/session tests; 39 serving/context/tool/cancellation/accounting tests. HIP and SYCL environments are unavailable, so the accompanying PR will remain draft. The fix adds no shared mutable state and does not change the gate's call site or atomic publication.

Related search: open/closed prefetch-gate discussions and PR #3324 were checked. That benchmark covers file-tier cost on a fully cacheable model; it does not cover this lost benefit-retry state.

Originally created by @cmdruid on GitHub (Oct 28, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/4537 A benefit-triggered prefetch closure can lose its periodic retry while the cache-room ratio stays between the low and high watermarks. I reproduced this with the actual `FileExpertSource::gate_capacity()` method compiled into a small CPU state-transition test. This is a reproduced controller defect; its contribution to GPU throughput is still being measured. Affected code checked: `011c9e600a93bbc9fd451c563501b5831c32bbca` (installed 0.2.2 / engine 0.1.47), release `5e8a4cca7d690ac60ca37eb09e7d0e010099ad6d` (v0.2.7 / Linux engine 0.1.52), and main `46c152a1310f77cd2f0ce2c7cd213962df14fe83`. The decision method is identical in these revisions. Reproduction: 1. Start with an open gate, default watermarks 0.55/0.65, and a constant cache-room ratio of 0.62 or 0.64. 2. Supply prefetch counters with low usefulness, or sufficiently low volume, to trigger a benefit closure. 3. Continue decode windows with capacity unchanged. Expected: retain the benefit closure reason and probe again after 256 windows, unless actual capacity falls below the low watermark. Actual: on the next decision after closure, `open` is false, so `room_ok` requires the high watermark. Inside the hysteresis band this is false and clears `gate_useless_`. The retry branch is then unreachable until capacity rises above the high watermark. In the test, it never reopens across 3,000 windows. Above the high watermark, the same benefit closure retries as intended. The focused candidate uses the low watermark while a benefit closure is pending, preserving the existing high-watermark requirement for a real capacity closure. A drop below the low watermark cancels the pending benefit retry. The test covers threshold edges, a capacity drop during the retry interval, repeated benefit closures, unknown capacity and a disabled gate. Reproducible test and candidate: [tools/test_prefetch_gate.py](https://github.com/cmdruid/Strata/blob/48f6fd4/tools/test_prefetch_gate.py). ```sh python3 tools/test_prefetch_gate.py git show 5e8a4cca7d690ac60ca37eb09e7d0e010099ad6d:src/core/expert_source.cpp > /tmp/expert_source_unpatched.cpp python3 tools/test_prefetch_gate.py --source /tmp/expert_source_unpatched.cpp ``` Observed: patched **31 checks, 0 failures**; unpatched **31 checks, 14 failing assertions**. The test extracts the production method verbatim; the surrounding capacity/counter inputs are synthetic. It is not a full-engine or GPU throughput test. Environment for the ongoing hardware qualification: Linux, two RTX 5070 Ti 16 GiB cards, Qwen3.8-Flash-Next UD-IQ4_XS, native MTP 4, 262144 context, int8 KV, mmap experts, prompt checkpoints and RAM conversation caching enabled, 40 GiB cgroup memory limit and zero swap. Earlier production logs showed persistent closure and slower decode, but did not establish the original closure reason. No throughput improvement is claimed here. Validation completed: CUDA `sm_120` release builds of both controls; five focused C++ conversation/session tests; 39 serving/context/tool/cancellation/accounting tests. HIP and SYCL environments are unavailable, so the accompanying PR will remain draft. The fix adds no shared mutable state and does not change the gate's call site or atomic publication. Related search: open/closed prefetch-gate discussions and PR #3324 were checked. That benchmark covers file-tier cost on a fully cacheable model; it does not cover this lost benefit-retry state.
Author
Owner

@Niko1221 commented on GitHub (Nov 5, 2026):

Thanks for taking the time to report this.

Strata has changed a lot since this was opened, and 0.2.11 is out now, so many older reports no longer apply. We're closing issues older than a week that have had no new reports in the last week. Closed here does not mean rejected.

To reopen it takes about two minutes:

  1. Re-test on 0.2.11. It may already be fixed. Write down what you see.
  2. Start the title with its area: [Engine], [GUI], [TUI], [Benchmark], [Docs] or [Other].
  3. Fill in the parts of the issue form: what happened, the Strata version, your graphics card, memory and system.
  4. Comment /reopen. A check runs and either reopens the issue or lists what is still missing.

The rules are in CONTRIBUTING.md.

<!-- gh-comment-id:6660631901 --> @Niko1221 commented on GitHub (Nov 5, 2026): Thanks for taking the time to report this. Strata has changed a lot since this was opened, and 0.2.11 is out now, so many older reports no longer apply. We're closing issues older than a week that have had no new reports in the last week. Closed here does not mean rejected. To reopen it takes about two minutes: 1. Re-test on 0.2.11. It may already be fixed. Write down what you see. 2. Start the title with its area: [Engine], [GUI], [TUI], [Benchmark], [Docs] or [Other]. 3. Fill in the parts of the issue form: what happened, the Strata version, your graphics card, memory and system. 4. Comment `/reopen`. A check runs and either reopens the issue or lists what is still missing. The rules are in [CONTRIBUTING.md](https://github.com/Niko1221/Strata/blob/main/CONTRIBUTING.md).
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#2049
No description provided.