Skip to content

Conversation

@JoongunPark
Copy link
Contributor

Summary

This PR addresses multiple issues in the Chakra converter:

1. Improper Handling of NCCL All-to-All Communication

Chakra incorrectly distinguishes between point-to-point and collective communication. In NCCL, all-to-all is implemented as point-to-point communication, but Chakra's current logic treats these as distinct, leading to an incorrect type for PyTorchNode. More details on NCCL point-to-point can be found here.

2. Logging Inconsistency

There was a mismatch in logging levels: sync dependencies log via logging.info, while other dependencies use logging.debug. This PR resolves the inconsistency by standardizing the logging approach.

3. False Positive Dependencies from HTA

HTA returns false positives for sync dependencies, leading to invalid later op -> earlier op dependencies. This causes Chakra to fail in certain traces. The Chakra converter was found to encounter two critical failures:

  • Cycle dependencies
  • Stack overflows (due to call stacks exceeding 1000 levels)

4. Update trace_linker to use external_id for finding GPU op's parent CPU op

There were many operations matched with wrong parent CPU during trace linking.
This PR solves this problem using external_id instead of ev_idx.

5. Handling HTA Errors in Chakra

The trace linker was terminating unexpectedly due to errors in HTA. Although this may stem from trace inconsistencies, the issue does not occur when HTA is excluded.
Updated Chakra to handle these errors by raising exceptions instead of terminating the trace linker.

6. Proper Encoding of pg_name in Collective Operations

Identified an issue where SendRecv, Reduce-Scatter and All-Gather operations do not correctly encode pg_name following updates on the PyTorch side.
Modified Chakra to ensure proper encoding of pg_name in these collective operations.

Test Plan

I tested the fixes using Mixtral 8x3B traces collected with the NeMo framework (NVIDIA).
traces_device_0.zip

#!/bin/bash
# Set the result path
PATH="~/scratch/results/mixtral_8x3b/results"

# Loop through trace ranks
for i in 0
do
    echo "Start linking trace: $i"
    chakra_trace_link \
        --chakra-host-trace $PATH/host_$i.json \
        --chakra-device-trace $PATH/device_$i.json  \
        --rank $i \
        --output-file $PATH/rank_$i.json

    echo "Start converting trace: $i"
    chakra_converter PyTorch \
        --input $PATH/rank_$i.json \
        --output $PATH/rank_$i.et
done

@JoongunPark JoongunPark requested a review from a team as a code owner February 21, 2025 22:08
@github-actions
Copy link

github-actions bot commented Feb 21, 2025

MLCommons CLA bot All contributors have signed the MLCommons CLA ✍️ ✅

@spandoescode
Copy link

#160 was closed accidentally, this PR was made instead. Looks good to me!

# In NCCL, all-to-all communication is implemented using point-to-point
# communications. More details can be found here:
# https://docs.nvidia.com/deeplearning/nccl/user-guide/docs/usage/p2p.html
if "nccl:all_to_all" in keyword:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This string name nccl::all_to_all is hardcoded below:

https://github.com/pytorch/pytorch/blob/7c71ab1d40992ea2660bb124152e95b7a9a5119d/torch/csrc/distributed/c10d/ProcessGroupNCCL.cpp#L4974

There is a possibility that once this changes in PT, this breaks.

# In NCCL, all-to-all communication is implemented using point-to-point
# communications. More details can be found here:
# https://docs.nvidia.com/deeplearning/nccl/user-guide/docs/usage/p2p.html
if "nccl:all_to_all" in keyword:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

@tushar-krishna tushar-krishna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This first issue (All-to-All) seems to be because of coalescing of multiple send-recvs (for All to All) into a ncclDevKernel_SendRecv ..
The confusion was that the name "SendRecv" implied a single src-dst pair. However, we confirm that one "SendRecv" nccl kernel can be the result of fusing multiple send and receive messages.

Copy link
Contributor

@tushar-krishna tushar-krishna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to merge!

@tushar-krishna tushar-krishna merged commit f534a1e into mlcommons:main Feb 26, 2025
9 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Feb 26, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants