[Minor] Rename misleading chunked to reusing in ReqToTokenPool.alloc() (#19465)

This commit is contained in:
Liangsheng Yin
2026-02-26 16:24:03 -08:00
committed by GitHub
parent 8293a914a6
commit 1a32c0db4d
2 changed files with 14 additions and 10 deletions
+7 -5
View File
@@ -129,15 +129,17 @@ class DecodeReqToTokenPool:
return len(self.free_slots) return len(self.free_slots)
def alloc(self, reqs: List["Req"]) -> Optional[List[int]]: def alloc(self, reqs: List["Req"]) -> Optional[List[int]]:
chunked = [i for i, r in enumerate(reqs) if r.req_pool_idx is not None] # Indices of reqs that already have a req_pool_idx and will reuse
# their existing slot (e.g. chunked prefill continuing across chunks).
reusing = [i for i, r in enumerate(reqs) if r.req_pool_idx is not None]
assert ( assert (
len(chunked) <= 1 len(reusing) <= 1
), "only one chunked request may reuse req_pool_idx in a batch" ), "only one chunked request may reuse req_pool_idx in a batch"
assert all( assert all(
reqs[i].is_chunked > 0 or reqs[i].kv_committed_len > 0 for i in chunked reqs[i].is_chunked > 0 or reqs[i].kv_committed_len > 0 for i in reusing
), "request has req_pool_idx but is not chunked" ), "reusing request must be chunked or have committed KV"
need_size = len(reqs) - len(chunked) need_size = len(reqs) - len(reusing)
if need_size > len(self.free_slots): if need_size > len(self.free_slots):
return None return None
select_index = self.free_slots[:need_size] select_index = self.free_slots[:need_size]
+7 -5
View File
@@ -153,16 +153,18 @@ class ReqToTokenPool:
return len(self.free_slots) return len(self.free_slots)
def alloc(self, reqs: list[Req]) -> Optional[List[int]]: def alloc(self, reqs: list[Req]) -> Optional[List[int]]:
chunked = [i for i, r in enumerate(reqs) if r.req_pool_idx is not None] # Indices of reqs that already have a req_pool_idx and will reuse
# their existing slot (e.g. chunked prefill continuing across chunks).
reusing = [i for i, r in enumerate(reqs) if r.req_pool_idx is not None]
if not any(r.is_dllm() for r in reqs): if not any(r.is_dllm() for r in reqs):
assert ( assert (
len(chunked) <= 1 len(reusing) <= 1
), "only one chunked request may reuse req_pool_idx in a batch" ), "only one chunked request may reuse req_pool_idx in a batch"
assert all( assert all(
reqs[i].is_chunked > 0 or reqs[i].kv_committed_len > 0 for i in chunked reqs[i].is_chunked > 0 or reqs[i].kv_committed_len > 0 for i in reusing
), "request has req_pool_idx but is not chunked" ), "reusing request must be chunked or have committed KV"
need_size = len(reqs) - len(chunked) need_size = len(reqs) - len(reusing)
if need_size > len(self.free_slots): if need_size > len(self.free_slots):
return None return None
select_index = self.free_slots[:need_size] select_index = self.free_slots[:need_size]