A high-throughput and memory-efficient inference and serving engine for LLMs
Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git
Synced Nov 14, 05:30 UTC
[BugFix] Fix `MinPLogitsProcessor.update_states()` (#23401)
Signed-off-by: Nick Hill <nhill@redhat.com>
Nick Hill committed
Aug 22, 2025 at 17:22 UTC
add1adfec742dfb13e614dab3372b5aafd1ff046
1 file changed
+21
-13
vllm/v1/sample/logits_processor/builtin.py
+21
-13
@@ -53,29 +53,37 @@ class MinPLogitsProcessor(LogitsProcessor):
53
# Process added requests.
54
for index, params, _, _ in batch_update.added:
55
min_p = params.min_p
56
- if self.min_p_cpu[index] != min_p:
56
+ min_p_before = self.min_p_cpu[index]
57
+ if min_p_before != min_p:
58
needs_update = True
59
self.min_p_cpu[index] = min_p
59
- if min_p:
60
- self.min_p_count += 1
60
+ if min_p and not min_p_before:
61
+ self.min_p_count += 1
62
+ elif not min_p and min_p_before:
63
+ self.min_p_count -= 1
64
65
if self.min_p_count:
66
# Process removed requests.
64
- needs_update |= bool(batch_update.removed)
65
- for index in batch_update.removed:
66
- if self.min_p_cpu[index]:
67
- self.min_p_count -= 1
67
+ if batch_update.removed:
68
+ needs_update = True
69
+ for index in batch_update.removed:
70
+ if self.min_p_cpu[index]:
71
+ self.min_p_cpu[index] = 0
72
+ self.min_p_count -= 1
73
69
- # Process moved requests, unidirectional (a->b) and swap (a<->b)
74
+ # Process moved requests, unidirectional (a->b) and swap (a<->b).
75
for adx, bdx, direct in batch_update.moved:
71
- change = (min_p_a :=
72
- self.min_p_cpu[adx]) != (min_p_b :=
73
- self.min_p_cpu[bdx])
74
- needs_update |= change
75
- if change:
76
+ min_p_a, min_p_b = self.min_p_cpu[adx], self.min_p_cpu[bdx]
77
+ if min_p_a != min_p_b:
78
+ needs_update = True
79
self.min_p_cpu[bdx] = min_p_a
80
if direct == MoveDirectionality.SWAP:
81
self.min_p_cpu[adx] = min_p_b
82
+ if direct == MoveDirectionality.UNIDIRECTIONAL:
83
+ if min_p_a:
84
+ self.min_p_cpu[adx] = 0
85
+ if min_p_b:
86
+ self.min_p_count -= 1
87
88
# Update tensors if needed.
89
size = batch_update.batch_size