Add support for custom position ids and attention bias to GQA CPU operator - #23944
Conversation
@microsoft-github-policy-service agree company="Microsoft" |
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1. Rename attention_mask -> attention_bias 2. Make last dim of attention_bias to be total_sequence_length 3. Rename pos_ids -> position_ids 4. Disallow custom position_ids when processing the first prompt 5. Add static assert for fp32 bias upscale
Updated PR description with the benchmark results |
|
LGTM |
|
Is there plan to implement for other EP (like CUDA/WebGPU etc)? If not, suggest to add some checks of these new inputs and throw not-implemented exception. This can be done in another PR. |
There isn't a plan to support it yet since we only use the CPU implementation of the operator. I opened issue #24043 so we can introduce checks for these inputs in implementations for other EPs as a follow-up PR. |
attention_bias in GroupQueryAttention (last EP missing it)
#29506
Description
Motivation and Context
Custom position ids and attention mask are required in order to implement speculative decoding in PhiSilica
Benchmarks
All the benchmarks are executed on the GQA op configuration which will be used in the PhiSilica speculative decoding secnario, and the configuration is as follows:
Benchmarks were executed on Cadmus with Snapdragon(R) X 12-core X1E80100 @ 3.40 GHz
In the tables below, column headers are total sequence length values used for benchmarking, and the row values are if the attention bias was used or not. Values are average inference time in ms over 100000 runs.
Fp16 results
Fp32 results