[Perf] Make latest_output_ids H2D non-blocking in prepare_for_decode (#28491)
This commit is contained in:
@@ -2595,17 +2595,13 @@ class ScheduleBatch(ScheduleBatchDisaggregationDecodeMixin):
|
|||||||
# real token is relayed via future_map and resolved at forward
|
# real token is relayed via future_map and resolved at forward
|
||||||
# entry. So take the last output token from Req directly
|
# entry. So take the last output token from Req directly
|
||||||
# (origin_input_ids[-1] on the first decode, before any output).
|
# (origin_input_ids[-1] on the first decode, before any output).
|
||||||
latest_output_ids = torch.tensor(
|
last_tokens = [
|
||||||
[
|
req.output_ids[-1] if len(req.output_ids) else req.origin_input_ids[-1]
|
||||||
(
|
for req in self.reqs
|
||||||
req.output_ids[-1]
|
]
|
||||||
if len(req.output_ids)
|
# Non-blocking H2D so this per-step copy doesn't sync behind the forward.
|
||||||
else req.origin_input_ids[-1]
|
latest_output_ids = torch.tensor(last_tokens, dtype=torch.int64).to(
|
||||||
)
|
self.device, non_blocking=True
|
||||||
for req in self.reqs
|
|
||||||
],
|
|
||||||
dtype=torch.int64,
|
|
||||||
device=self.device,
|
|
||||||
)
|
)
|
||||||
self.sampling_info.penalizer_orchestrator.cumulate_output_tokens(
|
self.sampling_info.penalizer_orchestrator.cumulate_output_tokens(
|
||||||
latest_output_ids
|
latest_output_ids
|
||||||
|
|||||||
Reference in New Issue
Block a user