[Perf] Make latest_output_ids H2D non-blocking in prepare_for_decode (#28491)

This commit is contained in:
Liangsheng Yin
2026-06-16 23:46:35 -07:00
committed by GitHub
parent 27291118b9
commit 3bc618485a
+7 -11
View File
@@ -2595,17 +2595,13 @@ class ScheduleBatch(ScheduleBatchDisaggregationDecodeMixin):
# real token is relayed via future_map and resolved at forward
# entry. So take the last output token from Req directly
# (origin_input_ids[-1] on the first decode, before any output).
latest_output_ids = torch.tensor(
[
(
req.output_ids[-1]
if len(req.output_ids)
else req.origin_input_ids[-1]
)
for req in self.reqs
],
dtype=torch.int64,
device=self.device,
last_tokens = [
req.output_ids[-1] if len(req.output_ids) else req.origin_input_ids[-1]
for req in self.reqs
]
# Non-blocking H2D so this per-step copy doesn't sync behind the forward.
latest_output_ids = torch.tensor(last_tokens, dtype=torch.int64).to(
self.device, non_blocking=True
)
self.sampling_info.penalizer_orchestrator.cumulate_output_tokens(
latest_output_ids