Skip to content

feat(cambricon): add Copy implementation - #927

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

feat(cambricon): add Copy implementation#927
baominghelly wants to merge 1 commit into
masterfrom
feat/cambricon-copy

Conversation

@baominghelly

Copy link
Copy Markdown
Contributor

Summary

  • Add a CNNL-based Cambricon provider for Copy using cnnlCopy_v2.
  • Add reusable Cambricon CNNL/CNRT resource helpers and extend Copy coverage for scalar tensors and strided KV-cache slices.

Motivation

Cambricon currently has no native provider for the non-deprecated Copy operator. This prevents layout-preserving, broadcast, and strided-output copy paths from running through InfiniOps on MLU 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

The standard smoke set was not run because its operator allowlist does not include copy. A Copy-only Cambricon build passed:

cmake -S /workspace/src/InfiniOps-upstream \
  -B /workspace/build/infiniops-upstream \
  -DINFINI_OPS_OPS=copy
cmake --build /workspace/build/infiniops-upstream --parallel 32

[1/3] Building CXX object .../generated_dispatch_0.cc.o
[2/3] Building CXX object .../copy.cc.o
[3/3] Linking CXX shared module src/ops.cpython-310-x86_64-linux-gnu.so

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 build passed; standard smoke not run 42 targeted Copy tests passed
Moore No N/A - not affected N/A - not affected
Ascend No N/A - not affected N/A - not affected
Targeted pytest output
python -m pytest tests/test_copy.py -q --devices cambricon

..........................................                               [100%]
42 passed in 0.25s

Benchmark / Performance Impact

N/A. This adds a previously missing Cambricon provider and does not change an existing implementation.

Notes for Reviewers

  • The provider supports scalar, broadcast, non-contiguous input, and strided output tensors, including KV-cache slice writes.
  • CNNL execution uses the caller's queue and validates caller-provided workspace capacity.
  • The CNNL/CNRT RAII helper names are aligned with feat(cambricon): add Embedding implementation #926; this PR extends tensor descriptor setup to scalar tensors and the 64-bit cnnlSetTensorDescriptorEx_v2 interface.
  • No deprecated RearrangeInfinilm provider is added.

@baominghelly baominghelly changed the title feat(cambricon): add copy provider feat(cambricon): add Copy implementation Aug 12, 2026
@baominghelly
baominghelly marked this pull request as ready for review August 12, 2026 09:19
@baominghelly
baominghelly requested review from a team and voltjia August 12, 2026 09:19
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