元鉴
返回中文阅读流

NVIDIA Developer Blog

使用 NCCL Inspector 和 Prometheus 进行实时性能监控与更快调试

分布式深度学习依赖 NVIDIA NCCL 实现快速可靠的 GPU 间通信;训练变慢时,定位原因和后续处理会很困难。

中文内容

已翻译official company source英文原文2026-05-26

分布式深度学习依赖 NVIDIA Collective Communication Library(NCCL)实现快速、可靠的 GPU 到 GPU 通信。当训练速度变慢时,判断原因以及下一步该怎么做会变得具有挑战性。问题可能涉及计算、通信、某个特定 rank,或底层硬件。

NVIDIA NCCL Inspector 通过提供轻量级、持续性的 NCCL 通信性能报告,加快问题分诊。它会跟踪每个 rank 的操作类型、大小和带宽;借助这项最新增强功能,可在开销极低的情况下促进实时分析。

它还有助于确定最优训练方案。此前一篇文章介绍了 NCCL Inspector 离线模式。虽然细粒度分析仍是深入研究数据的标准方式,但本文介绍的是一项新功能:实时监控。通过将 NCCL Inspector 与 Prometheus Exporter 集成,现在可以直接在用户基础设施仪表盘中提供实时的时间序列可视化。

NCCL Inspector 部署架构

NCCL 2.30 引入了 Prometheus Mode,这是面向 AI 工作负载中 NCCL 实时性能监控的一项重大增强。NCCL Inspector 有两种工作模式,如图 1 和图 2 所示。

Architecture diagram showing two GB200 Nodes, each containing four NCCL Inspector instances (GPU 0–GPU 4), writing output files to shared Lustre/AWS S3/NFS storage in JSON Mode. Each GPU's inspector produces NCCL Inspector Output Files storArchitecture diagram showing two GB200 Nodes, each containing four NCCL Inspector instances (GPU 0–GPU 4), writing output files to shared Lustre/AWS S3/NFS storage in JSON Mode. Each GPU's inspector produces NCCL Inspector Output Files stor
图 1. JSON 模式下的 NCCL Inspector(默认/离线模式)

JSON 模式包含数据收集和数据分析两个阶段。首先,数据收集阶段从每个 rank 生成性能指标,并将其分别存储在 JSON 文件中,通常位于共享存储上。随后,数据分析阶段处理这些数据。由于处理并非实时完成,因此该方法被视为离线模式。

Architecture diagram showing two GB200 Nodes, each containing four NCCL Inspector instances (GPU 0–GPU 4), writing output files to shared Lustre/AWS S3/NFS storage in JSON Mode. Each GPU's inspector produces NCCL Inspector Output Files storArchitecture diagram showing two GB200 Nodes, each containing four NCCL Inspector instances (GPU 0–GPU 4), writing output files to shared Lustre/AWS S3/NFS storage in JSON Mode. Each GPU's inspector produces NCCL Inspector Output Files stor
图 2. 实时 Prometheus 模式下的 NCCL Inspector

这项新功能将 NCCL Inspector 指标与 Prometheus 集成,把它们转换为适合在 Grafana 仪表盘中可视化的时间序列数据。Prometheus 模式消除了此前 JSON 模式所需的大量存储需求。这些指标数据由 node exporter 传输到 Prometheus——一个可扩展的云原生平台。NCCL 作业输出文件被设计为持续覆盖写入。一旦 node exporter 收集了指标,它们就不再需要保留在磁盘上。

Prometheus Mode 的实验设置

设置 NCCL Inspector Profiler 插件需要构建该插件,并设置以下必需的环境变量:

NCCL_PROFILER_PLUGIN=/path/to/nccl/plugins/profiler/inspector/libnccl-profiler-inspector.so
NCCL_INSPECTOR_ENABLE=1
NCCL_INSPECTOR_DUMP_THREAD_INTERVAL_MICROSECONDS=3000000
NCCL_INSPECTOR_PROM_DUMP=1
NCCL_INSPECTOR_DUMP_DIR=/path/to/node/exporter/log/location

dump 线程间隔和 dump 目录应根据所使用的 node exporter 进行设置和调优。配置完成后,NCCL Inspector 会启动该进程,并将集合通信性能转储到 NCCL_INSPECTOR_DUMP_DIR。随后,Prometheus Node Exporter 将指标发送到 Prometheus 时间序列数据库。最后,这些时间序列指标会以 Graphana 仪表盘图表的形式呈现。

运行作业时,指标会保存为如下格式的文件:nccl_inspector_metrics_<uuid_of_the_gpu>.prom。文件名中包含 GPU 的 UUID,因为在多用户环境中 CUDA 设备 ID 可能会重叠。

