Skip to content

feat(sddmm): add SDDMM operator with NPU-native kernels for Ascend - #16

Open
xuejiakn wants to merge 4 commits into
BUPT-GAMMA:masterfrom
xuejiakn:feat/sddmm-ascend
Open

feat(sddmm): add SDDMM operator with NPU-native kernels for Ascend#16
xuejiakn wants to merge 4 commits into
BUPT-GAMMA:masterfrom
xuejiakn:feat/sddmm-ascend

Conversation

@xuejiakn

Copy link
Copy Markdown

Summary

Add SDDMM (Sampled Dense Matrix Multiplication) operator with Ascend NPU-native kernels.

Changes

  • src/array/ascend/sddmm.cc: SDDMM dispatch (FP32)
  • sddmm_dot_kernel.cpp / sddmm_copy_lhs_kernel.cpp: NPU kernels
  • sddmm_copy_lhs_tiling.h: tiling params
  • kernel.cc: SDDMM/CSRSDDMM/COOSDDMM dispatch macros
  • _sparse_ops.py + sddmm.cc: fix add/sub/mul/div CPU fallback with NPU stream sync

Restructure note

Replaces SDDMM commits from #14[1][7] and #15[4][9] (duplicates). Base on master; the _sparse_ops.py change has a small intersection with the stream-sync PR (#1) but is independently reviewable.

xuejiakn and others added 2 commits July 28, 2026 14:17
- Add sddmm_dot_kernel.cpp: Ascend C kernel for dot op (FP32/FP16, COO format)
- Add sddmm_copy_lhs_kernel.cpp: NPU-native gather kernel for copy_lhs/copy_rhs
  (avoids CPU roundtrip that caused PyTorch NPU stream sync issues with autograd)
- Add sddmm.cc: host dispatch supporting all ops (dot/add/sub/mul/div/copy_lhs/copy_rhs)
  - dot: NPU kernel (COO + CSR via CSRToCOO)
  - copy_lhs/copy_rhs: NPU gather kernel (no CPU roundtrip)
  - add/sub/mul/div: CPU fallback (FP32 only)
  - int64 index: cast to int32 then delegate to int32 path
- Modify kernel.cc: SDDMM/CSRSDDMM/COOSDDMM dispatch macros to ATEN_XPU_SWITCH_CUDA_ASCEND
- _sparse_ops.py: ensure CPU fallback path for add/sub/mul/div is taken
  when NPU stream sync is involved
- sddmm.cc: align fallback dispatch with the fix

Source: cherry-pick from dgl-ascend PR BUPT-GAMMA#15 commit 14b4e38 (test file
excluded, belongs to the dedicated test PR).
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