Skip to content

Commit d209dcc

Browse files
committed
Add UCCL as an external build project.
Ultra & Unified CCL is a efficient communication library for GPUs, covering collectives, P2P (e.g., KV cache transfer, RL weight transfer), and EP (e.g., IBGDA), with two key focuses: - Flexibility for high performance in fast-evolving ML workloads - Portability for connecting heterogeneous GPUs in ML workloads For collectives, UCCL-collective serves as a drop-in replacement for NCCL/RCCL (e.g., requiring no changes to application code), and significantly outperforms them in both latency and throughput across various settings.
1 parent eb66f74 commit d209dcc

File tree

2 files changed

+152
-0
lines changed

2 files changed

+152
-0
lines changed

external-builds/uccl/README.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Build UCCL with ROCm support
2+
3+
This directory provides tooling for building UCCL with ROCm Python wheels.
4+
5+
Table of contents:
6+
7+
- [Support status](#support-status)
8+
- [Build instructions](#build-instructions)
9+
- [Running/testing UCCL](#runningtesting-uccl)
10+
- [Development instructions](#development-instructions)
11+
12+
## Support status
13+
14+
| Project / feature | Linux support | Windows support |
15+
| ------------------------------ | ------------- | ---------------- |
16+
| UCCL | ✅ Supported | ❌ Not Supported |
17+
18+
## Build instructions
19+
20+
UCCL builds in an Ubuntu 22.04 docker container and outputs a
21+
manylinux wheel to a directory named `wheelbase-therock` in the repo
22+
on the host.
23+
24+
### Prerequisites and setup
25+
26+
The build container installs a specific version Python from PyPA, if
27+
explicitly specified, or the host's python version otherwise.
28+
29+
The build script currently requires that TheRock index URL be provided
30+
explicitly and uses that to install UCCL's ROCm prerequisites inside
31+
the build container. The specific versions of those ROCm packages are
32+
then recorded in the UCCL wheel's dependences.
33+
34+
### Quickstart
35+
36+
Building is done with a single command that will clone the UCCL
37+
sources, launch a docker container, and perform the build in one go.
38+
39+
Example:
40+
41+
```bash
42+
python build_prod_wheels.py --output-dir outputs \
43+
--index-url http://rocm.nightlies.amd.com/v2/gfx94X-dcgpu
44+
```
45+
46+
Optional arguments for the name of the directory with cloned UCCL
47+
sources (default `uccl`) and specific python version are provided.
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
#!/usr/bin/env python
2+
r"""Builds production UCCL wheel based on the rocm wheels.
3+
4+
The UCCL project already has a TheRock build target that is currently
5+
based on the nightly wheels.
6+
"""
7+
8+
import argparse
9+
from datetime import date
10+
import json
11+
import os
12+
from pathlib import Path
13+
import platform
14+
import re
15+
import shutil
16+
import shlex
17+
import subprocess
18+
import sys
19+
import tempfile
20+
import textwrap
21+
22+
script_dir = Path(__file__).resolve().parent
23+
24+
is_windows = platform.system() == "Windows"
25+
26+
def exec(args: list[str | Path], cwd: Path, env: dict[str, str] | None = None):
27+
args = [str(arg) for arg in args]
28+
full_env = dict(os.environ)
29+
print(f"++ Exec [{cwd}]$ {shlex.join(args)}")
30+
if env:
31+
print(f":: Env:")
32+
for k, v in env.items():
33+
print(f" {k}={v}")
34+
full_env.update(env)
35+
subprocess.check_call(args, cwd=str(cwd), env=full_env)
36+
37+
38+
def copy_to_output(args: argparse.Namespace, src_file: Path):
39+
output_dir: Path = args.output_dir
40+
print(f"++ Copy {src_file} -> {output_dir}")
41+
output_dir.mkdir(parents=True, exist_ok=True)
42+
shutil.copy2(src_file, output_dir)
43+
44+
45+
def find_built_wheel(dist_dir: Path, dist_package: str) -> Path:
46+
dist_package = dist_package.replace("-", "_")
47+
glob = f"{dist_package}-*.whl"
48+
all_wheels = list(dist_dir.glob(glob))
49+
if not all_wheels:
50+
raise RuntimeError(f"No wheels matching '{glob}' found in {dist_dir}")
51+
if len(all_wheels) != 1:
52+
raise RuntimeError(f"Found multiple wheels matching '{glob}' in {dist_dir}")
53+
return all_wheels[0]
54+
55+
56+
def do_build(args: argparse.Namespace):
57+
uccl_dir: Path = args.uccl_dir
58+
59+
if is_windows:
60+
print("WARNING: Unsure if UCCL builds on Windows.", file=sys.stderr)
61+
62+
if not uccl_dir.exists():
63+
exec(["git", "clone", "--recursive", "https://github.com/uccl-project/uccl.git", str(uccl_dir)],
64+
cwd=script_dir)
65+
66+
exec(["./build.sh", "therock", "all", args.python_version, args.index_url],
67+
cwd=uccl_dir)
68+
69+
built_wheel = find_built_wheel(uccl_dir / "wheelhouse-therock", "uccl")
70+
print(f"Found built wheel: {built_wheel}")
71+
copy_to_output(args, built_wheel)
72+
73+
def main(argv: list[str]):
74+
p = argparse.ArgumentParser(prog="build_prod_wheels.py")
75+
76+
p.add_argument(
77+
"--output-dir",
78+
type=Path,
79+
required=True,
80+
help="Directory to copy built wheels to",
81+
)
82+
p.add_argument(
83+
"--uccl-dir",
84+
default=Path(script_dir / "uccl"),
85+
type=Path,
86+
help="UCCL source directory",
87+
)
88+
p.add_argument(
89+
"--python-version",
90+
default=".".join(platform.python_version_tuple()[:2]),
91+
type=str,
92+
help="Python version to use for the build",
93+
)
94+
p.add_argument(
95+
"--index-url",
96+
required=True,
97+
help="Base URL of the Python Package Index."
98+
)
99+
100+
args = p.parse_args(argv)
101+
do_build(args)
102+
103+
104+
if __name__ == "__main__":
105+
main(sys.argv[1:])

0 commit comments

Comments
 (0)