Metadata-Version: 2.4
Name: torchcomms-hccl
Version: 0.1.0
Summary: CANN HCCL backend for torchcomms
Author: Yuanhao Ji
License: MIT License
        
        Copyright (c) 2026 torchcomms-hccl contributors
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Keywords: pytorch,distributed,hccl,cann,torchcomms
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: C++
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: torch==2.12.0
Requires-Dist: torchcomms==0.3.1
Provides-Extra: npu
Requires-Dist: torch-npu==2.12.0.post3; extra == "npu"
Provides-Extra: dev
Requires-Dist: pytest; extra == "dev"
Requires-Dist: pylint; extra == "dev"
Requires-Dist: clang-format; extra == "dev"
Dynamic: license-file

# torchcomms-hccl

[CANN HCCL](https://ascend.huawei.com/hccl) backend for
[torchcomms](https://github.com/meta-pytorch/torchcomms).

```python
import torch
import torch_npu        # register the "npu" backend
import torchcomms
import torchcomms_hccl  # registers the "hccl" backend

comm = torchcomms.new_comm("hccl", torch.device("npu"))
```

Only `all_reduce` is implemented; other collectives raise "not supported".

## Supported versions

| Package | Version |
|---------|---------|
| torch | 2.12.0 |
| torch-npu | 2.12.0.post3 |
| torchcomms | 0.3.1 |
| Python | 3.11 – 3.13 |

`torch-npu` and `torchcomms` both pin `torch==2.12.0`; install them as this set.

## Features

- `all_reduce` collective
- Auto-registers `hccl` via the `torchcomms.backends` entry point
- Builds **without** a CANN Toolkit (submodule headers + stub libs)
- Ships as a standalone wheel

## Requirements

- Python >= 3.11, CMake >= 3.22, a C++17 compiler
- Build: `torch==2.12.0` (CPU build) + `torchcomms==0.3.1`
- Runtime: CANN Toolkit, `torch-npu==2.12.0.post3`, NPU hardware

> **`torchcomms` is not on PyPI** (the PyPI name is a placeholder). Install it
> from the PyTorch index (it pins `torch==2.12.0`):
>
> ```bash
> pip install torch==2.12.0 --index-url https://download.pytorch.org/whl/cpu
> pip install torchcomms==0.3.1 --index-url https://download.pytorch.org/whl/cu126 --no-deps
> ```

## Install

```bash
git clone --recursive https://github.com/cann-hccl/torchcomms-hccl

cd torchcomms-hccl
pip install torch==2.12.0 --index-url https://download.pytorch.org/whl/cpu
pip install torchcomms==0.3.1 --index-url https://download.pytorch.org/whl/cu126 --no-deps
pip install -r requirements_dev.txt
bash build.sh
pip install dist/*.whl
```

From PyPI: `torchcomms` is not on PyPI, so install it from the PyTorch index
first (along with `torch-npu==2.12.0.post3` for NPU), then
`pip install torchcomms-hccl`.

## Usage

```bash
bash build.sh          # build the wheel
bash build.sh --lint   # clang-format (--Werror) + pylint
bash build.sh --test   # pytest (NPU tests skip without CANN)
```

```bash
torchrun --nproc_per_node=2 examples/all_reduce.py
```

## Supported collectives

| Op | Status |
|----|--------|
| `all_reduce` | ✅ |
| others (`all_gather`, `broadcast`, …) | 🚧 planned |

## Development

```bash
pip install -r requirements_dev.txt
bash build.sh --lint   # clang-format + pylint
pytest tests/       # the all_reduce test needs NPU + CANN
```

## License

[MIT License](./LICENSE)
