[Fix] Keep request-pool row generations monotonic across clear() (#43439)

Co-authored-by: Hanming Lu <69857889+hanming-lu@users.noreply.github.com>
Co-authored-by: colinchan15 <colinchan15@users.noreply.github.com>
This commit is contained in:
metamergebot
2026-10-09 18:08:54 -07:00
committed by GitHub
co-authored by Hanming Lu colinchan15
parent 8cf4d73c84
commit e8fb52c526
3 changed files with 37 additions and 2 deletions
+1 -1
View File
@@ -253,7 +253,7 @@ class DecodeReqToTokenPool:
def clear(self):
self.free_slots = list(range(1, self._alloc_size))
self.req_generation.zero_()
# req_generation must stay monotonic; see ReqToTokenPool.clear().
def register_on_alloc_rows(self, hook: Callable[[List[int]], None]) -> None:
assert self._on_alloc_rows is None
+3 -1
View File
@@ -457,7 +457,9 @@ class ReqToTokenPool:
def clear(self):
self.free_slots = list(range(1, self._alloc_size))
self.req_generation.zero_()
# req_generation must stay monotonic: readers detect row reuse by
# equality with a generation they stored, so zeroing it here can give a
# row's next request the same generation as its previous one.
if self._aux_cache is not None:
self._aux_cache.clear()