HIP : optimize IQ2/IQ3 (__vsub4 __vcmpne4) using SWAR - #27962
Open
yanjs wants to merge 2 commits into
Open
Conversation
Author
|
(up: master, down: this pr) |
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
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.
Overview
__vsub4and__vcmpne4are CUDA intrinsic fallback implementations in HIP backends. This optimization improves the efficiency of these implementations using SWAR. The wrong implementation of__vsub4is fixed.These functions are used by IQ2/IQ3 paths only on HIP backends. These paths gain decent improvements (Qwen 3.8 27B IQ3_S tg128 +~20% on my device).
__vsub4: ~10% speed up. Fix the wrong implementation.__vcmpne4: ~10% speed up. Less instructions. No dependency on VCC. See https://godbolt.org/z/Mf8Yv73Y1 for details.test-backend-ops testpassed.Additional information
Tested on Arch Linux, RX 9070, gfx1201, ROCm 7.14, compared to base 77f132c . (up: master, mid: with only
__vcmpne4optimization, down: with 2 commits from this pr)__vcmpeq4is dead code. I did not change it as it is not benched. It can be removed or implemented using bitwise not of__vcmpne4if required.Requirements