Modern machine learning frameworks often use the
[NVIDIA Collective Communications Library (NCCL)](https://developer.nvidia.com/nccl)
for GPU-to-GPU communication primitives.

Google's enhanced version of NCCL is called NCCL/gIB and is available on
Google Cloud's A5X, A4X Max, A4X, A4, and A3 Ultra instances. NCCL/gIB is often
[more performant](https://docs.cloud.google.com/ai-hypercomputer/docs/nccl/overview.md.txt#benefits) than upstream NCCL on Google infrastructure.
Because NCCL performance can affect overall workload performance, we recommend
that you use NCCL/gIB.

## NCCL/gIB architecture

The NCCL/gIB software stack consists of two separate components that work
together:

- **NCCL Core (`libnccl.so` from NVIDIA)** : provides the standard GPU-to-GPU communication operations, such as `AllReduce`, `AllGather`, and `Broadcast`, that machine learning frameworks call.
- **Google's NCCL/gIB plugins**: extend NCCL Core dynamically with
  Google Cloud network optimizations and telemetry:

  - **gIB network plugin (`libnccl-net.so`)**: balances traffic across
    multiple network paths by using GPUDirect RDMA over RoCE v2 to deliver
    high throughput and low latency during collective operations.

  - **Custom tuner plugin (`libnccl-tuner.so`)**: selects recommended
    collective algorithms, protocols, and channel settings for Google Cloud
    VM topologies.

  - [**CoMMA profiler plugin**](https://docs.cloud.google.com/ai-hypercomputer/docs/nccl/comma.md.txt)
    (`libnccl-profiler.so` and `libGPUViz.so`): collects performance metrics
    and diagnostic data to detect stalled processes and slow nodes.

  - **Environment plugin (`libnccl-env-gcp.so`)**: applies platform-specific
    NCCL environment variables across Google Cloud VMs when you use NCCL
    2.28.7 or later.

The following diagram shows how your machine learning framework interacts with
NVIDIA GPUs, NCCL Core, and Google's NCCL/gIB plugins:

![The ML workload is managed by a ML framework that connects to both the NVIDIA GPUs and NCCL, while NCCL connects to various Google tools and plugins.](https://docs.cloud.google.com/static/ai-hypercomputer/images/nccl-gib-architecture-v2.png)

Because Google's plugins load dynamically, you can upgrade NCCL Core
independently to use a later CUDA version or meet framework requirements, as
long as your NCCL Core version is in the supported range. For supported
versions, see the version compatibility tables in the
[x86 release notes](https://docs.cloud.google.com/ai-hypercomputer/docs/nccl/release-notes-x86.md.txt#version-compatibility)
and
[ARM64 release notes](https://docs.cloud.google.com/ai-hypercomputer/docs/nccl/release-notes-arm64.md.txt#version-compatibility).

> [!NOTE]
> **Note:** If a feature requires network plugin support, such as GPU-Initiated Networking (GIN), then that feature still depends on your installed gIB network plugin version. To use a custom NCCL Core version or upgrade an existing installation, see [Install NCCL plugins](https://docs.cloud.google.com/ai-hypercomputer/docs/nccl/install-nccl.md.txt#plugins-only).

## Benefits of using NCCL/gIB

Although it's possible to use the upstream NVIDIA Collective Communications Library on Google Cloud VMs without stability problems, NCCL/gIB is better optimized for Google Cloud and the performance disparity can be very significant for certain communication patterns, even with the same NCCL parameters.

For example, the following graph shows a comparison of NCCL/gIB with upstream NCCL on AllReduce performance. NCCL/gIB outperforms upstream NCCL by as much as 12x on certain message sizes.

![A graph showing NCCL/gIB outperforms upstream NCCL at AllReduce tasks.](https://docs.cloud.google.com/static/ai-hypercomputer/images/nccl-gib-all-reduce.png)

32-node NCCL AllReduce performance using A3 Ultra (H200) with no background traffic.

Similarly in a comparison of NCCL/gIB with upstream NCCL on AllGather performance with background traffic, NCCL/gIB outperforms upstream NCCL by approximately 50% on larger message sizes, as shown in this graph.

![A graph showing NCCL/gIB outperforms upstream NCCL at AllGather tasks.](https://docs.cloud.google.com/static/ai-hypercomputer/images/nccl-gib-all-gather.png)

32-node NCCL AllGather performance using A3 Ultra (H200) on a shared fabric with a noisy background.

In addition, the [**CoMMA profiler plugin**](https://docs.cloud.google.com/ai-hypercomputer/docs/nccl/comma.md.txt) provides Google with improved custom telemetry, enabling us to better assist you should a workload-level issue arise.

## Install NCCL/gIB

Before you run NCCL tests, you must
[install NCCL/gIB](https://docs.cloud.google.com/ai-hypercomputer/docs/nccl/install-nccl.md.txt) in your runtime
environment.

## Use NCCL/gIB

To run NCCL/gIB tests on your cluster, choose the page from the following list
that best meets your requirements:

- [Use gIB NCCL plugins in NVIDIA NGC containers](https://docs.cloud.google.com/ai-hypercomputer/docs/nccl/ngc-containers.md.txt)
- [Run NCCL tests on Compute Engine instances](https://docs.cloud.google.com/ai-hypercomputer/docs/nccl/test-vms.md.txt)
- [Run NCCL on GKE clusters that use Cluster Toolkit](https://docs.cloud.google.com/ai-hypercomputer/docs/nccl/test-gke.md.txt)
- [Run NCCL on GKE clusters that use A4X Max](https://docs.cloud.google.com/ai-hypercomputer/docs/nccl/test-gke-custom-a4x-max.md.txt)
- [Run NCCL on GKE clusters that use A4X](https://docs.cloud.google.com/ai-hypercomputer/docs/nccl/test-gke-custom-a4x.md.txt)
- [Run NCCL on GKE clusters that use A4 or A3 Ultra](https://docs.cloud.google.com/ai-hypercomputer/docs/nccl/test-gke-custom.md.txt)
- [Run NCCL tests on Slurm clusters](https://docs.cloud.google.com/ai-hypercomputer/docs/nccl/test-slurm.md.txt)
- [Run NCCL tests in Cluster Director](https://docs.cloud.google.com/cluster-director/docs/monitor/cluster-health.md.txt#verify-health)

For directions on how to run NCCL/gIB on GKE clusters that use A5X, contact
your Google Cloud representative.

To learn how to address any issues with your cluster after you've run your
tests, see
[Collect and understand NCCL/gIB logs for troubleshooting](https://docs.cloud.google.com/ai-hypercomputer/docs/nccl/collect-and-understand.md.txt).