Skip to content

Conversation

@Xinyu-Kang
Copy link

Description

rcclx and torchcomms were not building on ROCm (MI325X). This PR makes the ROCm build work while keeping the CUDA path unchanged.

Changes

  • Fix BF16 handling on ROCm in DDA kernels
    • Add HIP includes and BF16/FP16 aliases for ROCm in CollCommon.cuh and the DDA kernels (all_reduce / all_gather / all_to_all / reduce_scatter).
    • Provide CUDA-compatible aliases (bf16, bf162, and __nv_bfloat16* shims on HIP) so the same kernels compile under both CUDA and HIP without hipify collisions.
  • Make build_rcclx.sh robust on ROCm
    • Export LD_LIBRARY_PATH / LIBRARY_PATH from the active conda env.
    • Add helpers to symlink .so.a when only shared libs exist in the env (e.g. libssl, libcrypto, libevent, libsodium, libboost_context).
    • Use a configurable THIRD_PARTY_ROOT (default ${BASE_DIR}/.third-party-cache) instead of /tmp/third-party to avoid permission errors, and add .forge_built stamp files plus FORCE_THIRD_PARTY_REBUILD to control reuse.
  • Clean up RCCLX CMake file lists
    • After rebasing on the latest main, upstream already added the plugin headers/sources I originally wired in. This PR now only removes duplicated entries and small inconsistencies.
  • Let torchcomms build on ROCm by gating CUDA-only transport
    • In comms/torchcomms/transport/CMakeLists.txt, treat CUDA as optional and fail early with a clear message if transport is enabled but CUDA is not found.
    • In setup.py, detect ROCm via torch.version.hip and default USE_TRANSPORT to False on ROCm (still opt-in via USE_TRANSPORT=1 if someone really wants to try). CUDA builds keep the existing default.

@meta-cla
Copy link

meta-cla bot commented Dec 4, 2025

Hi @Xinyu-Kang!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

function ensure_static_symlink() {
local base="$1"
local so="${CONDA_PREFIX}/lib/lib${base}.so"
local ar="${CONDA_PREFIX}/lib/lib${base}.a"
Copy link

Choose a reason for hiding this comment

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

This seems a bit hacky as we're altering the conda environment. Why do we need static libraries in the first place? Can't we link to the shared libraries?

Copy link
Author

@Xinyu-Kang Xinyu-Kang Dec 4, 2025

Choose a reason for hiding this comment

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

Yea.. Currently rcclx CMake hard-codes the static archives (.a files), but the ROCm conda env I’m testing on only has the .so variants. It makes sense to just build against shared libraries, but I'm not sure if it will touch something else on other machines.

If you’d prefer, I can instead patch the rcclx CMake to:

  • use the existing static libraries when they’re available, and
  • fall back to the shared libraries when only .so is present,

and then drop ensure_static_symlink entirely so we don’t touch the conda environment.

Does that sound reasonable?

#include <cuda.h>
#include <cuda_bf16.h>
#include <cuda_fp16.h>
using bf16 = __nv_bfloat16;
Copy link

Choose a reason for hiding this comment

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

Why do we redefine these here if we already have them in comms/common/algorithms/CollCommon.cuh which gets included below?

@mreso mreso requested a review from sudharssun December 4, 2025 02:11
@meta-cla
Copy link

meta-cla bot commented Dec 4, 2025

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Meta Open Source bot. label Dec 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot. module: rocm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants