-
Notifications
You must be signed in to change notification settings - Fork 126
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
Topk refactor #770
base: master
Are you sure you want to change the base?
Topk refactor #770
Conversation
…dding this when I modify the file
…contains infs for all elements in a row
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for doing this! I like this work very much.
My main general comment is that it would be very helpful to have more high-level comments, for all functions and data structures, as well as high-level blocks inside functions, to state what it does and what it is for.
I understand that some people do not like comments, as it makes the code look less clean. However, high-level comments like this are a service to the reader of the code, since reading a 1 or 2 line comment will be much faster than having to parse and understand the logic of the code itself. Consider that most of the time, readers of the code do not actually care or need to understand the detail implementation of everything. Often, readers need to quickly orient themselves to find the one place that they need to look at.
Thanks!
…e readable and updates struct function names
I think I have addressed all of your feedback @frankseide. I added detailed comments about the functions and made the stylistic changes you suggested. Let me if there's anything else that you think needs to be changed. |
Description
This PR rewrites the topk implementation. It is an optimization to benefit large batch and does not hinder small batch performance. This PR also changes the topk operator in topk.cu to use the new implementation.
There is a temporary template parameter in the topk launcher to enable/disable indexing relative to a given row. This can be removed if nth_element.cu is removed.
Performance improvements relative to PR #768
Times with 1 stream
Times with 2 streams
List of changes:
Added dependencies: cub
How to test
Run the unit tests. There are unit tests that cover the topk operator and they all still passed.
CMake command: cmake .. -DCOMPILE_CPU=on -DCOMPILE_CUDA=on -DUSE_SENTENCEPIECE=on -DUSE_STATIC_LIBS=off -DCOMPILE_SERVER=off -DUSE_FBGEMM=on -DCOMPILE_CUDA_SM35=off -DCOMPILE_CUDA_SM50=off -DCOMPILE_CUDA_SM60=off -DCOMPILE_CUDA_SM70=on -DCOMPILE_CUDA_SM75=off -DCOMPILE_TESTS=on
Ubuntu - 18.04.3 LTS
nvcc - 10.1.243
gcc - 7.5.0
Checklist