-
Notifications
You must be signed in to change notification settings - Fork 257
kimik3-fp4-mi355x-vllm-agentic-mtp: add LMCache DRAM KV-offload arm #2598
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
055dfc2
328836b
4584d37
aba14d1
6b95b7b
a8cda1a
afee680
20b4fda
3c1908b
d671e53
0811fb0
ac6ad7d
e890a2b
9678373
834e42c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -109,12 +109,14 @@ SERVER_LOG="$RESULT_DIR/server.log" | |
| mkdir -p "$RESULT_DIR" | ||
|
|
||
| SERVER_PID="" | ||
| LMCACHE_PID="" | ||
|
|
||
| cleanup_agentic_services() { | ||
| local exit_code=$? | ||
| trap - EXIT INT TERM | ||
| set +e | ||
| stop_background_process_tree "$SERVER_PID" "vLLM server" 60 | ||
| stop_background_process_tree "$LMCACHE_PID" "LMCache server" | ||
| exit "$exit_code" | ||
| } | ||
| trap cleanup_agentic_services EXIT | ||
|
|
@@ -143,6 +145,77 @@ case "${KV_OFFLOAD_BACKEND:-}" in | |
| ) | ||
| echo "SimpleCPUOffloadConnector: ${CPU_BYTES_PER_RANK} B/rank x ${TP} ranks, lazy_offload=$SIMPLE_LAZY_OFFLOAD" | ||
| ;; | ||
| lmcache) | ||
| require_agentic_kv_offload_backend "$KV_OFFLOAD_BACKEND" | ||
|
|
||
| # Keep the image's tested torch/ROCm stack and install only LMCache's | ||
| # missing runtime dependencies, same as the MiniMax-M3 lmcache arm. | ||
| LMCACHE_VERSION="0.5.4rc2" | ||
| LMCACHE_ROCM_INDEX="https://github.com/LMCache/LMCache/releases/expanded_assets/v${LMCACHE_VERSION}-rocm" | ||
| agentic_pip_install --quiet --no-cache-dir --no-deps \ | ||
| "sortedcontainers==2.4.0" \ | ||
| "opentelemetry-exporter-prometheus==0.61b0" \ | ||
| "cupy-rocm-7-0==14.1.1" \ | ||
| "lmcache==${LMCACHE_VERSION}" --find-links "$LMCACHE_ROCM_INDEX" | ||
| python3 -c \ | ||
| "import cupy; import lmcache.integration.vllm.lmcache_mp_connector; import opentelemetry.exporter.prometheus" \ | ||
| >/dev/null | ||
|
|
||
| # One MP server for the node, per the Kimi-K3 recipe | ||
| # (docs.lmcache.ai/recipes/kimi_k3.html), with --chunk-size sized for | ||
| # THIS stack rather than the recipe's CUDA-path 768: the connector | ||
| # requires the chunk to be a multiple of every engine KV group's | ||
| # tokens_per_block, and the hybrid KDA/MLA layout here registers | ||
| # attention groups at 1536 ("Setting attention block size to 1536", | ||
| # run 31644990546) plus a KDA state group at 3072 (run 31645828378), | ||
| # so 3072 is the minimum valid chunk. The multi-group layout also | ||
| # requires one object group per sliding-window size: | ||
| # --separate-object-groups. | ||
| LMCACHE_PORT=6555 | ||
| LMCACHE_HTTP_PORT=8090 | ||
| LMCACHE_LOG="$RESULT_DIR/lmcache_server.log" | ||
|
|
||
| LMCACHE_L1_SIZE_GB="$TOTAL_CPU_DRAM_GB" | ||
|
|
||
| LMCACHE_CMD=( | ||
| lmcache server | ||
| --host 127.0.0.1 | ||
| --port "$LMCACHE_PORT" | ||
| --http-host 127.0.0.1 | ||
| --http-port "$LMCACHE_HTTP_PORT" | ||
| --l1-size-gb "$LMCACHE_L1_SIZE_GB" | ||
| --l1-init-size-gb 10 | ||
| --chunk-size 3072 | ||
| --separate-object-groups | ||
| --enable-extra-logging | ||
| --extra-logging-interval 30 | ||
| --max-cpu-workers 8 | ||
| --max-gpu-workers 1 | ||
| --eviction-policy LRU | ||
| --supported-transfer-mode lmcache_driven | ||
| --shm-name "" | ||
| ) | ||
|
Comment on lines
+180
to
+197
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔴 The new lmcache MP server command omits Extended reasoning...The bug: Why this matters here specifically: an LMCache read lock is a lease on a chunk that Why the new arm is at least as exposed, not less: the kimik3 arm's own comment (line 208) notes '100k-330k-token agentic prefixes make single retrieves large,' and the author raised Why nothing else in the diff prevents this: the new arm installs LMCache fresh via pip and constructs Concrete walkthrough: (1) a request with a 250k-token prefix arrives under conc=12; (2) vLLM's LMCacheMPConnector calls Fix: add |
||
| append_command "$RESULT_DIR/lmcache_command.txt" "${LMCACHE_CMD[@]}" | ||
| "${LMCACHE_CMD[@]}" > "$LMCACHE_LOG" 2>&1 & | ||
| LMCACHE_PID=$! | ||
| wait_for_ready \ | ||
| --endpoint "http://127.0.0.1:${LMCACHE_HTTP_PORT}/healthcheck" \ | ||
| --log "$LMCACHE_LOG" \ | ||
| --pid "$LMCACHE_PID" \ | ||
| --sleep-interval 1 \ | ||
| --timeout 600 | ||
|
|
||
| # 100k-330k-token agentic prefixes make single retrieves large; use the | ||
| # same MQ timeout headroom as the MiniMax-M3 arm. | ||
| OFFLOAD_ARGS=( | ||
| --kv-transfer-config | ||
| "{\"kv_connector\":\"LMCacheMPConnector\",\"kv_connector_module_path\":\"lmcache.integration.vllm.lmcache_mp_connector\",\"kv_role\":\"kv_both\",\"kv_connector_extra_config\":{\"lmcache.mp.port\":$LMCACHE_PORT,\"lmcache.mp.mq_timeout\":6000.0}}" | ||
| ) | ||
| ;; | ||
| *) | ||
| echo "Error: unsupported KV_OFFLOAD_BACKEND='$KV_OFFLOAD_BACKEND' (expected vllm-simple or lmcache)" >&2 | ||
| exit 1 | ||
| ;; | ||
| esac | ||
| fi | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 The LMCache MP-server bootstrap in this new arm (pip install of the 4 pinned wheels, the python3 import smoke-test, server argv assembly, and append_command + background-launch + wait_for_ready polling at lines 154-213) is copy-pasted almost verbatim from the existing minimaxm3_fp4_mi355x_mtp.sh:85-159 lmcache arm, differing only in shard count, chunk-size/eviction knobs, and the mp.port vs mp.server_urls connector key. This is a pre-existing pattern (this is now the second copy) that a shared benchmark_lib.sh helper (e.g. start_lmcache_mp_servers) could remove; not blocking.
Extended reasoning...
Comparing
kimik3_fp4_mi355x_mtp.sh:148-213against the existingminimaxm3_fp4_mi355x_mtp.sh:85-159, the newlmcache)case arm is a near-verbatim copy of the one already in the MiniMax-M3 script:agentic_pip_install --no-depsblock installs the exact same 4 pinned wheels (sortedcontainers==2.4.0,opentelemetry-exporter-prometheus==0.61b0,cupy-rocm-7-0==14.1.1,lmcache==<version>) from the same ROCmexpanded_assetsindex, differing only in theLMCACHE_VERSIONstring (0.5.4rc2vs0.5.3).python3 -c "import cupy; import lmcache.integration.vllm.lmcache_mp_connector; import opentelemetry.exporter.prometheus"smoke test is byte-for-byte identical.lmcache serverargv assembly (--host/--port/--http-host/--http-port/--l1-size-gb/--l1-init-size-gb/--chunk-size/--eviction-policy LRU/--supported-transfer-mode lmcache_driven), theappend_command+ background-launch +wait_for_ready --endpoint .../healthcheckpolling shape, and theLMCacheMPConnectorkv-transfer-configJSON all follow the same structure.The real, intentional differences are exactly the ones called out in the PR description: this arm runs a single MP server for the whole node instead of one per TP rank, uses different chunk-size/eviction/logging knobs tuned for the hybrid KDA/MLA layout, and connects via
lmcache.mp.portinstead oflmcache.mp.server_urls.This isn't a functional bug — the script works correctly as written,
bash -npasses, and the duplication doesn't cause incorrect behavior. It's a maintainability nit: this pattern now exists in two single-node agentic scripts, and the next lmcache arm (there's already a comment in the diff about a third planned once the upstream hybrid KV recovery fix lands) will very likely copy it a third time.benchmark_lib.shalready hosts exactly this class of shared helper (agentic_pip_install,wait_for_ready,append_command,require_agentic_kv_offload_backend), so extracting at minimum the pip-install + smoke-test block, and plausibly a parameterizedstart_lmcache_mp_servershelper (taking shard count, chunk-size, and extra flags) intobenchmark_lib.sh, would fit the established pattern and remove the duplicate.Step-by-step: (1) open
minimaxm3_fp4_mi355x_mtp.sh:85-100— the pip-install block matcheskimik3_fp4_mi355x_mtp.sh:154-162line for line except the version string; (2) both scripts' next line is the identical three-importpython3 -csmoke test; (3) both then build anlmcache serverargv array with the same flag set and launch it the same way withappend_command, background&, andwait_for_ready --endpoint http://.../healthcheck; (4) both close with akv-transfer-configJSON forLMCacheMPConnectordiffering only in the connector-key field. No behavior differs from consolidating these into a shared helper, so this is a safe, non-blocking cleanup for a future PR.