mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #5318] [CLOSED] [Engine] Preserve external cache and sum prefill work across BYIELD #5384
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#5384
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/5318
Author: @YusenZhang0601
Created: 11/5/2026
Status: ❌ Closed
Base:
main← Head:codex/fix-prefill-yield-accounting📝 Commits (1)
82ffb65Fix external cache and prefill accounting across prompt yields📊 Changes
2 files changed (+149 additions, -0 deletions)
View changed files
📝
serve/server.py(+17 -0)➕
serve/test_yield_accounting.py(+132 -0)📄 Description
Problem and result
A prompt read can yield through BYIELD and resume more than once within one API request. The later DONE then reports a larger reused prefix because it includes work performed earlier in that same request. The server publishes that internal prefix as external cached input and loses earlier prompt time.
I reproduced this on base
9f7d977d220e9fdf2ec53cf2620cdadac1cfb24ewith the real Service and StrataEngine over a subprocess fake native engine. Three of four new regressions fail on the base. For example, the solo-yield request reports 384 cached tokens although only 3 preceded the request. Cancellation after two yields records(128, 64, 64)for input/cache/read instead of(128, 3, 125).The fix retains DONE records from yielded reads, preserves the original external cache boundary, sums their work and excludes the final DONE from the earlier list when cancellation ends on that exact record.
Related work and scope
I checked the existing discussions, including #1603, #2275 and #5307. This addresses prompt-read/cache accounting across BYIELD. #5307 addresses admission/slot decode accounting. Both touch the request finalizer, so the textual hunk there needs reapplication when combining them. I also reapplied this fix on #5307 commit
08519d46405ec720cda411f08af556bee54c9df0and ran the combined regressions successfully.The existing two-yield budget is preserved. This PR adds 17 lines to the Python server and a focused regression module.
Validation
On macOS arm64, Python 3.14.6, in a project-local virtual environment using the repository-pinned regex and Jinja2 packages.
Passed
python -B -m unittest serve.test_yield_accounting serve.test_request_accounting -v— 14 tests, 10.783 s.python -B -m unittest serve.test_parallel serve.test_yield_accounting serve.test_request_accounting -v— 62 tests, 59.380 s.git diff --check.Failed controls and setup attempts
Remaining validation
GPU/model execution and Windows runtime testing remain unperformed for this upstream port. The reproduction uses synthetic local input and a Python fake producer. The native engine sources and wire format are outside this patch.
I developed the original fix during local deployment research and used AI assistance to prepare this focused port and its validation. Thank you for reviewing it.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.