LogN Scaling
Description
For the Qwen long sequence scenario, LogN is used to scale attention.
Formula:

m is a training length, and n is a prediction length.
How to Enable
Set scaleType to infer::PagedAttentionParam::SCALE_TYPE_LOGN.
When LogN scaling is used, add an input tensor named logN to PagedAttentionOperation. The specifications are as follows.
Parameter |
Dimension |
Data Type |
Format |
cpu or npu |
|---|---|---|---|---|
logN |
Incremental phase: [batch size] |
ND |
NPU |
Other input tensors remain unchanged.
Constraints
None
Parent topic: Functions