Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
9e1d0d9
feat: add cluster deployment and benchmark script
chaomeiyan Mar 22, 2026
2fa6497
feat: implement S3-FIFO eviction strategy for KVCache workloads
chaomeiyan Mar 22, 2026
1d4f5a7
feat: add lock-free Bloom filter for ExistKey fast path
chaomeiyan Mar 22, 2026
18f60f3
feat: implement PmemBufferAllocator for PMEM storage tier
chaomeiyan Mar 22, 2026
3d083ef
feat: add bloom filter to GetReplicaList + bloom filter benchmark
yanchaomei Mar 22, 2026
ccef41a
fix: correct BatchPutStart signature in bloom_filter_bench
yanchaomei Mar 22, 2026
fc6b851
perf: optimize bloom filter - precompute hashes, reduce to 3 hash fun…
yanchaomei Mar 22, 2026
05d5280
docs: update benchmark results with bloom filter A/B comparison
yanchaomei Mar 22, 2026
9338517
docs: add competition story document with benchmark evidence
yanchaomei Mar 22, 2026
f85dec7
feat: implement adaptive cache scheduler for workload-aware eviction
yanchaomei Mar 22, 2026
7347799
fix: add default constructor for AdaptiveCacheScheduler (gcc-11 compat)
yanchaomei Mar 22, 2026
cc3667b
test: add unit tests for S3-FIFO and Bloom Filter
yanchaomei Mar 22, 2026
4255d9c
fix: remove duplicate InitGoogleLogging in test SetUp
yanchaomei Mar 22, 2026
e53d775
test: all 16 unit tests passing (S3-FIFO 10/10, Bloom Filter 6/6)
yanchaomei Mar 22, 2026
90a90c9
feat: add adaptive scheduler benchmark with 3-phase LLM workload sim
yanchaomei Mar 22, 2026
b1a5536
docs: grind round 2 - adaptive scheduler mode switching verified
yanchaomei Mar 22, 2026
4de7cc1
feat: counting bloom filter + prefix-aware radix tree index
yanchaomei Mar 22, 2026
f3f9d99
feat: add end-to-end SGLang + HiCache benchmark script and deploy guide
yanchaomei Mar 22, 2026
7c52e4e
feat: end-to-end SGLang + HiCache + Mooncake Store benchmark results
yanchaomei Mar 22, 2026
a5ebf4e
feat: comprehensive optimization comparison benchmark and report
yanchaomei Mar 22, 2026
104fe15
feat: hot path optimization — deferred lease grant + hash reuse
yanchaomei Mar 22, 2026
9f7de44
feat: harden Mooncake Store prefix reuse and E2E validation
yanchaomei Jul 10, 2026
940b62d
merge: sync Mooncake optimization branch with upstream main
yanchaomei Jul 10, 2026
2eb0aa3
chore: ignore local Claude backup directory
yanchaomei Jul 10, 2026
e671f2d
chore: satisfy CI formatting and typos gates
yanchaomei Jul 10, 2026
a1d40e7
fix(store): 修复自适应回收参数的 CI 编译失败
yanchaomei Jul 11, 2026
16ce758
fix(store): 补齐前缀复用测试的租户参数
yanchaomei Jul 11, 2026
7367673
fix(store): 修复本地盘副本索引与快照回收配置
yanchaomei Jul 11, 2026
ac21439
fix(store): 稳定快照持久化的租约与回收视图
yanchaomei Jul 11, 2026
86c05d4
fix(store): 避免自动快照子进程重复获取快照锁
yanchaomei Jul 11, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,9 @@ _codeql_detected_source_root

# CodeBuddy Memory
.codebuddy/
contest_info/
.claude/.claude_backup/
.gstack/

# core dumps
core_*
Expand Down
5 changes: 4 additions & 1 deletion .typos.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[default]
extend-ignore-words = ["CANN", "ASO", "fre", "wqs", "hsa"]
extend-ignore-words = ["CANN", "ASO", "fre", "wqs", "hsa", "FPR", "fpr", "Pris"]

[default.extend-words]
CANN = "CANN"
Expand All @@ -10,6 +10,9 @@ wqs = "wqs"
# ROCm dmabuf MR registration path.
hsa = "hsa"
HPE = "HPE"
FPR = "FPR"
fpr = "fpr"
Pris = "Pris"

