NeutronSparseLite accelerates sparse matrix-dense matrix multiplication (SpMM) on Ascend NPUs. The runtime is built on MindSpore, Huawei's Ascend-native AI framework, so the main program runs through the Ascend backend and dispatches to compiled NPU operators supplied by MindSpore/CANN whenever the corresponding tensor operations are executed.
The project uses a hybrid heterogeneous execution strategy.
In short, MindSpore is the primary Ascend-native runtime layer for this repository, and NeutronSparseLite relies on its prebuilt Ascend operator stack instead of implementing every NPU kernel directly in Python.
We use openEuler 2.10.11 as the operating system and CANN Toolkit 8.2.rc1 for the Ascend backend. MindSpore must be installed with Ascend support; CPU-only MindSpore builds are not enough for the benchmark path in NeutronSparseLiteRun.py.
The Python packages and corresponding versions required for NeutronSparse are as follows:
| Package | Version |
|---|---|
| Python | 3.11 |
| MindSpore | 2.7.0.rc1 |
Why MindSpore matters here:
- Ascend-native: MindSpore is designed to target Ascend hardware through CANN and the Ascend runtime.
- Compiled NPU operators: calls such as
ops.matmul,COOTensor.to_dense, andTensorScatterAddare dispatched to compiled Ascend kernels when running ondevice_target="Ascend". - Python orchestration, NPU execution: the Python code prepares data, chooses dense or sparse paths, and launches tensor operations; heavy numerical work is handled by the compiled NPU operator stack.
Before running the project, you must compile the custom C++ preprocessing extension. This extension prepares graph metadata on CPU; runtime SpMM execution still goes through MindSpore's Ascend backend and its compiled NPU operators.
Enter the compilation directory
cd prepare/sgt_cpp
Clean previous build artifacts
rm -rf build
Compile the extension in-place
python setup.py build_ext --inplace
Navigate to the data directory and extract the dataset archive.
Go to the data directory (assuming you are currently in prepare/sgt_cpp)
cd ../../origin_data/data_mtx
Extract the data
tar -zxvf data.tar.gz
After extracting the data, navigate to the prepare folder to run the preprocessing scripts.
Go back to the prepare folder
cd ../../prepare
-
Convert MTX format to COO format
python mtx2coo.py -
Reorder the graph (Replace 'reddit' with your dataset name)
bash graph_reorder.sh reddit -
Generate CSR format
python generate_csr.py -
Prepare data for NeutronSparse
python NeutronSparsePrepare.py
Once compilation and data preparation are complete, you can run the main program.
Go back to the project root, then enter the run folder
cd ../NeutronSparseLite
Quick start the training/inference
python NeutronSparseLiteRun.py
At startup, the program sets:
context.set_context(mode=context.PYNATIVE_MODE, device_target="Ascend", device_id=0)This makes MindSpore launch tensor operations on Ascend. If 3rdparty/ops-nn is present, the program also reports the optional ops-nn helper/source discovery status before falling back to the stable MindSpore operator path for execution.