HIP: branch-free SWAR for __vsub4 / __vcmpne4 / __vcmpeq4 - #28616
Draft
SimonTeixidor wants to merge 1 commit into
Draft
SimonTeixidor wants to merge 1 commit into
SimonTeixidor wants to merge 1 commit into
Conversation
Replace the scalar loop emulation of these 3 intrinsics in ggml/src/ggml-cuda/vendors/hip.h with a branch-free SWAR.
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
ggml/src/ggml-cuda/vendors/hip.hemulates these 3 intrinsics with a loop, this PRreplaces those loops with a branch-free SWAR.
Additional information
__vsub4was previously forwarded to__vsubss4, which saturates, and is nowa wrapping subtract instead. That should be fine for two reasons. First it
matches CUDA's
__vsub4, and second it passestest-backend-ops -o MUL_MAT(1288/1288).
End-to-end benchmark (Strix Halo / gfx1151,
llama-batched-bench, S_TG)The percentage after each quant is its share of decode weight bytes in the affected types.
The five types that use these intrinsics are IQ2_XXS, IQ2_XS, IQ2_S, IQ3_XXS, IQ3_S.
Requirements