opencl: add Adreno xmem attention fast path#1461
Open
happyyzy wants to merge 1 commit into
Open
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
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.
Summary
GGML_OPENCL_ADRENO_XMEM_ATTNggml_flash_attn_extcases to this pathtest-opencl-adreno-attnas a focused correctness/perf reproducerScope
This PR is intentionally narrow. It only touches the
ggml-openclattention path:It does not change quantization, GEMM, CLML, or non-Adreno code paths.
Supported cases
q: f32,k/v: f16 or f32,out: f32Notes
The dedicated QK/PV split sources and their early compile order are intentional. On current Adreno drivers, compiling these xmem kernels later can produce a materially slower device binary even with identical source and build options.
Validation
Build validation on this branch:
cmake -S . -B build-adreno-xmem -DGGML_OPENCL=ON -DGGML_OPENCL_EMBED_KERNELS=ON -DCMAKE_BUILD_TYPE=Releasecmake --build build-adreno-xmem --target ggml-opencl test-opencl-adreno-attn -j./build-adreno-xmem/bin/test-opencl-adreno-attn --helpCorrectness examples on Adreno 830:
dq=128 dv=128 nq=256 nkv=512 n_head=8 n_head_kv=2->mae=6.7302e-05,max_abs=8.9369e-04,cos=0.999993535dq=128 dv=128 nq=256 nkv=256 n_head=8 n_head_kv=2->mae=7.8839e-05,max_abs=9.92954e-04,cos=0.999999313dq=128 dv=128 nq=1 nkv=512 n_head=8 n_head_kv=2->mae=7.4717e-05,max_abs=4.90941e-04,cos=0.999992445Adreno 830 performance examples:
H=30, L=4224, D=128, noncausal: xmem188.606 ms / 1.453 TOPS; FA killed by system; nofuse OOMH=30, L=2048, D=128, noncausal: xmem49.852 ms / 1.292 TOPS; FA2015.568 ms / 0.03196 TOPS; nofuse148.097 ms / 0.4350 TOPSH=30, L=2048, D=128, causal prefill: xmem46.069 ms / 1.398 TOPS; FA2150.036 ms / 0.02996 TOPS; nofuse2155.344 ms / 0.02989 TOPSH=1, L=16384, D=512, noncausal: xmem272.191 ms / 2.020 TOPS; nofuse1084.935 ms / 0.5067 TOPS; FA hitmap::atDecode is not the target of this path and remains slower than the existing routes on small
nq=1cases:nq=1 nkv=512 dq=dv=128 n_head=8 n_head_kv=2: xmem6.562 ms; FA0.491 ms; nofuse0.282 msnq=1 nkv=16384 dq=dv=128 n_head=8 n_head_kv=2: xmem12.350 ms; FA8.276 ms; nofuse3.535 ms