Pull Request已成功合入, 合并人@CANN-robot
(感谢 lining23666 的贡献)变更摘要
本次 PR 旨在清理 dflow 模块中 decoder KV cache 的废弃代码。由于 SetDecoderKvCache 从未被调用,导致 decoder_kv_caches_ 始终为空,GetDecoderKvCache() 的三处调用均存在越界访问的未定义行为。变更从 KvCacheManager 类中彻底移除了与 decoder KV cache 相关的所有方法声明/定义、成员变量及析构清理逻辑,并同步删除了 LlmCommEntity 中的三个调用点。
主要改动
- 移除
KvCacheManager中 8 个 decoder KV cache 方法: 在kv_cache_manager.h和kv_cache_manager.cpp中删除了QueryDecoderKvCache、SaveDecoderKvCache、ReleaseDecoderKvCache、ReleaseDecoderKvCaches、SetDecoderKvCache、GetDecoderKvCache、ClearDecoderKvCache、GetDecoderKvCacheCount的声明与定义。 - 移除
KvCacheManager中 2 个 decoder 相关成员变量: 删除了decoder_kv_caches_(std::vector<std::shared_ptr<FlowMsg>>)和decoder_req_to_kv_cache_(std::unordered_map),并将mutex_的注释从 "decoder and prompt kv map" 修正为 "prompt kv map"。 - 精简
KvCacheManager析构函数: 在~KvCacheManager()中移除了ClearDecoderKvCache()调用及decoder_req_to_kv_cache_.clear()清理语句,仅保留ClearPromptKvCache()和kv_blocks_tensors_.clear()。 - 删除
LlmCommEntity中 3 处 decoder KV cache 调用点: 在llm_comm_entity.cpp的ReceiveKvCache、GetRecvAddrs、CheckSyncKvMetaInfo三个函数中,移除了基于!enable_paged_attention_条件分支内对KvCacheManager::GetInstance().GetDecoderKvCache()和SaveDecoderKvCache()的调用代码。


Thanks for your pull-request.
The full list of commands accepted by me can be found at here。
You can get sig-info at here
PR Approval Progress
✅ Congratulations! All modules have met the lgtm and approve requirements.
Module Approval Details
| module | lgtm status | approve status |
|---|---|---|
| repo-cann/ge | ✅ zhanj, xchu42, stevenaw0 (3/2) | ✅ zhanj (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
lining23666, thanks for your pull request. All authors of the commits have signed the CLA. 👍


compile


流水线任务触发成功
任务链接 [36d886adc8d44b0da13299b7bc44141d][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| pre_comment | ✅ SUCCESS | >>>>> | |
| Compile_X86_compiler | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_X86_executor | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_X86_dflow | ✅ SUCCESS | >>>>> | >>>>> |
| UT_Test_dflow | ✅ SUCCESS | ||
| UT_Test_ge_common | ✅ SUCCESS | ||
| UT_Test_parser | ✅ SUCCESS | ||
| UT_Test_python | ✅ SUCCESS | >>>>> | |
| UT_Test_rt | ✅ SUCCESS | ||
| UT_Test_acl | ✅ SUCCESS | ||
| UT_Test_autofuse | ✅ SUCCESS | ||
| UT_Test_executor | ✅ SUCCESS | ||
| UT_Test_autofuse_ascendc_api | ✅ SUCCESS | ||
| ST_Test_dflow | ✅ SUCCESS | ||
| ST_Test_ge_common | ✅ SUCCESS | ||
| ST_Test_parser | ✅ SUCCESS | ||
| ST_Test_python | ✅ SUCCESS | >>>>> | |
| ST_Test_rt | ✅ SUCCESS | ||
| ST_Test_autofuse | ✅ SUCCESS | ||
| ST_Test_executor | ✅ SUCCESS | ||
| ST_Test_hetero | ✅ SUCCESS | ||
| ST_Test_autofuse_ascendc_api | ✅ SUCCESS | ||
| ST_Test_autofuse_e2e | ✅ SUCCESS | ||
| UT_Test_fe | ✅ SUCCESS | ||
| UT_Test_tefusion | ✅ SUCCESS | ||
| ST_Test_fe | ✅ SUCCESS | ||
| ST_Test_tefusion | ✅ SUCCESS | ||
| ST_Test_ge_common_atc | ✅ SUCCESS | ||
| UT_Test_Report_graphengine | ✅ SUCCESS | >>>>> | |
| UT_Test_Report_ge_executor_c | ✅ SUCCESS | >>>>> | |
| UT_Test_Report_ge_autofuse | ✅ SUCCESS | >>>>> | |
| ST_Test_Report_graphengine | ✅ SUCCESS | >>>>> | |
| ST_Test_Report_ge_executor_c | ✅ SUCCESS | >>>>> | |
| ST_Test_Report_ge_autofuse | ✅ SUCCESS | >>>>> | |
| UT_Test_Report_fe | ✅ SUCCESS | >>>>> | |
| ST_Test_Report_fe | ✅ SUCCESS | >>>>> |
[2026-07-08 18:14:16] CI执行结束


流水线任务触发成功
任务链接 [6b5a7b5e2cfa4287b4a4696515841f39][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| pre_comment | ✅ SUCCESS | >>>>> | |
| Compile_ARM_compiler | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_ARM_executor | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_ARM_dflow | ✅ SUCCESS | >>>>> | >>>>> |
| API_Check | ✅ SUCCESS | >>>>> | |
| PreSmoke_A900_npupool | ✅ SUCCESS | >>>>> |
[2026-07-08 17:47:50] CI执行结束


流水线任务触发成功
任务链接 [b2ebf19b206c4ac2a39f992a9bfb64ab][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| codecheck_Pr | ✅ SUCCESS | ||
| codecheck | ✅ SUCCESS | >>>>> | |
| antipoison | ✅ SUCCESS | >>>>> | |
| SCA | ✅ SUCCESS | >>>>> | |
| codecheck_dt | ✅ SUCCESS | >>>>> | |
| codecheck_precommit | ✅ SUCCESS | >>>>> | |
| StaticCheck_codespell_check | ✅ SUCCESS | ||
| StaticCheck_link_validity_check | ✅ SUCCESS | ||
| StaticCheck_resource_existence_check | ✅ SUCCESS | ||
| StaticCheck_tag_closed_check | ✅ SUCCESS | ||
| StaticCheck_markdownlint | ✅ SUCCESS |
[2026-07-08 17:46:23] CI执行结束


compile


流水线任务触发成功
任务链接 [7a8be4c466504e95bd01a17d869801ff][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| pre_comment | ✅ SUCCESS | >>>>> | |
| Compile_X86_compiler | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_X86_executor | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_X86_dflow | ✅ SUCCESS | >>>>> | >>>>> |
| UT_Test_dflow | ✅ SUCCESS | ||
| UT_Test_ge_common | ✅ SUCCESS | ||
| UT_Test_parser | ✅ SUCCESS | ||
| UT_Test_python | ✅ SUCCESS | >>>>> | |
| UT_Test_rt | ✅ SUCCESS | ||
| UT_Test_acl | ✅ SUCCESS | ||
| UT_Test_autofuse | ✅ SUCCESS | ||
| UT_Test_executor | ✅ SUCCESS | ||
| UT_Test_autofuse_ascendc_api | ✅ SUCCESS | ||
| ST_Test_dflow | ✅ SUCCESS | ||
| ST_Test_ge_common | ✅ SUCCESS | ||
| ST_Test_parser | ✅ SUCCESS | ||
| ST_Test_python | ✅ SUCCESS | >>>>> | |
| ST_Test_rt | ✅ SUCCESS | ||
| ST_Test_autofuse | ✅ SUCCESS | ||
| ST_Test_executor | ✅ SUCCESS | ||
| ST_Test_hetero | ✅ SUCCESS | ||
| ST_Test_autofuse_ascendc_api | ✅ SUCCESS | ||
| ST_Test_autofuse_e2e | ✅ SUCCESS | ||
| UT_Test_fe | ✅ SUCCESS | ||
| UT_Test_tefusion | ✅ SUCCESS | ||
| ST_Test_fe | ✅ SUCCESS | ||
| ST_Test_tefusion | ✅ SUCCESS | ||
| ST_Test_ge_common_atc | ✅ SUCCESS | ||
| UT_Test_Report_graphengine | ✅ SUCCESS | >>>>> | |
| UT_Test_Report_ge_executor_c | ✅ SUCCESS | >>>>> | |
| UT_Test_Report_ge_autofuse | ✅ SUCCESS | >>>>> | |
| ST_Test_Report_graphengine | ✅ SUCCESS | >>>>> | |
| ST_Test_Report_ge_executor_c | ✅ SUCCESS | >>>>> | |
| ST_Test_Report_ge_autofuse | ✅ SUCCESS | >>>>> | |
| UT_Test_Report_fe | ✅ SUCCESS | >>>>> | |
| ST_Test_Report_fe | ✅ SUCCESS | >>>>> |
[2026-07-09 09:38:29] CI执行结束


流水线任务触发成功
任务链接 [defac4bb3fd44f6384b4fa60fa81435d][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| pre_comment | ✅ SUCCESS | >>>>> | |
| Compile_ARM_compiler | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_ARM_executor | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_ARM_dflow | ✅ SUCCESS | >>>>> | >>>>> |
| API_Check | ✅ SUCCESS | >>>>> | |
| PreSmoke_A900_npupool | ✅ SUCCESS | >>>>> |
[2026-07-09 09:32:11] CI执行结束


流水线任务触发成功
任务链接 [1c783476975246269366017b9ac44f23][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| codecheck_Pr | ✅ SUCCESS | ||
| codecheck | ✅ SUCCESS | >>>>> | |
| antipoison | ✅ SUCCESS | >>>>> | |
| SCA | ✅ SUCCESS | >>>>> | |
| codecheck_dt | ❌ FAILED | >>>>> | |
| codecheck_precommit | ✅ SUCCESS | >>>>> | |
| StaticCheck_codespell_check | ✅ SUCCESS | ||
| StaticCheck_link_validity_check | ✅ SUCCESS | ||
| StaticCheck_resource_existence_check | ✅ SUCCESS | ||
| StaticCheck_tag_closed_check | ✅ SUCCESS | ||
| StaticCheck_markdownlint | ✅ SUCCESS |


流水线任务触发成功
任务链接 [5d418586b9434b1f997cb72876c0123b][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| codecheck_Pr | ✅ SUCCESS | ||
| codecheck | ✅ SUCCESS | >>>>> | |
| antipoison | ✅ SUCCESS | >>>>> | |
| SCA | ✅ SUCCESS | >>>>> | |
| codecheck_dt | ✅ SUCCESS | >>>>> | |
| codecheck_precommit | ✅ SUCCESS | >>>>> | |
| StaticCheck_codespell_check | ✅ SUCCESS | ||
| StaticCheck_link_validity_check | ✅ SUCCESS | ||
| StaticCheck_resource_existence_check | ✅ SUCCESS | ||
| StaticCheck_tag_closed_check | ✅ SUCCESS | ||
| StaticCheck_markdownlint | ✅ SUCCESS |
[2026-07-09 15:13:09] CI执行结束


/lgtm


/lgtm


【MR评价】评价分数:3,
评价意见:
编码规范遵守度:无编码规范问题;
代码设计:不涉及代码设计;
DT质量:基本逻辑DT测试覆盖充足;


/approve


Pull Request
描述
KvCacheManager整个类的写入端从未连接到任何调用者:SetDecoderKvCache从未被调用,导致decoder_kv_caches_始终为空,GetDecoderKvCache()的 3 处调用均为越界访问(UB)SaveKvCacheForPrompt/SaveKvBlocksTensor/InitBlockTensors等写入方法均从未被调用,导致req_id_to_cache_id_/kv_blocks_tensors_等成员变量永远为空,读取端要么 no-op 要么越界 UB删除整个
KvCacheManager类及相关代码:kv_cache_manager.h和kv_cache_manager.cpp(整个类,含 17 个方法 + 所有成员变量)QueryPromptKvCache的 else 分支、CheckKvCacheManagerReq方法、ReleaseKvCacheForPrompt的 else 分支CheckKvCacheManagerReq声明GetRecvAddrs和CheckSyncKvMetaInfo中QueryKvBlocksTensors调用分支#include "llm_common/kv_cache_manager.h"变更类型
请选择本次引入的变更类型:
关联的Issue
如何测试
bash build.sh --dflow,确认修改文件在-Wall -Wextra -Werror下编译无错误ut_built_in_flow_func,92 个用例全部 PASSEDst_built_in_flow_func,73 个用例全部 PASSED核对清单
其他信息
KvCacheManager 中存活方法的数据流分析表明:所有写入端方法(
SaveKvCacheForPrompt、SaveKvBlocksTensor、AddKvCache、ShrinkKvCacheForPrefix等)均从未被调用,导致读取端方法(QueryPromptKvCache、QueryKvBlocksTensors、ReleaseKvCacheForPrompt)因数据源为空而实际为 no-op 或 UB。整个类无实际功能,全部删除。