[Performance Improvement] Update batched_count_greater_than to handle batch size 1 without recompile (#38933)
Signed-off-by: Lucas Kabela <lucaskabela@meta.com> Co-authored-by: Luka Govedič <ProExpertProg@users.noreply.github.com>
This commit is contained in:
co-authored by
Luka Govedič
parent
3b1d9c3156
commit
a8c6ee9b78
@@ -324,6 +324,12 @@ class Sampler(nn.Module):
|
||||
token_logprobs = logprobs.gather(-1, token_ids)
|
||||
|
||||
# Compute the ranks of the actual token.
|
||||
# Avoid 0/1 specialization recompile on the batch dimension
|
||||
# of the compiled batched_count_greater_than. mark_unbacked makes
|
||||
# the size fully symbolic so dynamo doesn't specialize when
|
||||
# batch_size transitions from 1 to >=2.
|
||||
torch._dynamo.decorators.mark_unbacked(logprobs, 0)
|
||||
torch._dynamo.decorators.mark_unbacked(token_logprobs, 0)
|
||||
token_ranks = batched_count_greater_than(logprobs, token_logprobs)
|
||||
|
||||
# Concatenate together with the topk.
|
||||
|
||||
Reference in New Issue
Block a user