LogN Scaling

Description

For Qwen long sequences, LogN scales 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.

Name

Dimension

Data Type

Format

cpu or npu

logN

Incremental phase: [batch size]

Atlas A2 training products/Atlas A2 inference products and Atlas A3 inference products/Atlas A3 training products: float32

Atlas inference products: float16

ND

NPU

Other input tensors remain unchanged.

Constraints

None