-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Ryanunderhill/beamscorer gpu #16272
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
Merged
Merged
Ryanunderhill/beamscorer gpu #16272
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…ryanunderhill/beamscorer_gpu
…ryanunderhill/beamscorer_gpu
Added parallel batch processing
Remove now unnecessary cpu memory buffer to hold it
…inned CPU memory from the kernel.
tianleiwu
reviewed
Jun 14, 2023
tianleiwu
reviewed
Jun 20, 2023
tianleiwu
reviewed
Jun 20, 2023
tianleiwu
reviewed
Jun 20, 2023
tianleiwu
reviewed
Jun 20, 2023
onnxruntime/contrib_ops/cpu/transformers/beam_search_impl_base.h
Outdated
Show resolved
Hide resolved
tianleiwu
reviewed
Jun 20, 2023
onnxruntime/contrib_ops/cpu/transformers/beam_search_impl_base.h
Outdated
Show resolved
Hide resolved
tianleiwu
reviewed
Jun 20, 2023
tianleiwu
reviewed
Jun 20, 2023
onnxruntime/contrib_ops/cpu/transformers/beam_search_impl_whisper.h
Outdated
Show resolved
Hide resolved
tianleiwu
reviewed
Jun 20, 2023
onnxruntime/contrib_ops/cuda/transformers/generation_cuda_impl.cu
Outdated
Show resolved
Hide resolved
tianleiwu
reviewed
Jun 21, 2023
tianleiwu
reviewed
Jun 21, 2023
tianleiwu
previously approved these changes
Jun 23, 2023
…ryanunderhill/beamscorer_gpu
tianleiwu
previously approved these changes
Jun 26, 2023
…ryanunderhill/beamscorer_gpu
tianleiwu
approved these changes
Jun 27, 2023
tianleiwu
added a commit
that referenced
this pull request
Feb 7, 2025
### Description * Pass topk_scores to beam scorer in slow topk path. * Add an env variable `ORT_BEAM_SEARCH_USE_FAST_TOPK` to enable/disable fast topk. * Add a test case for slow topk path. ### Motivation and Context This bug was introduced in #16272 Beam search uses fast cuda kernel when number of beams <= 32. When beam size is larger than that threshold, we use another code path (slower cuda kernel) to get topk. In such `slow topk path`, topk_scores shall be passed to beam scorer but it is not. This bug will cause incorrect result when num_beams > 32. It was not found previously since such large beam size is rarely used.
ashrit-ms
pushed a commit
that referenced
this pull request
Feb 11, 2025
### Description * Pass topk_scores to beam scorer in slow topk path. * Add an env variable `ORT_BEAM_SEARCH_USE_FAST_TOPK` to enable/disable fast topk. * Add a test case for slow topk path. ### Motivation and Context This bug was introduced in #16272 Beam search uses fast cuda kernel when number of beams <= 32. When beam size is larger than that threshold, we use another code path (slower cuda kernel) to get topk. In such `slow topk path`, topk_scores shall be passed to beam scorer but it is not. This bug will cause incorrect result when num_beams > 32. It was not found previously since such large beam size is rarely used.
guschmue
pushed a commit
that referenced
this pull request
Mar 6, 2025
### Description * Pass topk_scores to beam scorer in slow topk path. * Add an env variable `ORT_BEAM_SEARCH_USE_FAST_TOPK` to enable/disable fast topk. * Add a test case for slow topk path. ### Motivation and Context This bug was introduced in #16272 Beam search uses fast cuda kernel when number of beams <= 32. When beam size is larger than that threshold, we use another code path (slower cuda kernel) to get topk. In such `slow topk path`, topk_scores shall be passed to beam scorer but it is not. This bug will cause incorrect result when num_beams > 32. It was not found previously since such large beam size is rarely used.
ashrit-ms
pushed a commit
that referenced
this pull request
Mar 17, 2025
### Description * Pass topk_scores to beam scorer in slow topk path. * Add an env variable `ORT_BEAM_SEARCH_USE_FAST_TOPK` to enable/disable fast topk. * Add a test case for slow topk path. ### Motivation and Context This bug was introduced in #16272 Beam search uses fast cuda kernel when number of beams <= 32. When beam size is larger than that threshold, we use another code path (slower cuda kernel) to get topk. In such `slow topk path`, topk_scores shall be passed to beam scorer but it is not. This bug will cause incorrect result when num_beams > 32. It was not found previously since such large beam size is rarely used.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Make BeamScorer run on the GPU vs the CPU.
Brief overview:
Adds a CUDA 'CudaBeamSearchScorer' implementation of IBeamScorer
Instead of a 'done' flag per beam, there is one single 'not done' variable that is copied to the CPU every iteration
Removes some of the extra CPU side buffers and parameters that are no longer needed
Remaining future optimizations:
CPU copied beam indices is still used in the non DecoderMaskedSelfAttention case. An extra kernel can be written to avoid PickGptPasteState needing CPU copied beam indices (called from UpdateGptFeeds).
Motivation and Context
It's faster to keep the work on the GPU to avoid GPU->CPU->GPU copies of data.