Skip to content

Commit 9fa02ce

Browse files
hyukjleeclaude
andcommitted
[AMD][AgentX] Add Mooncake KV-offload backend to kimik2.7 agentic sweep
Add a third KV tier to the TP8 agentic comparison alongside none and LMCache: dram/Mooncake via the embedded MooncakeStoreConnector store (built from source for ROCm, tcp protocol), modeled on the MI355X DSv4 vLLM recipe. Wire it as an additive `mooncake)` case so the existing none/lmcache paths are unchanged. configs/amd-master.yaml now carries all three backends at conc [16,32,48]. configs/smoke-kimik2.7-mooncake.yaml is a temporary overlay to dispatch only the Mooncake cells, so the in-flight none/lmcache sweep is not rerun. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent e23ee3e commit 9fa02ce

3 files changed

Lines changed: 98 additions & 4 deletions

File tree

benchmarks/single_node/agentic/kimik2.7_fp4_mi355x.sh

Lines changed: 79 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ set -x
55
# Agentic trace replay benchmark for Kimi-K2.7 FP4 on MI355X using vLLM.
66
# KV_OFFLOADING=none -> GPU KV only
77
# KV_OFFLOADING=dram KV_OFFLOAD_BACKEND=lmcache -> LMCache MP server + connector
8+
# KV_OFFLOADING=dram KV_OFFLOAD_BACKEND=mooncake -> Mooncake embedded store + connector
89
#
910
# Required env vars:
1011
# MODEL, TP, CONC, KV_OFFLOADING, TOTAL_CPU_DRAM_GB, RESULT_DIR, DURATION, EP_SIZE
@@ -60,21 +61,27 @@ export VLLM_ALLREDUCE_USE_SYMM_MEM="${VLLM_ALLREDUCE_USE_SYMM_MEM:-0}"
6061
# ---- Server config ----------------------------------------------------------
6162
SERVER_LOG="$RESULT_DIR/server.log"
6263
LMCACHE_LOG="$RESULT_DIR/lmcache_server.log"
64+
MOONCAKE_MASTER_LOG="$RESULT_DIR/mooncake_master.log"
6365
mkdir -p "$RESULT_DIR"
6466

6567
OFFLOAD_ARGS=()
6668
PREFIX_CACHE_ARGS=()
6769

68-
# ---- LMCache config ---------------------------------------------------------
70+
# ---- Offload service cleanup ------------------------------------------------
6971
LMCACHE_PID=""
72+
MOONCAKE_MASTER_PID=""
7073

