We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When top_p is 1.0, we expect top_p_renorm_prob to be an identity function. However, it will make small values zero.
The following example constructs some value small probability values (1e-9). After top_p_renorm_prob, all of them become zero.
top_p_renorm_prob
import torch import flashinfer pre_norm_prob = torch.tensor([[1 - 1e-9 * 20] + [1e-9] * 20]).to("cuda") probs = pre_norm_prob / pre_norm_prob.sum(dim=-1, keepdim=True) print(f"sum={probs.sum(dim=1)}") renormed_probs = flashinfer.sampling.top_p_renorm_prob(probs, 1.0) print(f"{probs=}") print(f"{renormed_probs=}") print(f"{probs.min()=}") print(f"{renormed_probs.min()=}") assert torch.all(probs == probs) assert torch.all(probs == renormed_probs)
Output
sum=tensor([1.], device='cuda:0') probs=tensor([[1.0000e+00, 1.0000e-09, 1.0000e-09, 1.0000e-09, 1.0000e-09, 1.0000e-09, 1.0000e-09, 1.0000e-09, 1.0000e-09, 1.0000e-09, 1.0000e-09, 1.0000e-09, 1.0000e-09, 1.0000e-09, 1.0000e-09, 1.0000e-09, 1.0000e-09, 1.0000e-09, 1.0000e-09, 1.0000e-09, 1.0000e-09]], device='cuda:0') renormed_probs=tensor([[1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]], device='cuda:0') probs.min()=tensor(1.0000e-09, device='cuda:0') renormed_probs.min()=tensor(0., device='cuda:0') Traceback (most recent call last): File "/root/test_top_p_renorm.py", line 16, in <module> assert torch.all(probs == renormed_probs) AssertionError
The text was updated successfully, but these errors were encountered:
yzh119
No branches or pull requests
When top_p is 1.0, we expect top_p_renorm_prob to be an identity function. However, it will make small values zero.
Reproduce
The following example constructs some value small probability values (1e-9). After
top_p_renorm_prob
, all of them become zero.Output
The text was updated successfully, but these errors were encountered: