Skip to content
New issue

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

fix: prefer inplace softmax to avoid copy #2661

Merged
merged 2 commits into from
Oct 17, 2024

Conversation

drbh
Copy link
Collaborator

@drbh drbh commented Oct 17, 2024

This PR modifies log_softmax to operate in place, eliminating the need to copy large tensors. This optimization reduces memory consumption during warmup.

For instance, when using meta-llama/Meta-Llama-3.1-8B-Instruct on an L4, this change allows running the model with --max-batch-prefill-tokens increased from 7192 to 9874 without exceeding memory limits

@Narsil
Copy link
Collaborator

Narsil commented Oct 17, 2024

For instance, when using meta-llama/Meta-Llama-3.1-8B-Instruct on an L4, this change allows running the model with --max-batch-prefill-tokens increased from 7192 to 9874 without exceeding memory limits

With chunking in place, we don't want to increase max-batch-prefill-tokens anymore, but instead choose an optimal value :).

That being said, nice find, probably a lot of opportunities for such updates (let's focus on the large tensors though)

Narsil
Narsil previously approved these changes Oct 17, 2024
Co-authored-by: Nicolas Patry <patry.nicolas@protonmail.com>
@drbh drbh merged commit 5f32dea into main Oct 17, 2024
8 checks passed
@drbh drbh deleted the prefer-inplace-softmax-for-prefill-logprobs branch October 17, 2024 12:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants