Repository navigation
Optimize recsys-FlexKV - #418
Conversation
42c9818 to
9b151af
Compare
b2ae455 to
188fda3
Compare
188fda3 to
d38012d
Compare
|
/build |
|
❌ Pipeline #55646281 -- failed
Result: 12/17 jobs passed |
Greptile SummaryThis PR optimizes the FlexKV KV-cache manager through two main code changes and adds SSD backend support. The optimizations deliver substantial latency reductions (up to −54% on offload launch, −50% on onboard launch) at typical sequence lengths.
Confidence Score: 5/5The changes are well-scoped performance optimizations with no regressions observed in the benchmark data; the single stale comment in example.yml is cosmetic and does not affect runtime behavior. The The new batch offload path in Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[offload_kvcache_launch] --> B{as_batch AND\nnum_users > 1?}
B -- No --> C[put_async per user\ncollect task_ids]
B -- Yes --> D[put_match per user\ncompute return_mask]
D --> E{valid_len >= page_size\nAND launch_slot valid?}
E -- No --> F[cancel task_id\nskip user]
E -- Yes --> G[collect task_id\nbatch_slot_mappings]
G --> H{len task_ids > 1?}
H -- Yes --> I[launch as_batch=True]
H -- No --> J[launch as_batch=False]
C --> K[HostKVTaskHandle]
I --> K
J --> K
L[onboard_kvcache_launch] --> M[_build_slot_mappings\nbulk D2H kv_indices+kv_indptr]
M --> N[filter users needing onboard]
N --> O{as_batch AND\nnum_tasks > 1?}
O -- Yes --> P[launch as_batch=True]
O -- No --> Q[launch as_batch=False]
P --> R[HostKVTaskHandle]
Q --> R
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
A[offload_kvcache_launch] --> B{as_batch AND\nnum_users > 1?}
B -- No --> C[put_async per user\ncollect task_ids]
B -- Yes --> D[put_match per user\ncompute return_mask]
D --> E{valid_len >= page_size\nAND launch_slot valid?}
E -- No --> F[cancel task_id\nskip user]
E -- Yes --> G[collect task_id\nbatch_slot_mappings]
G --> H{len task_ids > 1?}
H -- Yes --> I[launch as_batch=True]
H -- No --> J[launch as_batch=False]
C --> K[HostKVTaskHandle]
I --> K
J --> K
L[onboard_kvcache_launch] --> M[_build_slot_mappings\nbulk D2H kv_indices+kv_indptr]
M --> N[filter users needing onboard]
N --> O{as_batch AND\nnum_tasks > 1?}
O -- Yes --> P[launch as_batch=True]
O -- No --> Q[launch as_batch=False]
P --> R[HostKVTaskHandle]
Q --> R
Reviews (9): Last reviewed commit: "Refine FLEXKV_CPU_BREAKDOWN doc" | Re-trigger Greptile |
|
/build |
|
❌ Pipeline #55763541 -- failed
Result: 13/17 jobs passed |
8eb2eaf to
4ea0899
Compare
|
Want your agent to iterate on Greptile's feedback? Try greploops. |
3826ad5 to
6bc5757
Compare
|
/build |
|
❌ Pipeline #57256931 -- failed
Result: 11/17 jobs passed |
|
/build |
|
❌ Pipeline #57502046 -- failed
Result: 12/17 jobs passed |
Replace per-seq page_ids D2H and numpy expand with one bulk kv_indices/kv_indptr copy and torch CPU broadcast; drop loop内全量 slot D2H. Add ex1 v2 profiling results (3-run mean) vs baseline and v1.
Remove text code-fence wrapper for the pipeline steps, drop the denominator note, and move the slot_mapping_optimization + as_batch perf summary out of the README (to be kept in the PR description).
3e216ac to
17b5a20
Compare
Description
_build_slot_mappingsby reducing D2H datasize.as_batchPerformance improvement summary
slot_mapping_optimizationBefore vs. after at
seq_len = 2048(L1, ms)offload_launchoffload_waitonboard_launchonboard_waitMain gains:
_build_slot_mappingsdrops from 3.30 ms → 0.43 ms (−87%).launchcuts onboard launch ~−50%.Launch + Wait Summary (
flexkv_as_batch=0vsflexkv_as_batch=1)as_batch=0(ms)as_batch=1(ms)Checklist