Skip to content
This repository was archived by the owner on Sep 10, 2025. It is now read-only.

Commit 11cea9b

Browse files
committed
Filter out infinitely small temperatures for float16 (#259)
$10^{-5}$ is too cold for fdtype, whose max is 65504.0 which is less than 100000 Fixes #250
1 parent 09593a2 commit 11cea9b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

generate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def multinomial_sample_one_no_sync(
9292

9393

9494
def logits_to_probs(logits, temperature: float = 1.0, top_k: Optional[int] = None):
95-
logits = logits / max(temperature, 1e-5)
95+
logits = logits / max(temperature, 1e-5 if logits.dtype != torch.float16 else 1e-3)
9696

9797
if top_k is not None:
9898
v, _ = torch.topk(logits, min(top_k, logits.size(-1)))

0 commit comments

Comments
 (0)