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 by batching the D2H transfer in
Confidence Score: 5/5Safe to merge; all core logic changes are well-scoped and the existing put_async fallback is preserved. The optimizations to _build_slot_mappings and the new batch offload path are well-validated by benchmark data. The only finding is a stale env-var reference in a comment with no runtime impact. examples/hstu/inference/configs/example.yml — the header comment references an env var that is not wired up anywhere. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[offload_kvcache_launch] --> B{as_batch AND\nbatch_size > 1?}
B -- No --> C[put_async per user\ntask_ids collected]
B -- Yes --> D[put_match per user\nvalid_len >= page_size]
D --> E{num_unmatched > 0\nAND end > start?}
E -- No --> F[client.cancel task_id]
E -- Yes --> G[Collect task_id +\nsliced slot_mapping]
G --> H{task_ids non-empty?}
H -- No --> I[Return handle\nno launch call]
H -- Yes --> J{len task_ids > 1?}
J -- Yes --> K[client.launch\nas_batch=True]
J -- No --> L[client.launch\nas_batch=False]
C --> M[Return HostKVTaskHandle]
K --> M
L --> M
I --> M
%%{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\nbatch_size > 1?}
B -- No --> C[put_async per user\ntask_ids collected]
B -- Yes --> D[put_match per user\nvalid_len >= page_size]
D --> E{num_unmatched > 0\nAND end > start?}
E -- No --> F[client.cancel task_id]
E -- Yes --> G[Collect task_id +\nsliced slot_mapping]
G --> H{task_ids non-empty?}
H -- No --> I[Return handle\nno launch call]
H -- Yes --> J{len task_ids > 1?}
J -- Yes --> K[client.launch\nas_batch=True]
J -- No --> L[client.launch\nas_batch=False]
C --> M[Return HostKVTaskHandle]
K --> M
L --> M
I --> M
Reviews (7): Last reviewed commit: "Clean pr" | 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. |
07ac3cd to
28c2a1a
Compare
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.
28c2a1a to
3826ad5
Compare
3826ad5 to
6bc5757
Compare
|
/build |
|
❌ Pipeline #57256931 -- failed
Result: 11/17 jobs passed |
Description
_build_slot_mappingsby reducing D2H datasize.as_batchChecklist