[sgl] view could hold the memory too long and introduced large memory (#19109)

This commit is contained in:
Bi Xue
2026-02-21 07:40:56 -08:00
committed by GitHub
parent 677b66af80
commit bf36aa4c31

View File

@@ -119,7 +119,14 @@ class SchedulerOutputProcessorMixin:
for k, v in logits_output.customized_info.items():
if k not in req.customized_info:
req.customized_info[k] = []
req.customized_info[k].append(v[i])
# Copy the element so it doesn't retain the entire batch
# tensor/array via a view reference.
elem = v[i]
if isinstance(elem, torch.Tensor):
elem = elem.clone()
elif hasattr(elem, "copy") and callable(elem.copy):
elem = elem.copy()
req.customized_info[k].append(elem)
def process_batch_result_prefill(
self: Scheduler,