fix(maru_vllm): adapt LMCache kernel integration to relocated KV-type enums - #72
Open
seohui-XCENA wants to merge 2 commits into
Open
fix(maru_vllm): adapt LMCache kernel integration to relocated KV-type enums#72seohui-XCENA wants to merge 2 commits into
seohui-XCENA wants to merge 2 commits into
Conversation
seohui-XCENA
marked this pull request as ready for review
August 14, 2026 08:34
seohui-XCENA
force-pushed
the
fix/lmcache-cops-shim-guard
branch
from
August 19, 2026 06:04
35d095a to
fead569
Compare
1 task
2 tasks
kihwan-XCENA
approved these changes
Aug 26, 2026
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Symptom
With current upstream LMCache installed, the first inference request kills the vLLM EngineCore:
The exception escapes
save_kv_layerinside the model forward, so the whole engine dies and every request through the frontend returns 500.Background: why the direct connector touches LMCache at all
MaruKVConnectoris a direct vLLM↔maru integration — all cache decisions (chunk keys, placement, metadata, retrieval) are maru's, and no LMCache connector/engine/service ever runs. The only thing borrowed from thelmcachepackage is its compiled CUDA kernels (multi_layer_kv_transfer/single_layer_kv_transfer), used purely as a library to gather/scatter paged GPU KV blocks to/from contiguous CXL slabs in one kernel launch. This is optional by design: without the kernels the connector uses its per-layer fallback. (Unrelated tomaru_lmcache, which is the opposite integration — running the real LMCache connector with maru as its storage backend.)Root cause
The kernel resolution handled two cases: lmcache not installed (
ImportErrorguard → fallback) and installed-but-missing-a-format (getattr(enum, name, None)→ fallback). Upstream LMCache created a third: the KV-type enums (EngineKVFormat,TransferDirection) were relocated out ofc_opsinto thelmcache.lmcache_nativeextension (LMCache/LMCache#4453), and the backward-compat forward was removed in #4473 (2026-08-12).lmcache.c_opsnow resolves through a device-ops shim that carries the kernels but not the enums, so the outer attribute access raises before the guarded inner lookup runs.Fix
Two layers, one commit each:
_resolve_lmc_ops()helper bundles whichever combination is present — kernels fromlmcache.c_ops; enums from c_ops attributes (old builds, including the xcena fork) or fromlmcache.lmcache_native(new upstream) — into one namespace with the legacyops.<name>shape, so all call sites work unchanged against either LMCache generation and the fused path stays active on new upstream.New config:
maru_use_lmcache_kernelsAdded to
kv_connector_extra_config. Typebool, defaulttrue.true(default)falseSet
falseto benchmark the fallback paths or to isolate lmcache-related issues. Interaction: the experimentalmaru_enable_fused_load=truerequires the kernels, so with this flag off it is disabled with a warning.Validation
AttributeErrorpre-fix), resolver across LMCache generations, toggle behavior. Full connector suite passes (172).dynamo.vllmworkers, Qwen2.5-32B, CXL /dev/dax pool): previously crashed on the first request. With the fix, cross-instance KV reuse works and the fused kernels engage — the per-load fallback warning is absent, and against the guard-only fallback baseline the medians improved: cold (prefill+store) 1.374s → 1.062s, warm (CXL→GPU load) 0.135s → 0.124s. Fallback-path cross-instance speedup was 10.2× TTFT; the kernel path improves on it mainly on the store side at this KV size (1.1 GB/request).examples/vllm/p2p_sharing/p2p_example.shpasses on the kernel path (Cache Hit: Yes).