NCCL 作业输出文件采用 Prometheus exposition format。每个指标都带有上下文标签,包括 NCCL 版本、Slurm 作业 ID、节点、GPU、communicator 名称、节点数、rank 数量和消息大小。以下是一个示例:

nccl_p2p_bus_bandwidth_gbs{version="v5.1",slurm_job_id="1670760",node="nvl72033-T01",gpu="GPU0",comm_name="unknown",n_nodes="1",nranks="64",p2p_operation="Send",message_size="1-2MB"} 19.1634
nccl_p2p_exec_time_microseconds{version="v5.1",slurm_job_id="1670760",node="nvl72033-T01",gpu="GPU0",comm_name="unknown",n_nodes="1",nranks="64",p2p_operation="Send",message_size="1-2MB"} 92.8984
nccl_p2p_bus_bandwidth_gbs{version="v5.1",slurm_job_id="1670760",node="nvl72033-T01",gpu="GPU0",comm_name="unknown",n_nodes="1",nranks="64",p2p_operation="Recv",message_size="1-2MB"} 19.2396
nccl_p2p_exec_time_microseconds{version="v5.1",slurm_job_id="1670760",node="nvl72033-T01",gpu="GPU0",comm_name="unknown",n_nodes="1",nranks="64",p2p_operation="Recv",message_size="1-2MB"} 92.5781
nccl_bus_bandwidth_gbs{version="v5.1",slurm_job_id="1670760",node="nvl72033-T01",gpu="GPU0",comm_name="unknown",n_nodes="4",nranks="32",collective="ReduceScatter",message_size="134-135MB",algo_proto="RING_SIMPLE"} 44.1181
nccl_collective_exec_time_microseconds{version="v5.1",slurm_job_id="1670760",node="nvl72033-T01",gpu="GPU0",comm_name="unknown",n_nodes="4",nranks="32",collective="ReduceScatter",message_size="134-135MB",algo_proto="RING_SIMPLE"} 104164

这些指标进入 Prometheus DB 后,下一步就是在 Grafana 中进行渲染。

基于时间序列的 Grafana 仪表盘

图 3 展示了使用 Prometheus 标签生成的时间序列仪表盘示例,这些标签被分类为 NVLink 集合通信仪表盘和混合类型(即 Network + NVLink 集合通信)仪表盘:

Line chart showing NCCL AllGather bus bandwidth in GB/s over NVLink-only communicators (single node), measured from 15:00 to 15:06. Multiple time series are plotted, each representing a different message size with 8 ranks. Larger message siLine chart showing NCCL AllGather bus bandwidth in GB/s over NVLink-only communicators (single node), measured from 15:00 to 15:06. Multiple time series are plotted, each representing a different message size with 8 ranks. Larger message si
图 3. Grafana 时间序列仪表盘,显示单节点(n_nodes==1)上仅使用 NVIDIA NVLink 的 communicator 的 NCCL AllGather 总线带宽(GB/s),观察窗口为 6 分钟
Line chart showing NCCL AllGather bus bandwidth in GB/s for combined Network (IB/RoCE/EFA) and NVLink communicators across multiple nodes (n_nodes != 1), measured from 15:00 to 15:06. Five time series are plotted representing different messLine chart showing NCCL AllGather bus bandwidth in GB/s for combined Network (IB/RoCE/EFA) and NVLink communicators across multiple nodes (n_nodes != 1), measured from 15:00 to 15:06. Five time series are plotted representing different mess
图 4. Grafana 时间序列仪表盘,显示多节点设置(n_nodes==4)中组合网络(IB/RoCE/EFA)和 NVLink communicator 的 NCCL AllGather 总线带宽(GB/s),观察窗口为 6 分钟

NCCL Inspector 的用例

为展示分诊工作流,以下两个用例说明了这些仪表盘如何加快根因识别。

实时可观测性

使用实时仪表盘查找长时间运行的 AI 工作负载中性能下降的根因。观察仪表盘变化,并将作业级退化与底层 NCCL 或网络层指标关联起来,可以根据异常来源进行有针对性的分诊。团队运行了一个大型 LLM 预训练作业来展示这一策略。

时间线 A:正常工作流

图 5 展示了某次实验中混合网络 + NVLink 集合通信的 AllGather 总线带宽。该 AI 预训练工作负载的计算性能约为 ~310 TFLOPs/GPU。

Line chart showing NCCL AllGather bus bandwidth in GB/s for combined Network and NVLink communicators across 4 nodes, measured from 15:00 to 15:06. A Grafana tooltip is visible at timestamp 2026-03-18 15:03:45, highlighting the 42–43MB messLine chart showing NCCL AllGather bus bandwidth in GB/s for combined Network and NVLink communicators across 4 nodes, measured from 15:00 to 15:06. A Grafana tooltip is visible at timestamp 2026-03-18 15:03:45, highlighting the 42–43MB mess
图 5. Grafana 时间序列仪表盘,显示四个节点上正常 AI 预训练工作流期间混合网络 + NVLink communicator 的 NCCL AllGather 总线带宽(GB/s),对应观察到的计算性能约为 ~310 TFLOPs/GPU

时间线 B:网络引发的减速

在引入人工网络限制后,混合网络 + NVLink 集合通信的 AllGather BusBw 显示计算性能下降至每 GPU 约 ~268 TFLOPs(相较基线约下降 13%)。

该示例表明,实时仪表盘提升了对混合传输 communicator(网络 + NVLink)集合通信性能的可观测性,从而能够更快识别根因,并缩短平均修复时间。

Line chart showing NCCL AllGather bus bandwidth in GB/s for combined Network and NVLink communicators across 4 nodes, measured from 17:56 to 18:03, during an artificially induced network slowdown. A Grafana tooltip at timestamp 2026-03-18 1Line chart showing NCCL AllGather bus bandwidth in GB/s for combined Network and NVLink communicators across 4 nodes, measured from 17:56 to 18:03, during an artificially induced network slowdown. A Grafana tooltip at timestamp 2026-03-18 1
图 6. Grafana 时间序列仪表盘,显示时间线 B(网络引发的减速场景)期间混合网络 + NVLink communicator 的 NCCL AllGather 总线带宽(GB/s)

性能归因

另一个用例是 NCCL Inspector,它有助于分析特定时间段内的性能下降。例如,在一次实验中,性能出现了如下所示的短暂下降:

[2026-03-19 14:39:47.098640] -> throughput per GPU: ~314 TFLOP/s/GPU
[2026-03-19 14:40:48.696103] -> throughput per GPU: ~295 TFLOP/s/GPU
[2026-03-19 14:42:00.816450] -> throughput per GPU: ~289 TFLOP/s/GPU
[2026-03-19 14:44:02.304347] -> throughput per GPU: ~311 TFLOP/s/GPU

接下来,对观察到的性能下降进行检查,以确定它是否与该时段内的网络异常相关。

Line chart showing NCCL ReduceScatter bus bandwidth in GB/s for NVLink-only communicators with 8 ranks, measured from approximately 14:35 to 14:51. Three message size series are plotted: 17–18MB (yellow) sustains the highest bandwidth nearLine chart showing NCCL ReduceScatter bus bandwidth in GB/s for NVLink-only communicators with 8 ranks, measured from approximately 14:35 to 14:51. Three message size series are plotted: 17–18MB (yellow) sustains the highest bandwidth near
图 7. Grafana 时间序列仪表盘,显示 2026-03-1 性能归因调查期间仅使用 NVLink 的 communicator 的 NCCL ReduceScatter 总线带宽(GB/s)
Line chart showing NCCL ReduceScatter bus bandwidth in GB/s for combined Network and NVLink communicators across 4 nodes, measured from approximately 14:35 to 14:51. Three series are plotted: 1–2GB (green, 4 ranks), 133–134MB (yellow, 32 raLine chart showing NCCL ReduceScatter bus bandwidth in GB/s for combined Network and NVLink communicators across 4 nodes, measured from approximately 14:35 to 14:51. Three series are plotted: 1–2GB (green, 4 ranks), 133–134MB (yellow, 32 ra
图 8. Grafana 时间序列仪表盘,显示 2026-03-19 同一性能归因窗口期间混合 Network + NVLink communicator 的 NCCL ReduceScatter 总线带宽(GB/s)

仪表盘显示混合传输通信(基于网络 + NVLink 的集合通信)存在性能下降。这种相关性表明根因是网络中的中断/拥塞。这使得进一步深入查看各主机和网络计数器,以定位减速发生位置成为可能。

实时可观测性的后续步骤

引入带有 Prometheus 集成的 NCCL Inspector,旨在增强面向 AI 工作负载性能分析的网络可观测性。这一强大组合使性能分析能够采用更科学的方法。用户可以利用详细指标,调试并理解运行中工作负载的实时性能特征,分诊减速问题,微调参数,并衡量由此带来的性能变化。

开始使用

请参阅 GitHub README.md 以:

  • 在 Prometheus 模式下构建并部署 NCCL Inspector 插件。
  • 配置 Prometheus exporter,为你的集群/环境暴露指标。

使用 Grafana 模板设置 grafana 仪表盘。

致谢

我们还要感谢 NVIDIA 同事 Nikhithkumar Kotagari、Giuseppe Congi、Nishank Chandawala,以及加利福尼亚大学河滨分校的 Ziyang Jia,在设计过程中提供的宝贵意见和评审。

Like

标签

原文标题

Real-Time Performance Monitoring and Faster Debugging with NCCL Inspector and Prometheus