Refactor logprob computation to return the real logprob used in sampling (#2664)
This commit is contained in:
@@ -392,34 +392,7 @@ class CudaGraphRunner:
|
||||
self.graphs[bs].replay()
|
||||
next_token_logits = self.output_buffers[bs][:raw_bs]
|
||||
|
||||
# Extract logprobs
|
||||
if forward_batch.return_logprob:
|
||||
logits_metadata = LogitsMetadata(
|
||||
forward_mode=ForwardMode.DECODE,
|
||||
top_logprobs_nums=forward_batch.top_logprobs_nums,
|
||||
)
|
||||
next_token_logprobs = (
|
||||
LogitsProcessor.compute_temp_top_p_normalized_logprobs(
|
||||
next_token_logits, logits_metadata
|
||||
)
|
||||
)
|
||||
logits_output = LogitsProcessorOutput(
|
||||
next_token_logits=next_token_logits,
|
||||
next_token_logprobs=next_token_logprobs,
|
||||
)
|
||||
return_top_logprob = any(x > 0 for x in forward_batch.top_logprobs_nums)
|
||||
if return_top_logprob:
|
||||
(
|
||||
logits_output.output_top_logprobs_val,
|
||||
logits_output.output_top_logprobs_idx,
|
||||
) = LogitsProcessor.get_top_logprobs(
|
||||
next_token_logprobs, logits_metadata
|
||||
)[
|
||||
2:4
|
||||
]
|
||||
else:
|
||||
logits_output = LogitsProcessorOutput(
|
||||
next_token_logits=next_token_logits,
|
||||
)
|
||||
|
||||
logits_output = LogitsProcessorOutput(
|
||||
next_token_logits=next_token_logits,
|
||||
)
|
||||
return logits_output
|
||||
|
||||
Reference in New Issue
Block a user