Commit 3b26ce4
authored
[BugFix] Add patch for local_cache_hit calculation in vllm 0.18.0 met… (#941)
## Purpose
Fix negative `local_cache_hit` calculation that can crash Prometheus
counters.
Related vLLM issue: vllm-project/vllm#36755
When preemption occurs with async scheduling, there's a race condition
where:
- `schedule(N+1)` can preempt a request and reset its state
- `update_from_output(N)` reads the already-mutated request state
This can result in `num_external_computed_tokens` exceeding
`num_cached_tokens + recomputed`, causing `local_cache_hit` to become
negative. Prometheus counters then crash with:
ValueError: Counters can only be incremented by non-negative amounts.
## Modifications
- Patch `vllm.v1.metrics.stats.PromptTokenStats.update_from_output` to
wrap `local_cache_hit` calculation with `max(0, ...)`
- Add `v0180/vllm/pc/metrics/stats.py` with the patched method
- Add `v0180/vllm/pc_patch.py` to register the patch
- Update `apply_patch.py` to support vllm 0.18.0 version1 parent f0323d4 commit 3b26ce4
6 files changed
Lines changed: 37 additions & 0 deletions
File tree
- ucm/integration/vllm/patch
- v0180/vllm
- pc
- metrics
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
136 | 136 | | |
137 | 137 | | |
138 | 138 | | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
139 | 142 | | |
140 | 143 | | |
141 | 144 | | |
| |||
File renamed without changes.
Whitespace-only changes.
Whitespace-only changes.
Lines changed: 17 additions & 0 deletions
| 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 | + | |
| 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 | + | |
0 commit comments