fix mamba cache leak when adder fails to add a matched req. (#21404)

This commit is contained in:
strgrb
2026-03-30 16:45:49 +08:00
committed by GitHub
parent 62a63eeff7
commit b246269444
+7
View File
@@ -2416,6 +2416,13 @@ class Scheduler(
) > 0 or (not self.running_batch.is_empty())
else:
self.running_batch.batch_is_full = True
# revert matched mamba idx to avoid memory leak, if req is not added
added = len(adder.can_run_list) > 0 and req is adder.can_run_list[-1]
if not added and req.mamba_pool_idx is not None:
self.tree_cache.req_to_token_pool.mamba_pool.free(
req.mamba_pool_idx.unsqueeze(-1)
)
req.mamba_pool_idx = None
break
# Update waiting queue