Open
[Feature]: [DeepSeek V4] Fused QuantLightningIndexerFlashAttention (LIFA) operator for decode #432
yasakova_anastasiaAdd on  7 days ago
yasakova_anastasia
yasakova_anastasiaCollaborators
7 days ago Create

Feature Description / 功能描述

Thanks for sending a feature request! Please fill in the following template.
感谢提交功能需求!请填写以下模板。

Feature Description / 功能描述

Add QuantLightningIndexerFlashAttention (LIFA): a single PyPTO operator that
covers three consecutive stages of the DeepSeek V4 lightning-attention decode
path.

  1. Prolog (quant): dequantized linear transform of the low-rank query qr,
    inverse RoPE, Hadamard transform, per-token-head quantization
    -> q (int8), q_scale (fp16), weights (fp16).
  2. Lightning Indexer (quant decode): paged int8 QK matmul against the key
    cache, weighted reduction, key rescaling, TopK selection
    -> topk_res (int32).
  3. SCFA: window selection + sparse gather from the compressed KV cache by
    topk_res, then C1 (QK) / V1 (softmax with attention sink) / C2 (PV)
    -> attention_out (bf16).

Scope: decode phase only

Use Case / 应用场景

The current PyPTO decode path runs seven operators at 38.72 ms per token against 27.32 ms for the AscendC reference — 0.71x. The gap is dominated by host-side dispatch and by intermediate tensors crossing the kernel boundary.

Three of the seven operators are strictly sequential and exchange data no other consumer needs.

Fusing these stages is the largest single dispatch-overhead reduction available on this path without touching the remaining operators.

Expected Behavior / 期望行为

  • Model-level decode latency below the seven-operator PyPTO path.
  • Target: no regression against the AscendC reference when the operator is
    placed in an otherwise-AscendC stack.

Additional Information / 附加信息

Measured on the model, decode latency per token:

Configuration ms / token vs AscendC
AscendC (baseline) 27.32 1.00x
AscendC + LIFA 27.03 1.01x
PyPTO, 7 separate ops 38.72 0.71x
PyPTO, 5 ops + LIFA 32.64 0.84x

HW: 4x Ascend910C

Use Case / 应用场景

Expected Behavior / 期望行为

Additional Information / 附加信息

likedislike
huangluhuangluCollaborators
6 days ago Assign yasakova_anastasia as responsible person
yasakova_anastasia
yasakova_anastasiaCollaborators
3 days ago Comments:

@lululu40888
We can close this issue because PR #744 was merged

likedislike
wangzheng97
wangzheng97Collaborators
1 day ago Comments:

PR已合入 master。感谢贡献,关闭此 Issue。

likedislike