Commit 6cdc3d8
phaedonsun
feat(dist_reuse): KV cache sharing across TP/PP/CP + single-node radix match
Squashes 5 commits (20a65d5 + d97db4d + 72632ec + b9230c6 + 7cd04ad)
into a single landed feature. This is the full dist_reuse stack on
top of PR #165 (RankInfo refactor), validated end-to-end on a 2-machine
GPU setup (gpu-146.56.224.46 master / gpu-129.211.162.213 peer):
S1 (single-node TP=1) cached_ratio 99.65% PASS
S2 (single-node TP=2) cached_ratio 99.65% PASS
S3 (cross-node TP=1) master cold->warm 99.63%, peer
crosshit 99.63% storage=272 backend=
FlexKVConnector (PEERH2H @ 6.22 GB/s
via mooncake/RDMA) PASS x3
357/357 unit tests on both nodes PASS
== Original commits (in chronological order) ==
[20a65d5] feat(dist_reuse): KV cache sharing across TP/PP/CP + single-
node radix match
Initial dist_reuse stack: master coordinator, sharing-domain key,
aggregate radix, redis-meta namespace, multi-node policy, P2P
transfer types (PEERH2H/H2PEERH/PEERSSD2H/H2PEERSSD), failure
detector, four S{1..4} sglang+FlexKV e2e benchmark scripts.
[d97db4d] fix(dist_reuse): unblock cross-instance KV cache sharing on
s3_cross_node_tp1
Three runtime bugs blocked the s3 (master prime / peer crosshit) flow:
1) GPUCPUTransferWorker._transfer_impl had positional-arg drift
on the transfer_kv_blocks pybind: C++ added 'start_layer_id'
between 'chunk_size_in_bytes' and 'num_layers' (transfer.cu
2025-07-10), which silently mapped is_h2d=False onto
transfer_num_cta and launched D2H kernels with gridDim(0)
-> cudaErrorInvalidConfiguration on every D2H.
Fix: bind every value to the C++ pybind name with kwargs and
add 'start_layer_id=0' explicitly.
2) GlobalCacheEngine._maybe_attach_multi_sd_peerh2h_ops carried a
dead 'layer_num' parameter which the only caller in
_get_impl_local passed undefined -> NameError on first
cross-instance reuse hit. Fix: drop the dead parameter and 6
call sites in tests/test_d3_filter_and_get_clones.py.
3) merge_to_batch_graph raised NotImplementedError on PEERH2H /
H2PEERH / PEERSSD2H / H2PEERSSD as soon as a real cross-instance
hit produced a P2P op. Fix: whitelist the four types as P2P
passthrough (preserves per-block src_block_node_ids and
per-op target_node_ids from D-3 multi-SD broadcast clones),
wire dependencies on merged_h2d_op (GET) / merged_d2h_op (PUT).
[72632ec] fix(memory_handle): propagate _import_tensor_handle exceptions
Previously _import_tensor_handle logged the error and returned
torch.empty(0) on import failure, which silently dropped the wrapper
into a 0-element tensor and surfaced as an unrelated IndexError later
in worker.py::_get_layer_ptrs (layer_blocks[lay_id][0] out of range).
Now always re-raise, keeping the original traceback so cross-node
CUDA IPC handle device-id mismatches surface at their source.
Consistent with _import_cuda_ipc_handle which never swallowed.
[b9230c6] fix(config): move tp_node_idx from ModelConfig to RankInfo
PR #165 removed tp_rank from ModelConfig but
ModelConfig.tp_node_idx still referenced self.tp_rank, raising
AttributeError. Two pre-existing test_cache_config_batch_b.py
cases failed because of this.
Fix: remove ModelConfig.tp_node_idx (replaced with a migration
comment); add RankInfo.tp_node_idx (tp_rank // tp_size_per_node)
to complement RankInfo.tp_rank_per_node (tp_rank %
tp_size_per_node); update the two TP-node-count tests to
construct a RankInfo for tp_node_idx assertions.
[7cd04ad] docs(monitoring): document the new flexkv_py_dist_reuse_*
metrics
Added user-facing documentation for the 5 cross-instance reuse
metrics in docs/monitoring/README_{en,zh}.md (kept in sync):
* \xa72.3 'Cross-instance Reuse Metrics' table with type, labels,
severity and KNOWN_ISSUE-derived alert thresholds.
* 'Instrumentation status' subtable that flags the two metrics
(lease_meta_nullptr_total / about_to_evict_total) whose Python
collector hooks are ready but whose C++ master-side trigger
has not yet landed, with a callout that '0' on these two does
NOT mean 'system healthy'.
* \xa71.1 environment variable table now documents
PROMETHEUS_MULTIPROC_DIR (the sample dir used by
prometheus_client across sglang TP/PP workers, KVManager
subprocess and transfer workers).
* \xa73.5 'Multiprocess Scrape Notes' explaining the
MultiProcessCollector aggregation path and the recommended
/dev/shm/flexkv_prom tmpfs override.
* \xa73.6 'Recommended PromQL alerts' section with 4 ready-to-paste
Prometheus alert rules:
- FlexKVDistReuseLeaseMetaNullptr (critical, any positive)
- FlexKVDistReusePeerReadFailureRate (critical, > 0.1%)
- FlexKVDistReusePeerReadP99High (warning, > 500ms)
- FlexKVDistReuseEvictPressure (warning, ratio > 10)
* The /metrics curl verification snippet now also greps
flexkv_py_dist_reuse_.1 parent 00cc828 commit 6cdc3d8
67 files changed
Lines changed: 15364 additions & 473 deletions
File tree
- benchmarks/dist_benchmark
- csrc
- dist
- docs
- dist_reuse
- monitoring
- flexkv
- cache
- common
- dist_reuse
- integration
- metrics
- server
- transfer
- scripts/multi-nodes
- tests
- multinode
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
132 | 132 | | |
133 | 133 | | |
134 | 134 | | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
135 | 143 | | |
136 | 144 | | |
137 | 145 | | |
| |||
0 commit comments