mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-07-26 19:52:38 +00:00
Make ROCm Attention biased+masked and biased+nomask scaling logic consistent (#14976)
The biased+masked and biased+nomask have different scaling logic in current ROCm implementation Currently, biased + masked: (QK'+ bias) * scale + convert(mask) biased + nomask: QK' * scale + bias which is not correct. What we want is QK' * scale [+ bias] That is, bias should not be scaled. This effectively follows https://github.com/microsoft/onnxruntime/pull/14517/files?w=1#diff-e4768ce15a73499f584f9cd7d71adcb1ff2ed8d68ad7e496723a4775cbc35e33
This commit is contained in:
parent
f83923d5df
commit
51b67fa15c
1 changed files with 5 additions and 5 deletions
|
|
@ -205,11 +205,7 @@ __global__ void SoftmaxWithRawMaskSmallKernel(
|
|||
// to avoid the performance impact from using the valid_items interface.
|
||||
float thread_data = -ROCMRT_INF_F;
|
||||
if (threadIdx.x < all_sequence_length) {
|
||||
if (add_before_softmax == nullptr) {
|
||||
thread_data = float(input[index]) * rsqrt_head_size;
|
||||
} else {
|
||||
thread_data = float(input[index] + add_before_softmax[index]) * rsqrt_head_size;
|
||||
}
|
||||
thread_data = float(input[index]) * rsqrt_head_size;
|
||||
|
||||
const int sequence_index = blockIdx.x % sequence_length;
|
||||
if (is_unidirectional) {
|
||||
|
|
@ -234,6 +230,10 @@ __global__ void SoftmaxWithRawMaskSmallKernel(
|
|||
thread_data = -ROCMRT_INF_F;
|
||||
}
|
||||
}
|
||||
|
||||
if (add_before_softmax != nullptr) {
|
||||
thread_data += float(add_before_softmax[index]);
|
||||
}
|
||||
}
|
||||
|
||||
if (skip_softmax) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue