KVCache simulator for LLM serving cluster routing research

Discrete-event simulator for evaluating KV cache-aware routing policies
in prefill-disaggregated LLM serving clusters. Models a two-tier KV cache
hierarchy (L0 GPU HBM + L1 CPU DRAM) with RDMA/PCIe link contention,
architecture-derived roofline compute (MoE, MLA, DSA), and a cluster-wide
meta-store for prefix-aware routing decisions.

Includes 11 routing policies (random, round_robin, least_loaded,
least_tokens, ttl_aware, precise, min_pd, cache_load, cache_score,
estimated_ttft, prefix_affinity), HuggingFace config.json auto-parsing,
built-in GPU hardware presets (H100/H800/H20/A100/B200), and ablation
tooling for systematic policy comparison across real Alibaba serving traces.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-14 01:16:02 +08:00
commit ec73a95e05
52 changed files with 6005 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
use anyhow::Result;
use serde::Serialize;
use std::path::Path;
#[derive(Debug, Clone, Serialize)]
pub struct PerRequestRow {
pub req_id: u64,
pub arrival: f64,
pub ttft: f64,
pub e2e: f64,
pub instance: u32,
pub total_blocks: u32,
pub l0_hit_blocks: u32,
pub l1_hit_blocks: u32,
pub remote_hit_blocks: u32,
pub miss_blocks: u32,
pub rdma_bytes: u64,
pub pcie_bytes: u64,
pub probe_overhead_s: f64,
}
pub struct PerRequestWriter {
inner: csv::Writer<std::fs::File>,
}
impl PerRequestWriter {
pub fn create<P: AsRef<Path>>(path: P) -> Result<Self> {
let f = std::fs::File::create(path)?;
let inner = csv::Writer::from_writer(f);
Ok(Self { inner })
}
pub fn write(&mut self, row: &PerRequestRow) -> Result<()> {
self.inner.serialize(row)?;
Ok(())
}
pub fn finish(mut self) -> Result<()> {
self.inner.flush()?;
Ok(())
}
}