Merged
feat(deepseek_v4): Add new fused LIFA operator for DeepSeek-v4 #744
yasakova_anastasiaAdd on Sep 25
feat(deepseek_v4): Add new fused LIFA operator for DeepSeek-v4 #744
Merged
yasakova_anastasiaAdd on Sep 25
yasakova_anastasia
yasakova_anastasiaCollaborators
Sep 25

Was This PR authored or co-authored using generative AI tooling?

[x] No
[ ] Yes
__1. AI Agent :
__2. AI Model :
__3. Prompt :

What this PR does / why we need it:

Adds QuantLightningIndexerFlashAttention, a PyPTO operator fusing the three sequential stages of the DeepSeek V4 lightning-attention decode path:

  • prolog: int8 matmul + dequant, inverse RoPE, Hadamard transform, per-token int8 quantization -> q, q_scale, weights;
  • indexer: weighted dot product against the paged int8 key cache and TopK selection -> topk_res;
  • SCFA: gather from the compressed KV cache by topk_res, sliding-window concat, softmax with attention sink, PV -> attention_out.

Performance

Model-level decode, per-token latency:

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

Swapping three PyPTO operators for the fused one removes 6.08 ms per token (-15.7%) and closes the gap to the AscendC baseline from 29% to 16%. Dropped
into the AscendC stack, the fused operator matches the reference (1.01x).

HW: 4x Ascend910C

Which issue this PR fixes

Resolves #432

Special notes for your reviewer:

Change Type / 改动类型

Testing / 测试信息

Checklist / 检查清单

likedislike
Pull Request has been successfully merged by CANN-robot.
(Thank you for yasakova_anastasia's contribution.)
yasakova_anastasiayasakova_anastasiaCollaborators
Sep 25 Created pull request, commit 94af7f9c
CANN-robotCANN-robotCollaborators
Sep 25 Added label: cann-cla/yes
CANN-robot
CANN-robotCollaborators
Sep 25 Comments:

Thanks for your pull-request.
The full list of commands accepted by me can be found at here.
You can get sig-info at here.
You can self-configure the PR merge rules for this repository. For more details, please refer to Here.
For more, you also can visit HICANN.


PR Approval Progress

✅ Congratulations! All modules have met the lgtm and approve requirements.

Module Approval Details

module lgtm status approve status
repo-cann/pypto-gym ✅ li-shengxian3, liulufang_gitcode (2/2) ✅ li-shengxian3, liulufang_gitcode (2/1)

💡 Tip:

  • Committer can comment /approve or /lgtm
  • Commenting /approve implies both code review (lgtm) and intent to merge (approve)

CLA Signature Pass

yasakova_anastasia, thanks for your pull request. All authors of the commits have signed the CLA. 👍

likedislike
CANN-robot
CANN-robotCollaborators
Sep 25 Comments:

CLA Signature Pass

yasakova_anastasia, thanks for your pull request. All authors of the commits have signed the CLA. 👍

likedislike
yasakova_anastasiayasakova_anastasiaCollaborators
Sep 25 Modify description of pull request
80 messages are collapsed here。 See more
CANN-robotCANN-robotCollaborators
7 hours ago Removed label: ci-pipeline-failed
CANN-robotCANN-robotCollaborators
7 hours ago Added label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
7 hours ago Removed label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
7 hours ago Added label: ci-pipeline-passed
CANN-robotCANN-robotCollaborators
7 hours ago Merged pull request