[files]
extend-exclude = [
Expand Down
256 changes: 256 additions & 0 deletions IDEA_REPORT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,256 @@
# Idea Discovery Report

**Direction**: KV Cache Storage Optimization (Mooncake Store)
**Date**: 2026-03-23
**Pipeline**: research-lit → idea-creator → novelty-check → filtering
**Current Score**: 72 → **Target**: 85+

## Executive Summary

通过文献调研和代码分析,发现 **场景适配性(25%权重)是最大短板**(当前仅有微基准,无 SGLang+HiCache 端到端验证)。推荐 **3 个 P0 优化 + 2 个 P1 优化**,预计可将总分从 72 推到 85+。

**核心推荐**:
1. 🏆 **Prefix-Aware Radix Tree Index** — Store 层前缀感知索引(创新性 +2)✅ **已实现 — 11/11 测试通过**
2. 🏆 **Counting Bloom Filter with Eviction-Aware Rebuild** — 修复淘汰后假阳性累积(技术完整性 +1)✅ **已实现 — 13/13 测试通过**
3. 🏆 **End-to-End SGLang + HiCache Benchmark** — 真实 LLM 负载验证(场景适配性 +3)⏳ 待执行

---

## Literature Landscape

### 研究方向图谱

| 方向 | 代表工作 | 年份 | 关键数据 |
|------|---------|------|---------|
| KV Cache 压缩量化 | KVTC, MiKV, RocketKV | 2024-25 | 20x-40x 压缩,minimal quality loss |
| 分布式 KV 池化 | Mooncake (FAST'25 Best Paper), TokenLake, llm-d | 2024-25 | 87% cache hit, 88% faster TTFT |
| 前缀感知缓存 | SGLang RadixAttention, KVFlow, ChunkAttention | 2024-25 | Radix tree prefix matching |
| 多租户共享 | KVShare, Oneiros, PrefillShare | 2025 | Rolling hash 复用检测 |
| 内存分层 | PrisKV, Dynamo, TraCT (CXL) | 2025 | GPU→DRAM→SSD, <1ms offload |
| 注意力稀疏性 | Pre-hoc Sparsity, TokenSelect | 2025 | 90% retrieval overhead reduction |
| 语义感知淘汰 | KVFlow, SentenceKV | 2025 | 工作流语义指导淘汰 |

### 关键论文

- [Mooncake: A KVCache-centric Disaggregated Architecture for LLM Serving](https://arxiv.org/abs/2407.00079) — FAST'25 Best Paper
- [A Survey on LLM Acceleration based on KV Cache Management](https://arxiv.org/html/2412.19442v3) — 2024 综述
- [KVFlow: Efficient Prefix Caching for Multi-Agent Workflows](https://openreview.net/forum?id=5Iw1nDtYmT) — 前缀树淘汰
- [KV Cache Transform Coding for Compact Storage](https://arxiv.org/abs/2511.01815) — 20x 压缩
- [Multi-tier Dynamic Storage of KV Cache](https://link.springer.com/article/10.1007/s40747-025-02200-4) — 分层存储
- [RadixAttention and SGLang](https://lmsys.org/blog/2024-01-17-sglang/) — Radix tree prefix matching
- [LMCACHE: Efficient KV Cache Layer for Enterprise-Scale LLM Inference](https://lmcache.ai/tech_report.pdf) — 企业级 KV 缓存层

---

## Ranked Ideas

### 🏆 Idea 1: Prefix-Aware Radix Tree Index — RECOMMENDED

**Priority**: P0 | **创新性**: 9/10 | **实现天数**: 5-7 天

**一句话**: 在 Mooncake Store 层添加 Radix Tree 前缀索引,使 GetReplicaList 支持前缀匹配查询,将 SGLang RadixAttention 的前缀复用能力下沉到存储层。

**洞察**: 当前 Mooncake Store 使用 `std::unordered_map<std::string, ObjectMetadata>` 做精确 key 匹配。但 LLM 推理中,不同请求的 KVCache key 具有大量公共前缀(system prompt + shared context)。SGLang 的 RadixAttention 已经在推理框架层面用 radix tree 做前缀匹配,但 Store 层不感知前缀结构,导致:
- 相同前缀的 KVCache 重复存储
- GetReplicaList 无法返回"最长前缀匹配"结果
- 跨请求的前缀复用率低于理论最优

**技术方案**:
```
新增 PrefixRadixTree 索引(不替换原有 HashMap,作为辅助索引):
1. PutEnd 时:同时插入 HashMap 和 RadixTree
2. GetReplicaList 时:
- 精确匹配 → 走 Bloom Filter + HashMap(现有路径)
- 前缀匹配 → 走 RadixTree 找最长前缀 → 返回匹配节点
3. Evict 时:同步删除两个索引
```

**预期效果**:
- 前缀命中率提升 20-40%(多轮对话场景)
- 存储效率提升(相同前缀不重复存储元数据)
- 直接对接 SGLang RadixAttention,端到端验证有据可依

**新颖性验证**: ✅ CONFIRMED
- SGLang 的 RadixAttention 在推理框架层做前缀匹配
- Mooncake Store 目前无前缀感知能力
- **首次将 Radix Tree 前缀索引下沉到分布式 KVCache 存储层** — 论文级创新
- 最接近的工作:KVFlow(树状前缀缓存淘汰),但它是在调度层而非存储层

**风险**: Radix tree 的内存开销需要控制;并发安全需要 reader-writer lock 保护

**评分维度贡献**:
- 创新性: +2(从"合理组合"到"首创应用前沿技术")
- 场景适配性: +1(直接对接 SGLang 前缀缓存协议)

---

### 🏆 Idea 2: Counting Bloom Filter with Eviction-Aware Rebuild — RECOMMENDED

**Priority**: P0 | **创新性**: 7/10 | **实现天数**: 2-3 天

**一句话**: 用 Counting Bloom Filter 替代当前的标准 Bloom Filter,使淘汰操作能正确删除 key,避免假阳性随时间累积导致查询加速效果退化。

**洞察**: 代码分析发现一个关键设计缺陷:
```cpp
// master_service.cpp line 839: PutEnd 注册 key
bloom_filter_.Add(key);

// 但 BatchEvict 中删除 key 时,没有从 bloom filter 中移除!
// → 随着 cache churn,假阳性率持续上升
// → 最终 bloom filter 的加速效果完全消失
```

在 LLM 推理的高 churn 率场景下(大量 KVCache 条目快速创建和淘汰),标准 Bloom Filter 的假阳性率会从初始的 0.004% 迅速上升到 10%+,使得原本 40% 的查询加速优势被完全抵消。

**技术方案**:
```
方案 A(推荐): Counting Bloom Filter
- 每个 bit 改为 4-bit counter
- Add() → increment, Remove() → decrement
- 内存:从 512KB 增加到 2MB(可接受)
- 淘汰时调用 bloom_filter_.Remove(key)

方案 B: 周期性重建
- 定时(如每 10 次 eviction batch)重建 bloom filter
- 遍历所有 shard 的 key 重新 Add
- 优点:内存不增加
- 缺点:重建期间性能下降
```

**预期效果**:
- 长期运行下保持 Bloom Filter 假阳性率 <0.01%
- 持续维持 90% miss ratio 下 40%+ 的查询加速
- 修复一个真实的工程缺陷 — 评委会认可

**新颖性验证**: ⚠️ INCREMENTAL (不是学术创新,但是重要的工程修复)
- Counting Bloom Filter 是已知技术(Fan et al., 2000)
- 但将其应用于 KVCache 淘汰场景的假阳性管理是合理创新

**风险**: 极低。Counting Bloom Filter 是成熟技术。

**评分维度贡献**:
- 技术完整性: +1(修复了 Bloom Filter 的设计缺陷)
- 场景适配性: +0.5(长期运行场景下性能可持续)

---

### 🏆 Idea 3: End-to-End SGLang + HiCache Benchmark — MUST DO

**Priority**: P0 | **创新性**: N/A | **实现天数**: 3-5 天

**一句话**: 搭建 SGLang + HiCache + Mooncake Store 端到端测试环境,用真实 LLM 推理负载验证所有优化的实际效果。

**洞察**: 当前得分最大短板是场景适配性(估分 5/10)。评分标准明确要求:
> 8分: 在 Mooncake Store 层面有可测量的性能提升,明确适配 KVCache 工作负载
> 10分: 在真实 LLM 推理场景(SGLang+HiCache)中端到端验证,性能提升显著

现有验证仅限于:
- 微基准(BatchGetReplicaList)
- 单元测试(S3-FIFO、Bloom Filter)
- 自适应调度器模式切换日志

**缺失**:真实 LLM 请求 → SGLang → HiCache → Mooncake Store 的端到端吞吐量/延迟数据。

**技术方案**:
```
环境:A40_8_node3 (6x A40) + SKV 集群
1. 部署 SGLang (GPU inference) + HiCache (KVCache 管理)
2. 配置 HiCache 使用 Mooncake Store 作为远程 KV 存储
3. 设计 benchmark workload:
- ShareGPT 对话数据集(真实多轮对话)
- 变化 prefix 复用率(模拟不同场景)
4. 测量指标:
- TTFT (Time To First Token)
- Throughput (tokens/sec)
- Cache hit rate (Mooncake Store 层)
- P50/P99 latency
5. 对比:baseline(无优化)vs optimized(全部优化)
```

**预期效果**:
- 场景适配性从 5/10 → 8/10(+3 分 × 25% 权重 = +7.5 分)
- 这是得分提升最大的单一行动

**风险**: 环境部署复杂,需要 GPU + 网络 + 推理框架的联调

**评分维度贡献**:
- 场景适配性: +3(最大提升)
- 技术完整性: +1(完整的端到端验证闭环)

---

### Idea 4: LocalHotCache + S3-FIFO 联合优化 — BACKUP

**Priority**: P1 | **创新性**: 6/10 | **实现天数**: 3-4 天

**一句话**: 将现有的 LocalHotCache(LRU)与 S3-FIFO 统一为两级缓存架构:S3-FIFO 管理元数据淘汰,LocalHotCache 管理热数据本地副本。

**洞察**: 代码分析发现 LocalHotCache 和 S3-FIFO 是独立实现的,没有协调。S3-FIFO 的 Main 队列中的"高频 key"应该自动进入 LocalHotCache,而 S3-FIFO 淘汰的 key 应该同步从 LocalHotCache 中移除。

**预期效果**: 热数据读取跳过 RDMA 传输,延迟降低 50%+

---

### Idea 5: Store-Layer LZ4 Transparent Compression — BACKUP

**Priority**: P1 | **创新性**: 5/10 | **实现天数**: 3-4 天

**一句话**: 在 Put/Get 路径上添加 LZ4 透明压缩,减少内存占用和 RDMA 传输量。

**洞察**: KVCache 数据(float16/bfloat16 tensor)有一定的数值冗余(特别是 attention 值中的大量接近零值)。LZ4 压缩速度极快(~3GB/s),开销可忽略,但可以节省 30-50% 内存。

**预期效果**: 有效缓存容量翻倍,RDMA 传输量减半

---

## Eliminated Ideas

| Idea | Phase | Kill Reason |
|------|-------|-------------|
| Temporal Locality-Aware Prefetching | Phase 2 | 需要 ML 模型,2-3 周内不可行 |
| GPU-CPU KV Cache Tiering | Phase 2 | 错误的架构层 — Store 不直接管 GPU |
| Learned Cache Replacement | Phase 2 | Transformer predictor 过于复杂,训练数据不足 |
| Pipeline-Aware Prefill/Decode Coordination | Phase 2 | 属于推理调度层,非 Store 层 |
| SIMD Bloom Filter | Phase 2 | 提升有限,Bloom Filter 非瓶颈 |
| Adaptive Sequence Length Bucketing | Phase 2 | Store 层不感知 sequence 结构 |
| Multi-Tenant Priority Eviction | Phase 2 | 竞赛场景为单租户 |

---

## Scoring Projection

| 维度 | 权重 | 当前 | Idea 1 (Radix) | Idea 2 (CBF) | Idea 3 (E2E) | 预计总分 |
|------|------|------|----------------|--------------|--------------|---------|
| 创新性 | 35% | 6 | **8** (+2) | 6.5 (+0.5) | 6 | **8** |
| 技术完整性 | 30% | 7 | 7 | **8** (+1) | **8** (+1) | **8** |
| 场景适配性 | 25% | 5 | 6 (+1) | 5.5 (+0.5) | **8** (+3) | **8** |
| 开源规范性 | 10% | 7 | 7 | 7 | 7 | **7** |
| **加权总分** | | **62.5** | | | | **~79** |

加上 P1 优化(Idea 4+5)和文档打磨 → **预计 82-87 分**

---

## Recommended Execution Plan

```
Week 1 (Day 1-5):
[P0] Idea 2: Counting Bloom Filter (2-3 days) — 快速修复,立竿见影
[P0] Idea 1: Prefix-Aware Radix Tree Index (开始设计 + 原型)

Week 2 (Day 6-10):
[P0] Idea 1: Radix Tree 实现 + 测试 + benchmark
[P0] Idea 3: 部署 SGLang + HiCache 端到端环境

Week 3 (Day 11-15):
[P0] Idea 3: 端到端 benchmark 数据采集 + 对比分析
[P1] Idea 4/5: 根据 benchmark 结果选择最有价值的补充优化
[P1] 文档完善:设计文档、PR 描述、CHANGELOG
```

## Next Steps

- [ ] `/contest-grind` 执行下一轮优化(Idea 2: Counting Bloom Filter)
- [ ] `/contest-plan` 细化 Radix Tree 实现方案
- [ ] `/run-experiment` 部署 SGLang + HiCache 端到端环境
- [ ] `/auto-review-loop` 优化完成后的质量审查
Loading
Loading