71-
cleanup_lmcache_server() {
74+
cleanup_offload_services() {
7275
if [[ -n "$LMCACHE_PID" ]] && kill -0 "$LMCACHE_PID" 2>/dev/null; then
7376
kill "$LMCACHE_PID" 2>/dev/null || true
7477
wait "$LMCACHE_PID" 2>/dev/null || true
7578
fi
79+
if [[ -n "$MOONCAKE_MASTER_PID" ]] && kill -0 "$MOONCAKE_MASTER_PID" 2>/dev/null; then
80+
kill "$MOONCAKE_MASTER_PID" 2>/dev/null || true
81+
wait "$MOONCAKE_MASTER_PID" 2>/dev/null || true
82+
fi
7683
}
77-
trap cleanup_lmcache_server EXIT
84+
trap cleanup_offload_services EXIT
7885

7986
wait_for_lmcache_ready() {
8087
{ set +x; } 2>/dev/null
@@ -192,8 +199,76 @@ case "$OFFLOAD_MODE" in
192199
"{\"kv_connector\":\"LMCacheMPConnector\",\"kv_connector_module_path\":\"lmcache.integration.vllm.lmcache_mp_connector\",\"kv_role\":\"kv_both\",\"kv_connector_extra_config\":{\"lmcache.mp.host\":\"$LMCACHE_CONNECT_HOST\",\"lmcache.mp.port\":$LMCACHE_PORT}}"
193200
)
194201
;;
202+
mooncake)
203+
unset VLLM_USE_SIMPLE_KV_OFFLOAD
204+
205+
# Mooncake embedded mode contributes one global segment per GPU rank to
206+
# a shared distributed store, so pre-divide the aggregate host-memory
207+
# budget across TP ranks. Mirrors the MI355X DSv4 vLLM recipe.
208+
MOONCAKE_PER_RANK_GB=$((TOTAL_CPU_DRAM_GB / TP))
209+
210+
# No prebuilt ROCm wheel: build the Mooncake transfer engine from source
211+
# if the store module isn't importable. Clone to a container-local dir
212+
# (NOT bind-mounted /workspace) so the next job's checkout `clean: true`
213+
# won't trip over root-owned build artifacts.
214+
if ! python3 -c "from mooncake.store import MooncakeDistributedStore" >/dev/null 2>&1; then
215+
MOONCAKE_SRC_DIR="${MOONCAKE_SRC_DIR:-/opt/mooncake-src}"
216+
MOONCAKE_GIT_REF="${MOONCAKE_GIT_REF:-main}"
217+
rm -rf "$MOONCAKE_SRC_DIR"
218+
git clone https://github.com/kvcache-ai/Mooncake.git "$MOONCAKE_SRC_DIR"
219+
( cd "$MOONCAKE_SRC_DIR"
220+
git checkout "$MOONCAKE_GIT_REF"
221+
bash dependencies.sh
222+
mkdir -p build && cd build
223+
cmake ..
224+
make -j
225+
make install )
226+
python3 -c "from mooncake.store import MooncakeDistributedStore" >/dev/null
227+
fi
228+
229+
MOONCAKE_MASTER_PORT=$((PORT + 12000))
230+
MOONCAKE_CONFIG_PATH="$RESULT_DIR/mooncake_config.json"
231+
cat > "$MOONCAKE_CONFIG_PATH" <<EOF
232+
{
233+
"mode": "embedded",
234+
"metadata_server": "P2PHANDSHAKE",
235+
"master_server_address": "127.0.0.1:$MOONCAKE_MASTER_PORT",
236+
"global_segment_size": "${MOONCAKE_PER_RANK_GB}GB",
237+
"local_buffer_size": "2GB",
238+
"protocol": "tcp",
239+
"device_name": "",
240+
"enable_offload": false
241+
}
242+
EOF
243+
export MOONCAKE_CONFIG_PATH
244+
export MC_ENABLE_DEST_DEVICE_AFFINITY=1
245+
export PYTHONHASHSEED="${PYTHONHASHSEED:-0}"
246+
export MC_SLICE_SIZE=1048576
247+
export MC_WORKERS_PER_CTX=8
248+
249+
echo "Starting Mooncake master on port $MOONCAKE_MASTER_PORT..."
250+
mooncake_master --port "$MOONCAKE_MASTER_PORT" \
251+
--eviction_high_watermark_ratio=0.80 \
252+
--eviction_ratio=0.10 \
253+
--default_kv_lease_ttl=60s \
254+
> "$MOONCAKE_MASTER_LOG" 2>&1 &
255+
MOONCAKE_MASTER_PID=$!
256+
echo "Mooncake master PID: $MOONCAKE_MASTER_PID"
257+
sleep 10
258+
if ! kill -0 "$MOONCAKE_MASTER_PID" 2>/dev/null; then
259+
echo "Mooncake master died during startup. Log follows:" >&2
260+
cat "$MOONCAKE_MASTER_LOG" >&2 || true
261+
exit 1
262+
fi
263+
264+
PREFIX_CACHE_ARGS=(--enable-prefix-caching)
265+
OFFLOAD_ARGS=(
266+
--kv-transfer-config
267+
'{"kv_connector":"MooncakeStoreConnector","kv_role":"kv_both","kv_connector_extra_config":{"load_async":true}}'
268+
)
269+
;;
195270
*)
196-
echo "Error: unsupported KV_OFFLOAD_BACKEND '$OFFLOAD_MODE' (expected: lmcache)" >&2
271+
echo "Error: unsupported KV_OFFLOAD_BACKEND '$OFFLOAD_MODE' (expected: lmcache, mooncake)" >&2
197272
exit 1
198273
;;
199274
esac

configs/amd-master.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,7 @@ kimik2.7-fp4-mi355x-vllm-agentic:
567567
search-space:
568568
- { tp: 8, kv-offloading: none, conc-list: [16, 32, 48] }
569569
- { tp: 8, kv-offloading: dram, kv-offload-backend: { name: lmcache, version: "aaf7c0d3" }, conc-list: [16, 32, 48] }
570+
- { tp: 8, kv-offloading: dram, kv-offload-backend: { name: mooncake, version: "source-main" }, conc-list: [16, 32, 48] }
570571

571572

572573
kimik2.5-fp4-mi355x-atom:
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Temporary overlay to dispatch ONLY the Mooncake KV-offload cells for the
2+
# kimik2.7 agentic TP8 smoke, so the in-flight none/lmcache sweep is not
3+
# rerun. Same config key + settings as configs/amd-master.yaml, mooncake only.
4+
# Remove once the 3-way none/lmcache/mooncake comparison is complete.
5+
kimik2.7-fp4-mi355x-vllm-agentic:
6+
image: vllm/vllm-openai-rocm:v0.24.0
7+
model: amd/Kimi-K2.7-Code-MXFP4
8+
model-prefix: kimik2.7
9+
runner: cluster:mi355x-amds
10+
precision: fp4
11+
framework: vllm
12+
multinode: false
13+
scenarios:
14+
agentic-coding:
15+
- dram-utilization: 0.80
16+
duration: 900
17+
search-space:
18+
- { tp: 8, kv-offloading: dram, kv-offload-backend: { name: mooncake, version: "source-main" }, conc-list: [16, 32, 48] }

0 commit comments

Comments
 (0)