Skip to content

Fix ATOMesh KV-cache counters / 修复 ATOMesh KV-cache 计数 - #4397

Open
chunfangamd wants to merge 4 commits into
mainfrom
chun/fix-atomesh-cache-counters
Open

chunfangamd wants to merge 4 commits into
mainfrom
chun/fix-atomesh-cache-counters

Conversation

@chunfangamd

@chunfangamd chunfangamd commented Oct 22, 2026 •

Copy link
Copy Markdown
Collaborator

ATOM P/D exports report prompt counters on both prefill and decode. Counting both dilutes the hit rate; using LMCache transfer tokens for CPU reuse also measures the wrong quantity.

Count prefill/unified counters once, read CPU reuse from prefix_cache_offload_tokens, and include GPU + CPU in overall. For prefill full=1000, GPU=600, CPU=100, the result is 60% / 10% / 70%; decode's repeated full=1000 is excluded. Validate each endpoint/label domain before summing so another engine cannot hide invalid reuse. With KV_OFFLOADING=none, missing CPU domains are zero only when present values are valid zeros; otherwise CPU/overall remain unavailable.

This is the counter layer. #4405 adds modern-export qualification; together they replace closed #3964. No historical window reconstruction or serving recipe changes. Real modern P/D with nonzero offload remains unverified. Measured-pricing deployment also needs the consumer protection in app #1377 or an equivalent maintainer-approved isolation.

中文

ATOM 的 P/D 两端都可能上报 prompt counter,累加会重复计算分母;LMCache 传输量也不能代表 CPU 复用。本层只统计 prefill/unified,用 offload counter 计算 CPU,overall 为 GPU+CPU。示例 full=1000、GPU=600、CPU=100 得到 60%/10%/70%,排除 decode 重复分母。

先逐 endpoint/标签域校验,再汇总;关闭 offload 时,仅在已有值都是合法零且域匹配的情况下补缺失零。坏值、非零矛盾或额外域不会获得 CPU/overall 数值。

本层与 #4405 的现代数据资格层一起替代已关闭的 #3964;不重建历史窗口、不改 serving 配方。真实现代 P/D+非零 offload 尚未验证;计价上线仍依赖 app #1377 或维护者接受的等价隔离。

AI model disclosure

GPT-6 (Codex), including delegated implementation and independent review agents, prepared and checked these revisions. A finer runtime model identifier is not exposed. Earlier producer/app work was prepared by an agent reporting Claude Opus 5.5; that historical runtime identifier could not be independently verified.

仅汇总 prefill/unified 缓存计数,CPU reuse 使用 offload counter,
overall 合并 GPU 和 CPU reuse;缺少增量或角色时保留未知值。
@chunfangamd
chunfangamd marked this pull request as ready for review October 22, 2026 07:49
@chunfangamd
chunfangamd requested a review from a team October 22, 2026 07:49
@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

inferencex-e2e/infx diff: +479 -21

Generally most InferenceX submissions don't need to add changes to the infx package. On the off chance they do, generally the diff is small. Please prompt your agent to clean your PR to keep your diff to only necessary & minimal changes too. We have an increased code quality bar for changes to the infx package.

中文

大多数 InferenceX 提交通常不需要修改 infx 包。即使确实需要,改动通常也很小。请让你的 agent 清理 PR,使改动只包含必要且最小的内容。infx 包的改动有更高的代码质量要求。

@claude

claude Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @chunfangamd's task in 59s —— View job


LGTM - no blocking issues found.

I traced the new endpoint-role path from start to finish:

  • endpoint_roles_from_env builds the http://{endpoint}/metrics keys the same way infx/bench/agentic/replay.py:_server_metrics_urls does, so the endpoint_url filters match.
  • The Atomesh P/D recipe (dsv4/atom/mi355x-fp4/agentx) takes the SRT_PREFILL_ENDPOINTS/SRT_DECODE_ENDPOINTS branch. It does not hit the AIPERF_SERVER_METRICS_URLS or dynamo fallback, and no ATOM recipe sets either.
  • A missing, ambiguous or invalid counter now produces None instead of a partial sum.

One thing I could not check: the new CPU source only works if ATOM workers with lmcache_offload actually emit prefix_cache_offload_tokens. If they don't, the CPU and overall rates come out None. Your PR description already says live serving is unverified.

I could not run the tests (pytest needed approval in this environment), and no perf-changelog entry is needed because nothing here changes what a benchmark runs.

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Findings marked 🟡 are optional suggestions and need no follow-up push.

Comment thread inferencex-e2e/infx/results/agentic/backends/atom.py
Comment thread inferencex-e2e/infx/results/agentic/server_metrics.py Outdated
仅在确认关闭 CPU offload 且无计数器时补零,保留单端点自定义 metrics 的角色回退,并从输入总量中排除 decode 重复计数。补充相应行为回归。
中文:同步当前 main,保留 ATOM 缓存计数修复与上游 KV 使用率处理。
中文:按端点与完整标签域校验缓存分层计数;仅在 CPU offload 明确关闭且现有计数均为零时补齐缺失零值,拒绝无效或矛盾的 offload 数据。
Jasen2201 added a commit that referenced this pull request Oct 26, 2026
…ult tooling

#3964 was closed in favour of #4397, so the cherry-picked ATOM cache
accounting goes back to main's version; #4397 is merged next.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Jasen2201 added a commit that referenced this pull request Oct 26, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant