Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion cacheflow/models/sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@ def forward(
# Use in-place division to avoid creating a new tensor.
logits.div_(t.unsqueeze(dim=1))

# We use float32 for probabilities and log probabilities.
# Compute the probabilities.
probs = torch.softmax(logits, dim=-1, dtype=torch.float)
# Compute the log probabilities (before applying top-p).
logprobs = torch.log(probs, out=logits)
logprobs = torch.log(probs)

# Apply top-p truncation.
top_ps = _get_top_ps(input_metadata)
Expand Down