实现 ALiBi:Attention_ALiBi(Q,K,V)=softmax(dQKT+α⋅Δ)V,其中 Δ=i−j 为相对位置偏置,α 为斜率。按行应用 softmax,Q,K,V,output,α 为 float32。
- Use only native features (external libraries are not permitted)
- The solve function signature must remain unchanged
- 输出写入
output
见页面两组示例(含 α 参数)。
- Q∈RM×d; K,V∈RN×d
- 1≤M,N≤2048; 1≤d≤1024; −1.0≤α≤1.0
- Performance: M=2048,N=2048