Skip to content

feat(cambricon): add mul provider - #957

Open
baominghelly wants to merge 1 commit into
masterfrom
feat/cambricon-mul
Open

feat(cambricon): add mul provider#957
baominghelly wants to merge 1 commit into
masterfrom
feat/cambricon-mul

Conversation

@baominghelly

Copy link
Copy Markdown
Contributor

Summary

  • Add a native Cambricon slot 0 provider for mul with contiguous, broadcasted, and strided tensor support.
  • Add reusable Cambricon task-range/stride-offset helpers and skip unsigned MLU cases that the torch_mlu tensor-cloning path cannot construct.

Motivation

The canonical mul operator does not currently have a native Cambricon implementation. This prevents InfiniOps from dispatching elementwise multiplication to slot 0 on Cambricon devices.

Type of Change

  • feat — new feature / new operator / new platform
  • fix — bug fix
  • perf — performance improvement (no behavioral change)
  • refactor — code restructuring without behavior change
  • test — adding or fixing tests only
  • docs — documentation only
  • build / ci — build system or CI configuration
  • chore — tooling, formatting, or other non-code changes
  • Breaking change (requires a ! in the Conventional Commits prefix or a BREAKING CHANGE: footer)

Platforms Affected

  • CPU (WITH_CPU)
  • NVIDIA (WITH_NVIDIA)
  • Iluvatar (WITH_ILUVATAR)
  • MetaX (WITH_METAX)
  • Cambricon (WITH_CAMBRICON)
  • Moore (WITH_MOORE)
  • Ascend (WITH_ASCEND)
  • PyTorch C++ bindings (WITH_TORCH)
  • Build system / CMake / CI
  • Python bindings / user-facing API

Smoke Test Result

A targeted Cambricon mul build and test were run. The repository-wide smoke subset was not run.

cmake -S . -B /workspace/build/infiniops-pr-mul \
  -DAUTO_DETECT_DEVICES=OFF \
  -DWITH_CPU=ON \
  -DWITH_CAMBRICON=ON \
  -DWITH_TORCH=OFF \
  -DWITH_LINKED=OFF \
  -DGENERATE_PYTHON_BINDINGS=ON \
  -DINFINI_OPS_OPS=mul \
  -DINFINI_RT_ROOT=/workspace/install/infinirt-master-test \
  -DPython_EXECUTABLE=/torch/venv3/pytorch/bin/python3.10 \
  -Dpybind11_DIR=/workspace/python-user/lib/python3.10/site-packages/pybind11/share/cmake/pybind11 \
  -DCMAKE_BUILD_TYPE=Release \
  -DCMAKE_INSTALL_PREFIX=/workspace/build/infiniops-pr-mul-site/infini
cmake --build /workspace/build/infiniops-pr-mul --parallel "$(nproc)"
cmake --install /workspace/build/infiniops-pr-mul

-- Wrapper op allowlist: mul
[100%] Built target ops

PYTHONPATH=/workspace/build/infiniops-pr-mul-site \
LD_LIBRARY_PATH=/workspace/build/infiniops-pr-mul-site/infini:/workspace/install/infinirt-master-test/lib \
/torch/venv3/pytorch/bin/python3.10 -m pytest \
  -q tests/test_mul.py --devices cambricon --maxfail=1

117 passed, 42 skipped in 1.10s

Test Results on Supported Platforms

Platform Affected Build / Smoke Result Full Result / Notes
NVIDIA No N/A - not affected N/A - not affected
Iluvatar No N/A - not affected N/A - not affected
MetaX No N/A - not affected N/A - not affected
Cambricon Yes Targeted mul build and tests passed Full suite not run
Moore No N/A - not affected N/A - not affected
Ascend No N/A - not affected N/A - not affected
Full `pytest` output (optional)
........................................................................ [ 45%]
............ssssssssssssssssssssssssssssssssssssssssss.................. [ 90%]
...............                                                          [100%]
117 passed, 42 skipped in 1.10s

Benchmark / Performance Impact

N/A - no performance benchmark was run.

Notes for Reviewers

  • The fast path handles contiguous tensors with matching shapes; the general path supports broadcasting and non-contiguous input/output strides.
  • Work is chunked through NRAM and distributed across Cambricon tasks with the shared kernel_utils.h helpers.
  • Supported kernel dtypes are float16, bfloat16, float32, int16, int32, int64, uint16, uint32, and uint64.
  • The uint16/uint32/uint64 MLU pytest cases are skipped because the current torch_mlu cloning path cannot construct those tensors; those kernel dtype paths were compiled but not exercised by this pytest run.
  • The repository-wide smoke subset and full test suite were not run; the PR remains a draft.

@baominghelly
baominghelly marked this pull request as ready for review August 31, 2026 08:31
@baominghelly
baominghelly requested review from a team and voltjia August 31, 2026 08:31
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