[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:
co-authored by
Hanming Lu
colinchan15
parent
8cf4d73c84
commit
e8fb52c526
@@ -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
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user