Skip to content

Repository files navigation

MSCCL

Microsoft Collective Communication Library (MSCCL) is a platform to execute custom collective communication algorithms on heterogenous accelerators supported by Microsoft Azure. MSCCL currently supports NVIDIA and AMD GPUs. The research prototype of this project is microsoft/msccl.

Introduction

MSCCL vision is to provide a unified, efficient, and scalable framework for executing collective communication algorithms on heterogenous accelerators. To achieve this, MSCCL has multiple components:

  • MSCCL toolkit: Inter-connection among accelerators have different latencies and bandwidths. Therefore, a generic collective communication algorithm does not necessarily well for all topologies and buffer sizes. In order to provide the flexibility, we provide the MSCCL toolkit, which allows a user to write a hyper-optimized collective communication algorithm for a given topology and a buffer size. MSCCL toolkit contains a high-level DSL (MSCCLang) and a compiler which generate an IR for the MSCCL executor to run on the backend. Example provides some instances on how MSCCL toolkit with the runtime works. Please refer to MSCCL toolkit for more information.

  • MSCCL scheduler: MSCCL scheduler provides an example design and implementation of how to select optimal MSCCL algorithms for MSCCL executors.

  • MSCCL executor: MSCCL executor is a set of libraries that are responsible for running custom-written collective communication algorithms on heterogenous accelerators. Each kind of accelerator has a corresponding executor library that is specifically optimized it. Different executor libraries share the same interface to run MSCCL algorithm IR from MSCCL toolkit and talk with MSCCL scheduler. For NVIDIA GPUs, it's msccl-executor-nccl which is built on top of NCCL. For AMD GPUs, it's RCCL which already integrated all MSCCL executor features.

  • MSCCL test toolkit(msccl-tests-nccl): These tests check both the performance and the correctness of MSCCL operations.

Performance

For reference, FP16 All-Reduce and All-Gather algorithms were tested and compared on ND H100 v5 VM, using msccl-tests-nccl.

FP16 All-Reduce Latency (us)All-Gather Latency (us)
Message SizeNCCLMSCCLMSCCL SpeedupMessage SizeNCCLMSCCLMSCCL Speedup
1KB13.127.501.80x1KB9.545.651.69x
2KB14.397.481.92x2KB9.85.71.72x
4KB15.287.492.04x4KB9.785.431.80x
8KB15.697.672.04x8KB9.785.471.81x
16KB16.648.032.07x16KB10.295.531.86x
32KB19.39.082.13x32KB12.495.752.17x
64KB2010.361.93x64KB12.875.952.16x
128KB20.4211.061.85x128KB13.166.382.06x
256KB20.512.861.60x256KB13.237.261.82x
512KB29.8919.141.56x512KB13.398.711.54x
1MB31.9422.311.43x1MB18.3312.31.49x
2MB37.9533.431.14x2MB23.1817.751.31x
4MB49.2843.971.12x4MB33.6623.371.44x
8MB77.0168.161.13x8MB44.738.541.16x
16MB116115.71.00x16MB67.1967.161.00x
32MB187.2186.51.00x32MB104.798.41.06x
64MB317.4315.71.01x64MB192.4181.91.06x
128MB572.5570.41.00x128MB368.3348.41.06x
256MB10791075.61.00x256MB699.5680.71.03x
512MB2071.12067.91.00x512MB1358.61339.31.01x
1GB4028.74026.81.00x1GB2663.826331.01x

Example

In order to use MSCCL, you may follow these steps to use two different MSCCL algorithms for AllReduce on Azure NDv4 which has 8xA100 GPUs:

1. Download the source code of msccl and related submodules

$ git clone https://github.com/Azure/msccl.git --recurse-submodules

2. Below is the steps to install MSCCL executor:

$ git clone https://github.com/Azure/msccl.git --recurse-submodules
$ cd msccl/executor/msccl-executor-nccl
$ make -j src.build
$ cd ../
$ cd ../

3. Below is the steps to install msccl-tests-nccl for performance evaluation:

$ cd tests/msccl-tests-nccl/
$ make MPI=1 MPI_HOME=/path/to/mpi CUDA_HOME=/path/to/cuda NCCL_HOME=$HOME/msccl/executor/msccl-executor-nccl/build/ -j
$ cd ../
$ cd ../

4. Apply the msccl algo when using msccl external scheduler

  • for ndv4, we already have algo optimized, you can use msccl scheduler to apply this algo directly to the executor, below is the steps to apply the scheduler
$ sudo apt-get install libcurl4-openssl-dev nlohmann-json3-dev
$ cd scheduler/msccl-scheduler
for nccl:
$ CXX=/path/to/nvcc BIN_HOME=/path/to/nccl/binary SRC_HOME=/path/to/nccl/source make
for rccl:
$ CXX=/path/to/nvcc BIN_HOME=/path/to/nccl/binary SRC_HOME=/path/to/nccl/source make PLATFORM=RCCL
$ make install 
  • for customize the msccl algo for your system, you can install MSCCL toolkit to compile a few custom algorithms:
$ git clone https://github.com/Azure/msccl-tools.git
$ cd msccl-tools/
$ pip install .
$ cd ../
$ python msccl-tools/examples/mscclang/allreduce_a100_allpairs.py --protocol=LL 8 2 > test.xml
$ cd ../

The compiler's generated code is an XML file (test.xml) that is fed to MSCCL runtime. To evaluate its performance, copy the test.xml to the msccl/executor/msccl-executor-nccl/build/lib/msccl-algorithms/ and execute the following command line on an Azure NDv4 node or any 8xA100 system:

5. Below is the command to run test using msccl-executor-nccl

$ mpirun -np 8 -x LD_LIBRARY_PATH=msccl/executor/msccl-executor-nccl/build/lib/:$LD_LIBRARY_PATH -x NCCL_DEBUG=INFO -x NCCL_DEBUG_SUBSYS=INIT,ENV tests/msccl-tests-nccl/build/all_reduce_perf -b 128 -e 32MB -f 2 -g 1 -c 1 -n 100 -w 100 -G 100 -z 0

6. If everything is installed correctly, you should see the following output in log:

[0] NCCL INFO Connected 1 MSCCL algorithms

You may evaluate the performance of test.xml by comparing in-place (the new algorithm) vs out-of-place (default ring algorithm) and it should up-to 2-3x faster on 8xA100 NVLink-interconnected GPUs. MSCCL toolkit has a rich set of algorithms for different Azure SKUs and collective operations with significant speedups over vanilla NCCL.

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit CLA.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

Trademarks

This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft's Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party's policies.

About

Microsoft Collective Communication Library

Resources

Code of conduct

Security policy

Stars

67 stars

Watchers

5 watching

Forks

Releases

Packages

Used by

Contributors