Skip to content

fix(cambricon): link TopK Softmax for 16-bit inputs - #1051

Open
baominghelly wants to merge 2 commits into
masterfrom
fix/cambricon-topk-softmax-link
Open

baominghelly wants to merge 2 commits into
masterfrom
fix/cambricon-topk-softmax-link

Conversation

@baominghelly

@baominghelly baominghelly commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Instantiate the Cambricon TopkSoftmaxUnion launcher with InfiniRT's Float16 and BFloat16 storage types for each supported index type. Use the short names imported into infini::ops, as in the Cambricon fill launcher.

Motivation

The Cambricon provider introduced in #958 compiles its BANG kernel but fails to link a full native build. Host dispatch requests the InfiniRT storage types, while the BANG object emits the launcher symbols for __half and __bang_bfloat16. The linker reports six undefined TopkSoftmaxUnion references.

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

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 (Cambricon extension linkage)

Smoke Test Result

Validated the final commit in a fresh build directory on cambricon30 (MLU590-M9), with cncc 5.7.2 and InfiniRT c0810cf. The original full build failed at examples/gemm. The patched build linked the library and all examples.

cmake -S /workspace/src/InfiniOps-type-fix -B /workspace/build/InfiniOps-pr-short-types -G Ninja \
  -DWITH_CPU=ON -DWITH_CAMBRICON=ON -DAUTO_DETECT_DEVICES=OFF \
  -DAUTO_DETECT_BACKENDS=OFF -DWITH_TORCH=OFF -DWITH_LINKED=OFF \
  -DINFINI_OPS_SMOKE_BUILD=OFF -DGENERATE_PYTHON_BINDINGS=OFF \
  -DCMAKE_BUILD_TYPE=Release \
  -DFETCHCONTENT_SOURCE_DIR_NLOHMANN_JSON=/workspace/transfer/json \
  -DINFINI_RT_ROOT=/workspace/install/InfiniRT \
  -DCMAKE_INSTALL_PREFIX=/workspace/install/InfiniOps-pr-short-types
cmake --build /workspace/build/InfiniOps-pr-short-types --parallel 24
cmake --install /workspace/build/InfiniOps-pr-short-types
[28/33] Linking CXX shared library src/libinfiniops.so
[32/33] Linking CXX executable examples/gemm
-- Installing: /workspace/install/InfiniOps-pr-short-types/lib/libinfiniops.so
All 9 TopkSoftmaxUnion symbols match the previous PR commit.
libinfiniops.so loaded with RTLD_NOW

nm -DC --undefined-only found zero unresolved TopkSoftmaxUnion symbols. Clang Format 21.1.8 passed on the changed file.

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 Full native build, install, and dynamic load passed Python wheel and MLU pytest suites not run
Moore No N/A - not affected N/A - not affected
Ascend No N/A - not affected N/A - not affected

Benchmark / Performance Impact

N/A

Notes for Reviewers

The existing LoadAsFloat branches already handle both InfiniRT storage types. The revised instantiations resolve the FP16 and BF16 launchers for int32_t, uint32_t, and int64_t indices. The repository's default Cambricon CI smoke allowlist omits topk_softmax, so the reproduction and validation used the full native configuration.

Instantiate the launcher with the InfiniRT storage types used by host dispatch so the FP16 and BF16 symbols resolve for every supported index type.
@baominghelly
baominghelly marked this pull request as ready for review November 20, 2026 05:36
@baominghelly
baominghelly requested a review from a team November 20, 2026 05:36

This branch has not been deployed

No deployments
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