mirror of
https://github.com/huggingface/text-generation-inference.git
synced 2025-09-11 20:34:54 +00:00
fix: prefer inplace softmax to avoid copy
This commit is contained in:
parent
a6a0c97ed9
commit
8d7448de9f
@ -1922,8 +1922,9 @@ class FlashCausalLM(Model):
|
|||||||
batch.adapter_meta.adapter_indices = next_adapter_indices
|
batch.adapter_meta.adapter_indices = next_adapter_indices
|
||||||
|
|
||||||
if prefill and prefill_logprobs:
|
if prefill and prefill_logprobs:
|
||||||
# Get prefill logprobs
|
# Get prefill logprobs with inplace softmax (avoid copying the `out` tensor (max_batch_size * vocab_size))
|
||||||
prefill_logprobs_tensor = torch.log_softmax(out, -1)
|
torch.log_softmax(out, -1, out=out)
|
||||||
|
prefill_logprobs_tensor = out
|
||||||
prefill_logprobs = torch.gather(
|
prefill_logprobs = torch.gather(
|
||||||
prefill_logprobs_tensor, 1, prefill_tokens_indices.view(-1, 1)
|
prefill_logprobs_tensor, 1, prefill_tokens_indices.view(-1, 1)
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user