Skip to content

Commit

Permalink
[CORE] Improvement in ranks code (vllm-project#4718)
Browse files Browse the repository at this point in the history
  • Loading branch information
SwapnilDreams100 authored and tjohnson31415 committed May 16, 2024
1 parent 3942ef1 commit 6410635
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion vllm/model_executor/layers/sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,9 @@ def _get_ranks(x: torch.Tensor, indices: torch.Tensor) -> torch.Tensor:
"""
vals = x[torch.arange(0, len(x), device=x.device, dtype=indices.dtype),
indices]
return (x > vals[:, None]).long().sum(1).add_(1)
result = (x > vals[:, None])
del vals
return result.sum(1).add_(1)


def _get_logprobs(
Expand Down

0 comments on commit 6410635

Please sign in to comment.