Skip to content

feat(edge_softmax): add edge_softmax and CSRTranspose NPU support for Ascend - #20

Open
xuejiakn wants to merge 4 commits into
BUPT-GAMMA:masterfrom
xuejiakn:feat/edge-softmax-csr-transpose
Open

feat(edge_softmax): add edge_softmax and CSRTranspose NPU support for Ascend#20
xuejiakn wants to merge 4 commits into
BUPT-GAMMA:masterfrom
xuejiakn:feat/edge-softmax-csr-transpose

Conversation

@xuejiakn

Copy link
Copy Markdown

Summary

Add edge_softmax and CSRTranspose NPU support, required by GAT/PAGTN attention normalization.

Changes

  • src/array/ascend/edge_softmax.cc + edge_softmax_kernel.cpp + edge_softmax_tiling.h: edge_softmax NPU kernel
  • src/array/ascend/csr_transpose.cc: CSR transpose NPU op
  • src/array/array.cc + kernel.cc: dispatch registration
  • tests/ascend/test_edge_softmax_npu.py: NPU test

Restructure note

Replaces #15[10]. Independent of other PRs (base = master).

… Ascend

Add Ascend NPU adaptation for edge_softmax operator, enabling GAT/PAGTN
graph attention network training on Ascend 910B NPU.

New operators:
- edge_softmax forward/backward: Ascend C kernel with FullLoad/RowSplit
  dual-mode, FP32/FP16 support, AR/ARA (num_heads=1/>1) branches
- CSRTranspose: Ascend implementation via COOToSR(COOTranspose(CSRToCOO))
  chain, reusing existing Ascend kernels

Framework integration:
- kernel.cc: dispatch edge_softmax by data tensor device (not graph context)
  to handle NPU tensors with CPU-resident graph topology; add CPU fallback
  for BackwardSegmentCmp and ScatterAdd (needed by GAT WeightedSumAndMax)
- array.cc: add Ascend dispatch branch for CSRTranspose

Host code (edge_softmax.cc):
- ACL host with forward/backward template specializations (FP32/FP16 x
  int32/int64)
- CSC edge ID remapping via CPU gather/scatter (NPU torch index ops
  unreliable on DGL blob tensors)
- Backward interface adapted to DGL convention (sds = out * grad_out)

End-to-end validation:
- pytest test_gat.py: 2/3 passed, 1 regression needs 800 epochs (CPU also
  needs more epochs)
- pytest test_pagtn.py: no operator crashes (precision is test-epoch limit)
- test_edge_softmax_npu.py: 78 tests, 100% pass (FP32/FP16 x fwd/bwd x
  6 graph types x 3 num_heads + edge cases + perf)

Co-Authored-By: CANNBot <cannbot@ascend>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant