Repository navigation
feat!: support AVG reductions for Ascend HCCL - #85
Merged
Merged
Conversation
Implement `AllReduce` and `ReduceScatter` AVG as HCCL SUM followed by in-place ACLNN division on the same stream. - support FP16/BF16/FP32 and truncating INT8/INT16 averages - cache repeatable division plans with event-protected resource cleanup - add fatal internal HCCL/ACL/ACLNN checks while propagating native statuses - isolate AVG dependency discovery from basic HCCL probing BREAKING CHANGE: `WITH_HCCL` builds now require the ACLNN division header and `libopapi`, including applications that do not request AVG.
Delete copy operations for `HcclAveragePlan` and `AverageCache` to prevent duplicate resource cleanup, while preserving default cache construction. Remove the ACL/ACLNN diagnostic's terminal period to follow LLVM style.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Support
infinicclAvgin HCCLAllReduceandReduceScatterby submitting native HCCL SUM followed by ACLNN in-place division on the same stream. Previously, the HCCL reduction map rejected AVG. FP16, BF16, FP32, INT8, and INT16 are supported; unsupported AVG datatypes returnNotSupported. There is no public API or communicator ABI change.Breaking build change:
WITH_HCCL=ONnow requiresaclnnop/aclnn_div.handlibopapi, including builds whose applications never request AVG. Basic HCCL probing still checks only HCCL, but actual bbackend configuration requires these additional dependencies.AVG versus the native HCCL path:

Changes
Reduction Dispatch
HcclReductionOpinsrc/backends/ccl/hccl/reduction_op.hto preserve theAVGflag through the shared CCL adapter while mapping native execution toHCCL_REDUCE_SUM.AVGpreparation/execution betweenAllReduceandReduceScatterinsrc/backends/ccl/hccl/api.h. Skipping division if nativeSUMfails.Ascend Averaging
src/backends/ccl/hccl/ascend/average.{h,cc}usingaclnnInplaceDivMods, with an FP32 divisor for floating inputs and an INT64 divisor with truncation toward zero for INT8/INT16.SUM. Reuse thread-local plans keyed by context, stream, output buffer, element count, datatype, and communicator size.Error Handling
INFINI_CHECK_HCCLandINFINI_CHECK_ACLNN.AVGtypes to the publicNotSupportedresult.Build Integration
_infiniccl_find_hccl_average, reusing the existing Ascend SDK hints. Remove invalidQUIETsearch arguments.libopapilinkage insrc/CMakeLists.txt.Platform and Backend Affected
Platform
Backend
Performance Impact
Every
AVGcall: HCCL first computes SUM, then ACLNN divides the output by the number of ranks. That adds an operator launch and another read/write pass over the output buffer.First call or cache miss: InfiniCCL also creates the tensor/scalar descriptors, prepares the operator executor, creates a completion event, and allocates workspace if needed.
Cache hit: Matching calls reuse those resources. They still execute the division; caching removes repeated preparation work.
Other reductions: SUM, PROD, MIN, and MAX skip AVG preparation and division.
The previous Ascend/HCCL implementation could not run AVG, so when Ascend is required, this is the cost of enabling AVG rather than a regression from an existing supported AVG path. No controlled performance comparison is reported.
Known Issues & Future Work
AVGis disabled because CANN 9.1 division probes lost precision for large values. Unsigned types and FP64 remain disabled pending validation.SUMproduces an original-datatype result before division, so overflow and rounding can occur before averaging.resource unavailableduring communicator initialization, followed by a cleanup failure. A retry and the final example suite passed; the intermittent failure's root cause is unresolved.Test Results
Environment: AArch64 Ascend 910C, CANN 9.1.0/A3 container, CMake 3.27.9, native HCCL and local OpenMPI configurations.
Test Involved Platform
Test Involved Backend
Ascend HCCL + OMPI:
ccl_mpi_hybrid_all_gather.log
ccl_mpi_hybrid_all_reduce.log
ccl_mpi_hybrid_send_recv.log
Ascend HCCL:
ccl_all_gather.log
ccl_all_reduce.log
ccl_all_reduce_fp16_bf16.log
ccl_reduce_scatter.log
ccl_send_recv.log
Checklist
Title, Branch, and Commits
feat: …,fix(nccl): …).<type>/xxx-yyyy-zzzzwhere<type>matches the PR title's Conventional Commits type and words are joined with hyphens (seeCONTRIBUTING.md§Branches).CONTRIBUTING.md§Pull Requests).master— the branch is rebased cleanly on top of the currentmaster.fixup!/squash!/wipcommits remain.Scope and Design
CONTRIBUTING.md§Code/General).printf/std::cout/print(...)left behind, orTODOwithout an owner and issue link.General Code Hygiene
CONTRIBUTING.md§Code/General).CONTRIBUTING.md§Code/General).the `AllReduce` implementation) (CONTRIBUTING.md§Code/General).CONTRIBUTING.md§Code/General).CONTRIBUTING.md§Code/General; §Python).C++ Specific (if C++ files changed)
clang-format(version 16, per.github/workflows/clang-format.yml) has been run against all modified applicable files; the diff is clean.assertwith messages that include at least__FILE__,__LINE__, and__func__(CONTRIBUTING.md§C++).CONTRIBUTING.md§C++).CONTRIBUTING.md§C++).CONTRIBUTING.md§C++).CONTRIBUTING.md§C++).CONTRIBUTING.md§C++).Python Specific (if Python files changed)
N/A — No Python files are changed.
Testing
Build, CI, and Tooling
CMakeLists.txtunderif(AUTO_DETECT_DEVICES)or toif(AUTO_DETECT_BACKENDS)if applicable.clang-format.yml,ruff.yml) are green locally (or expected to be green on CI).Documentation
README.md,CONTRIBUTING.md, or inline docs updated when behavior, build flags, or developer workflow changed.!orBREAKING CHANGE:footer.Security and Safety