-
Notifications
You must be signed in to change notification settings - Fork 20
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
Head-Specific KV Cache Compression Feature (Ada-SnapKV, AdaKV) #25
Conversation
add_AdaKV_initial_version AdaKV Signed-off-by: FFY0 <[email protected]>
Add ThinKPress (NVIDIA#20)
Signed-off-by: FFY0 <[email protected]>
I also have some confusion regarding batch support in the current repository. It seems that much of the code assumes a batch size of 1. This is because the compression logic doesn't appear to account for padding tokens caused by varying sequence lengths across different samples. Meanwhile, the current unit tests seem to use dummy inputs with a batch size greater than 1. To align with other methods, the current implementation of Ada-SnapKV is limited to scenarios where the batch size is 1. If necessary, I will explore support for multiple batch sizes in the future. |
Hi @SimJeg , I have added unit tests in It seems the current CI Action workflows require approval before they can run. I'm not very familiar with this process, so please let me know if there’s anything else I can contribute to. Additionally, the CI Action might fail due to the requirements of the new kernel build process. This issue may need further discussion on how to manage the kernel moving forward to identify a solution. |
Hi @FFY0, thanks for your hard work on this PR, the results you shared look really promising. One of the goal of the recent refacto was to welcome more complex presses such yours. We started to look at your PR and will come back with feedback. |
Hi @SimJeg, this interface looks great. Using a wrapper avoids many modifications in current architecture. I tried running the code, but I seem to have encountered a minor issue.
It seems that the condition in the function should be After changing it to I think one possible solution is to sequentially call the attention method for each query state within the wrapper func during decoding. This also allows for solving fake key states for each query state easily, for example:
|
@FFY0 there are still several issues to fix with this approach, I'm working on it ! Calling attention sequentially would work indeed but I'm confident I can fix search_hyperplane |
@FFY0 it should be fixed now, and early results with on 1% of RULER with AdaSnapKV and AdaExpectedAttention are promising ! I will benchmarks to see if I can reproduce the ones you shared at the beginning of the PR. |
@SimJeg This implementation is really impressive! I'm looking forward to the test results. |
Closing this PR as #38 has been merged |
Add Feature of Head-Specific KV Cache Compression at issue
I have got some results of Ada-SnapKV on the 4K Ruler benchmark. The results look promising. I have placed the corresponding results in a new notebook, which also includes a brief explanation of the flattened KV cache layout employed by head-specific KV cache compression during computation and a tutorial on how to customize new Head-Specific methods based on the latest
AdaBasePress
.Additionally, it seems that the Head-Specific KV Cache Compression feature may require custom unit test workflow, such as instantiating new attention classes before loading models. As a result, simply adding Ada-SnapKV into the current unit test may cause failures. I will attempt to resolve this issue in the future. Feel free to let me know if there's anything else you'd like me to refine or if you need additional details!