Support return_logprob for spec v2 (overlap safe) (#19801)
Co-authored-by: Ratish1 <ratish1501@gmail.com> Co-authored-by: Ratish1 <formula733@gmail.com> Co-authored-by: hnyls2002 <lsyincs@gmail.com>
This commit is contained in:
@@ -63,6 +63,21 @@ class GenerationBatchResult:
|
||||
self.logits_output.input_token_logprobs = (
|
||||
self.logits_output.input_token_logprobs.to("cpu", non_blocking=True)
|
||||
)
|
||||
if self.logits_output.next_token_top_logprobs_val is not None:
|
||||
self.logits_output.next_token_top_logprobs_val = [
|
||||
v.to("cpu", non_blocking=True) if torch.is_tensor(v) else v
|
||||
for v in self.logits_output.next_token_top_logprobs_val
|
||||
]
|
||||
if self.logits_output.next_token_top_logprobs_idx is not None:
|
||||
self.logits_output.next_token_top_logprobs_idx = [
|
||||
x.to("cpu", non_blocking=True) if torch.is_tensor(x) else x
|
||||
for x in self.logits_output.next_token_top_logprobs_idx
|
||||
]
|
||||
if self.logits_output.next_token_token_ids_logprobs_val is not None:
|
||||
self.logits_output.next_token_token_ids_logprobs_val = [
|
||||
v.to("cpu", non_blocking=True) if torch.is_tensor(v) else v
|
||||
for v in self.logits_output.next_token_token_ids_logprobs_val
|
||||
]
|
||||
if self.logits_output.hidden_states is not None:
|
||||
self.logits_output.hidden_states = self.logits_output.hidden_states.to(
|
||||
"cpu", non_blocking=True
|
||||
|
||||
Reference in New Issue
Block a user