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

Remove CPU sync before Sampler #414

Merged

Conversation

kdamaszk
Copy link

Currently before each Sampler call we have a CPU sync, which causes a host gap:
image

This PR is removing that sync, so the host gap is no longer visible:
image

NOTE: class ApplyToppTopkScalar still has some CPU syncs inside. It means that the biggest gain will be observed in the scenario without top_p or top_k parameters. I think it is worth to investigate if we can remove the syncs from this function too.

@kdamaszk kdamaszk added the habana Issues or PRs submitted by Habana Labs label Oct 22, 2024
@michalkuligowski michalkuligowski merged commit 0cf5261 into habana_main Oct 22, 2024
19 checks passed
@michalkuligowski michalkuligowski deleted the dev/kdamaszke/remove-cpu-sync-before-sampler branch October 22, 2024 08:43
xuechendi pushed a commit to xuechendi/vllm-fork that referenced this pull request Oct 23, 2024
Currently before each Sampler call we have a CPU sync, which causes a
host gap:
<img width="226" alt="image"
src="https://github.com/user-attachments/assets/4509e69b-0f16-4ac9-812e-a2a9bc43a6ad">

This PR is removing that sync, so the host gap is no longer visible:
<img width="133" alt="image"
src="https://github.com/user-attachments/assets/66c19e4b-d832-4955-848d-8ae4acd8d264">

NOTE: class `ApplyToppTopkScalar` still has some CPU syncs inside. It
means that the biggest gain will be observed in the scenario without
`top_p` or `top_k` parameters. I think it is worth to investigate if we
can remove the syncs from this function too.
tzielinski-habana pushed a commit that referenced this pull request Oct 24, 2024
Currently before each Sampler call we have a CPU sync, which causes a
host gap:
<img width="226" alt="image"
src="https://github.com/user-attachments/assets/4509e69b-0f16-4ac9-812e-a2a9bc43a6ad">

This PR is removing that sync, so the host gap is no longer visible:
<img width="133" alt="image"
src="https://github.com/user-attachments/assets/66c19e4b-d832-4955-848d-8ae4acd8d264">

NOTE: class `ApplyToppTopkScalar` still has some CPU syncs inside. It
means that the biggest gain will be observed in the scenario without
`top_p` or `top_k` parameters. I think it is worth to investigate if we
can remove the syncs from this function too.
michalkuligowski pushed a commit that referenced this pull request Oct 30, 2024
This change is fixing the performance issue I have introduced in the PR
#414 -- due to the usage of `torch.where` both functions have been
called. Now we will run only the selected one.
imangohari1 pushed a commit to imangohari1/vllm-fork that referenced this pull request Oct 31, 2024
This change is fixing the performance issue I have introduced in the PR
HabanaAI#414 -- due to the usage of `torch.where` both functions have been
called. Now we will run only the selected one.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
habana Issues or PRs submitted by Habana Labs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants