Tools to parse and visualize NCCL logs generated with debug mode enabled.
pip install pandas numpy matplotlib seaborn# Option 1: Full logs (recommended)
NCCL_DEBUG=INFO NCCL_DEBUG_SUBSYS=INIT,COLL,P2P <your_command> 2>&1 | tee nccl_debug.log
# Option 2: Only collective operations
NCCL_DEBUG=INFO NCCL_DEBUG_SUBSYS=COLL <your_command> 2>&1 | tee nccl_debug.log
# Example with distributed PyTorch:
NCCL_DEBUG=INFO NCCL_DEBUG_SUBSYS=COLL python -m torch.distributed.launch \
--nproc_per_node=8 train.py 2>&1 | tee nccl_debug.logpython nccl_parser.py nccl_debug.log --output results/analysisThis will generate multiple CSV files with detailed analysis:
analysis_collective_ops_summary.csv- Summary by operation typeanalysis_collective_rank_summary.csv- Summary by rankanalysis_collective_rank_op_matrix.csv- Rank × operation matrixanalysis_p2p_comm_count_matrix.csv- P2P communications matrix (count)analysis_p2p_comm_data_matrix.csv- P2P communications matrix (data MB)analysis_p2p_rank_summary.csv- Send/Recv summary by rankanalysis_all_collective_ops.csv- All parsed collective operationsanalysis_all_p2p_ops.csv- All parsed P2P operations
python nccl_visualizer.py results/analysis --output-dir results/plotsThis will generate PNG format graphics:
operation_summary.png- Operations summary by typerank_summary.png- Communications by rankrank_operation_heatmap.png- Operations heatmapp2p_communication_matrix.png- P2P communication matricesp2p_send_recv_summary.png- Send/Recv summaryoperation_timeline.png- Operations timeline (if there are timestamps)data_size_distribution.png- Data size distribution
- AllReduce: Reduction and broadcast of data among all GPUs
- AllGather: Gathering data from all GPUs
- Broadcast: Distributing data from one GPU to all others
- ReduceScatter: Reduction and segmented distribution
- Reduce: Reduction towards a specific GPU
- AllToAll: Complete exchange among all GPUs
- Send/Recv: Direct communications between GPU pairs
- By operation type:
- Count of each operation type
- Total data transferred by type
- Average, minimum, and maximum size
- By rank (GPU):
- Total operations performed
- Total data sent/received
- Distribution by operation type
- P2P communications:
- Communication matrix: who sends to whom
- Volume and count of data
- Most active communication pairs
- Communication patterns:
- Load balancing among GPUs
- Identify bottlenecks
- Asymmetries in communications
# The rank_summary.csv file will show:
# - Which GPU performs the most operations
# - Which GPU transfers the most data# The p2p_comm_*_matrix.csv files will show:
# - Matrix of who communicates with whom
# - Data volume between each GPU pair# The collective_ops_summary.csv file will show:
# - Which operation is used the most (e.g. AllReduce in DDP)
# - How much bandwidth each type consumesGenerate logs for only one representative epoch or iteration to avoid huge files:
# In your PyTorch code
if epoch == 5: # Only log one specific epoch
os.environ['NCCL_DEBUG'] = 'INFO'
os.environ['NCCL_DEBUG_SUBSYS'] = 'COLL'
else:
os.environ['NCCL_DEBUG'] = 'WARN'Use additional subsystems:
NCCL_DEBUG=INFO NCCL_DEBUG_SUBSYS=INIT,COLL,P2P,NET <command>Combine with timestamps to view temporal trends:
NCCL_DEBUG=INFO NCCL_DEBUG_SUBSYS=COLL NCCL_DEBUG_TIMESTAMP_FORMAT="[%F_%T.%3f]" <command>- Verify that
NCCL_DEBUG=INFOis on - Make sure to include
NCCL_DEBUG_SUBSYS=COLLorCOLL,P2P - Confirm the log contains lines with "NCCL INFO"
- Capture only a few iterations
- Filter the log to include only NCCL lines:
grep "NCCL INFO" nccl_full.log > nccl_filtered.log- Check that the CSV files were generated
- Make sure matplotlib and seaborn are installed
- Some plots require specific data (e.g. timeline needs timestamps)
Identify if there is imbalance in AllReduce of gradients.
Review Send/Recv operations between pipeline stages.
Analyze volume of AllGather and ReduceScatter.
Check communication patterns among GPUs with different model sections.
Author: Pablo Saura Sánchez Date: October 2025