[KVCache] Support environment variable overrides for AttentionStore c…#7455
[KVCache] Support environment variable overrides for AttentionStore c…#7455jackyYang6 wants to merge 1 commit intoPaddlePaddle:developfrom
Conversation
|
Thanks for your contribution! |
PaddlePaddle-bot
left a comment
There was a problem hiding this comment.
🤖 AI Code Review |
2026-04-17 11:36 CST
📋 Review 摘要
PR 概述:为 AttentionStoreConfig 的 namespace、pod_name、model_version 字段新增环境变量覆盖能力,方便 K8s 部署场景。
变更范围:cache_manager/transfer_factory/mooncake_store/attention_store.py
影响面 Tag:KVCache
问题
| 级别 | 文件 | 概述 |
|---|---|---|
| 🟡 建议 | attention_store.py:66-69 |
日志在环境变量覆盖之前打印,记录的配置值与实际使用值不一致 |
详细说明
当前代码在第 66 行先打印了 self.config,然后在第 67-69 行才用环境变量覆盖 namespace/pod_name/model_version。这意味着日志中记录的是覆盖前的值,而非实际传给 AttentionStoreSDK 的值。在 K8s 环境排查问题时,这会导致日志与实际行为不一致,增加调试难度。
建议:将环境变量覆盖逻辑移到 logger.info 之前,或者在覆盖之后补充一条日志记录最终生效的配置:
self.config.namespace = os.getenv("MODEL_ID", self.config.namespace)
self.config.pod_name = os.getenv("FD_POD_NAME", self.config.pod_name)
self.config.model_version = os.getenv("KVCACHE_VERSION", self.config.model_version)
logger.info(f"[INIT] Start initializing AttentionStoreSDK with config: {self.config}")总体评价
变更简洁明确,环境变量优先于构造函数参数的策略符合 K8s 部署惯例,且未设置环境变量时保持原有默认行为,不会引入 breaking change。建议修正日志打印顺序以确保可观测性准确。
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #7455 +/- ##
==========================================
Coverage ? 73.47%
==========================================
Files ? 398
Lines ? 54979
Branches ? 8613
==========================================
Hits ? 40398
Misses ? 11873
Partials ? 2708
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
9fbff4a to
8407b8a
Compare
|
|
||
| try: | ||
| self.config.namespace = os.getenv("MODEL_ID", self.config.namespace) | ||
| self.config.pod_name = os.getenv("FD_POD_NAME", self.config.pod_name) |
There was a problem hiding this comment.
这个Pod Name 需要和上报给IC 和 IM 的pod name 对齐吗?
Motivation
AttentionStore's
namespace,pod_name, andmodel_versionare currently only configurable via constructor arguments. In K8s deployments, these values are typically derived from Pod environment variables (e.g.,MODEL_ID,FD_POD_NAME,KVCACHE_VERSION). Without environment variable overrides, deployment configuration is inflexible.Modifications
Modified file:
fastdeploy/cache_manager/transfer_factory/mooncake_store/attention_store.pyAdded environment variable overrides for
AttentionStoreConfigfields before SDK initialization inAttentionStore.__init__:Usage or Command
Set the corresponding environment variables before launching the service:
Accuracy Tests
Not applicable — this change does not affect model outputs.
Checklist
pre-commitbefore commit.releasebranch, make sure the PR has been submitted to thedevelopbranch, then cherry-pick it to thereleasebranch with the[Cherry-Pick]PR tag.