fix(pd): avoid first-token cache stats race - #1450
Open
sufubao wants to merge 14 commits into
Open
Conversation
sufubao
force-pushed
the
fix/pd-first-token-cache-stats-race
branch
from
August 9, 2026 11:55
3b2e8a4 to
3d3773d
Compare
sufubao
force-pushed
the
fix/pd-first-token-cache-stats-race
branch
from
August 10, 2026 12:47
958df35 to
729ed9b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
P、D 节点都会上报首 token,PD Master 原先使用先到达的一份。D 先到时,P 首 token 携带的 CPU/磁盘缓存命中会被丢弃,导致 OpenAI
cached_tokens偏低;实测缓存命中率从 59.90% 被误报为 28.95%。直接等待 P 也不安全:如果 P 转发异常,已经完成的 D 输出会一直被缓存,请求无法结束。
修改
prompt_cache_len更新后续 D token,并丢弃重复的 D 首 token;验证