Skip to content

[rocm][7.0/7.2] Fix [[nodiscard]] build errors and BUCK deps across comms, gloo, caffe2 (#176671) - #176671

Closed
gyllstromk wants to merge 1 commit into
pytorch:mainfrom
gyllstromk:export-D93759269
Closed

gyllstromk wants to merge 1 commit into
pytorch:mainfrom
gyllstromk:export-D93759269

Conversation

@gyllstromk

@gyllstromk gyllstromk commented Mar 6, 2026 •

Copy link
Copy Markdown
Contributor

Summary:
ROCm 7.0+ HIP headers annotate API functions (hipStreamDestroy,
hipMemcpyAsync, hipStreamSynchronize, hipSetDevice, hipGetDevice, hipFree,
hipHostUnregister, hipDeviceEnablePeerAccess, cuGetErrorString) with
[[nodiscard]]. Combined with -Werror, this causes build failures wherever
return values are discarded.

Originally discovered building with ROCm 7.2 headers, but confirmed to
also affect ROCm 7.0 builds (reported independently by yvliu and hqguo).
The [[nodiscard]] attribute is present in both ROCm 7.0 and 7.2 HIP
headers — the fix is the same for both versions.

Changes:

  • Add (void) casts to suppress [[nodiscard]] warnings across comms/
    (tcp_devmem, ctran, rcclx), gloo/, and caffe2/ (nativert) — 12 C++ files
  • Fix BUCK dependency issues in comms/tcp_devmem/nccl (replace devmgr-client
    with common:common) and comms/tcp_devmem/unpack (explicit glog dep path)
    that surface when building these targets under ROCm constraints

The (void) casts are no-ops on CUDA and older ROCm — safe to land
regardless of ROCm version.

Test Plan: buck2 build mode/amd-gpu -m rocm72 fbcode//comms/tcp_devmem/unpack:batch_unpack_producer fbcode//gloo:cuda_collectives_native — builds successfully

Differential Revision: D93759269

Pulled By: gyllstromk

cc @jeffdaily @sunway513 @jithunnair-amd @pruthvistony @ROCmSupport @jataylo @hongxiayang @naromero77amd @pragupta @jerrymannil @xinyazhang

@pytorch-bot

pytorch-bot Bot commented Mar 6, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/176671

Note: Links to docs will display an error until the docs builds have been completed.

✅ You can merge normally! (3 Unrelated Failures)

As of commit 8b6c670 with merge base c014085 (image):

FLAKY - The following job failed but was likely due to flakiness present on trunk:

BROKEN TRUNK - The following jobs failed but was present on the merge base:

👉 Rebase onto the `viable/strict` branch to avoid these failures

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@pytorch-bot pytorch-bot Bot added ciflow/rocm-mi300 Trigger "default" config CI on ROCm MI300 module: rocm AMD GPU support for Pytorch labels Mar 6, 2026
@pytorch-bot

pytorch-bot Bot commented Mar 6, 2026

Copy link
Copy Markdown

This PR needs a release notes: label

If your changes are user facing and intended to be a part of release notes, please use a label starting with release notes:.

If not, please add the topic: not user facing label.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "topic: not user facing"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

LOG(ERROR) << #fn << " returned error: " << result; \
const char* errMsg = nullptr; \
get_nvrtc().cuGetErrorString(result, &errMsg); \
(void)get_nvrtc().cuGetErrorString(result, &errMsg); \

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This isn't the right fix. This is an actual bug.

Suggested change
(void)get_nvrtc().cuGetErrorString(result, &errMsg); \
C10_CUDA_CHECK(get_nvrtc().cuGetErrorString(result, &errMsg)); \

is the right fix.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It seems C10_CUDA_CHECK doesn't work here because it expects cudaError_t (runtime API) while cuGetErrorString returns CUresult (driver API). This causes a compile error on any
CUDA-enabled build:

error: cannot initialize a variable of type 'const cudaError_t' (aka 'const cudaError')
with an rvalue of type 'CUresult' (aka 'cudaError_enum')

C10_CUDA_CHECK expands to const cudaError_t __err = EXPR (https://github.com/pytorch/pytorch/blob/main/c10/cuda/CUDAException.h#L29), but cuGetErrorString returns CUresult
(https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__ERROR.html#group__CUDA__ERROR_1g2c4ac087113652768e1f5ceb4c37be41), so the types are incompatible.

Using (void) is the right fix here — this call is inside the CU_LOG_ERROR error-logging macro (https://github.com/pytorch/pytorch/blob/main/torch/nativert/executor/triton/CudaTritonKernelManager.cpp#L17-L23), so we're already in an
error path. The cuGetErrorString call is just converting the error code to a human-readable string for the log message; there's nothing meaningful to do if that conversion itself fails.

gyllstromk added a commit to gyllstromk/gloo that referenced this pull request Mar 6, 2026
Summary:
X-link: pytorch/pytorch#176671

ROCm 7.0+ HIP headers annotate API functions (hipStreamDestroy,
hipMemcpyAsync, hipStreamSynchronize, hipSetDevice, hipGetDevice, hipFree,
hipHostUnregister, hipDeviceEnablePeerAccess, cuGetErrorString) with
[[nodiscard]]. Combined with -Werror, this causes build failures wherever
return values are discarded.

Originally discovered building with ROCm 7.2 headers, but confirmed to
also affect ROCm 7.0 builds (reported independently by yvliu and hqguo).
The [[nodiscard]] attribute is present in both ROCm 7.0 and 7.2 HIP
headers — the fix is the same for both versions.

Changes:
- Add (void) casts to suppress [[nodiscard]] warnings across comms/
  (tcp_devmem, ctran, rcclx), gloo/, and caffe2/ (nativert) — 12 C++ files
- Fix BUCK dependency issues in comms/tcp_devmem/nccl (replace devmgr-client
  with common:common) and comms/tcp_devmem/unpack (explicit glog dep path)
  that surface when building these targets under ROCm constraints

The (void) casts are no-ops on CUDA and older ROCm — safe to land
regardless of ROCm version.

Reviewed By: bbeckca

Differential Revision: D93759269
pytorch-bot Bot pushed a commit that referenced this pull request Mar 6, 2026
…omms, gloo, caffe2 (#176671)

Summary:

ROCm 7.0+ HIP headers annotate API functions (hipStreamDestroy,
hipMemcpyAsync, hipStreamSynchronize, hipSetDevice, hipGetDevice, hipFree,
hipHostUnregister, hipDeviceEnablePeerAccess, cuGetErrorString) with
[[nodiscard]]. Combined with -Werror, this causes build failures wherever
return values are discarded.

Originally discovered building with ROCm 7.2 headers, but confirmed to
also affect ROCm 7.0 builds (reported independently by yvliu and hqguo).
The [[nodiscard]] attribute is present in both ROCm 7.0 and 7.2 HIP
headers — the fix is the same for both versions.

Changes:
- Add (void) casts to suppress [[nodiscard]] warnings across comms/
  (tcp_devmem, ctran, rcclx), gloo/, and caffe2/ (nativert) — 12 C++ files
- Fix BUCK dependency issues in comms/tcp_devmem/nccl (replace devmgr-client
  with common:common) and comms/tcp_devmem/unpack (explicit glog dep path)
  that surface when building these targets under ROCm constraints

The (void) casts are no-ops on CUDA and older ROCm — safe to land
regardless of ROCm version.

Test Plan:
Note: full stack used for testing: D95592619. Putting test plan here for clear reproducibility of problem.

```# Build and run the raw SparseSemiStructuredTensor benchmark (NN mode)
buck2 run mode/opt-amd-gpu -m "fbcode//caffe2:hipsparselt[enabled]" \
  fbcode//scripts/gylls/torchao:benchmark_semi_structured_sparsity -- \
  --mode nvidia-bert --dtype fp16 --backend cusparselt

# TN mode (requires D95099241)
CUSPARSELT_FORCE_TN=1 buck2 run mode/opt-amd-gpu -m "fbcode//caffe2:hipsparselt[enabled]" \
  fbcode//scripts/gylls/torchao:benchmark_semi_structured_sparsity -- \
  --mode nvidia-bert --dtype fp16 --backend cusparselt

# TorchAO unit tests (11 tests)
buck2 run mode/opt-amd-gpu -m "fbcode//caffe2:hipsparselt[enabled]" \
  fbcode//pytorch/ao/test:torchao_test_sparsity -- \
  pytorch.ao.test.sparsity.test_sparse_2x4_cusparselt.TestSparse2x4CuSparseLt

# TorchAO benchmark (CuSpLt vs SST vs Dense)
buck2 run mode/opt-amd-gpu -m "fbcode//caffe2:hipsparselt[enabled]" \
  fbcode//pytorch/ao/test:torchao_test_sparsity -- \
  pytorch.ao.test.sparsity.test_benchmark_sparse_2x4_cusparselt.TestBenchmarkSparse2x4CuSparseLt
``

Reviewed By: bbeckca

Differential Revision: D93759269
gyllstromk added a commit to gyllstromk/pytorch that referenced this pull request Mar 6, 2026
…omms, gloo, caffe2 (pytorch#176671)

Summary:
Pull Request resolved: pytorch#176671

ROCm 7.0+ HIP headers annotate API functions (hipStreamDestroy,
hipMemcpyAsync, hipStreamSynchronize, hipSetDevice, hipGetDevice, hipFree,
hipHostUnregister, hipDeviceEnablePeerAccess, cuGetErrorString) with
[[nodiscard]]. Combined with -Werror, this causes build failures wherever
return values are discarded.

Originally discovered building with ROCm 7.2 headers, but confirmed to
also affect ROCm 7.0 builds (reported independently by yvliu and hqguo).
The [[nodiscard]] attribute is present in both ROCm 7.0 and 7.2 HIP
headers — the fix is the same for both versions.

Changes:
- Add (void) casts to suppress [[nodiscard]] warnings across comms/
  (tcp_devmem, ctran, rcclx), gloo/, and caffe2/ (nativert) — 12 C++ files
- Fix BUCK dependency issues in comms/tcp_devmem/nccl (replace devmgr-client
  with common:common) and comms/tcp_devmem/unpack (explicit glog dep path)
  that surface when building these targets under ROCm constraints

The (void) casts are no-ops on CUDA and older ROCm — safe to land
regardless of ROCm version.

Test Plan:
Note: full stack used for testing: D95592619. Putting test plan here for clear reproducibility of problem.

```# Build and run the raw SparseSemiStructuredTensor benchmark (NN mode)
buck2 run mode/opt-amd-gpu -m "fbcode//caffe2:hipsparselt[enabled]" \
  fbcode//scripts/gylls/torchao:benchmark_semi_structured_sparsity -- \
  --mode nvidia-bert --dtype fp16 --backend cusparselt

# TN mode (requires D95099241)
CUSPARSELT_FORCE_TN=1 buck2 run mode/opt-amd-gpu -m "fbcode//caffe2:hipsparselt[enabled]" \
  fbcode//scripts/gylls/torchao:benchmark_semi_structured_sparsity -- \
  --mode nvidia-bert --dtype fp16 --backend cusparselt

# TorchAO unit tests (11 tests)
buck2 run mode/opt-amd-gpu -m "fbcode//caffe2:hipsparselt[enabled]" \
  fbcode//pytorch/ao/test:torchao_test_sparsity -- \
  pytorch.ao.test.sparsity.test_sparse_2x4_cusparselt.TestSparse2x4CuSparseLt

# TorchAO benchmark (CuSpLt vs SST vs Dense)
buck2 run mode/opt-amd-gpu -m "fbcode//caffe2:hipsparselt[enabled]" \
  fbcode//pytorch/ao/test:torchao_test_sparsity -- \
  pytorch.ao.test.sparsity.test_benchmark_sparse_2x4_cusparselt.TestBenchmarkSparse2x4CuSparseLt
``

Reviewed By: bbeckca

Differential Revision: D93759269
@meta-codesync

meta-codesync Bot commented Mar 6, 2026

Copy link
Copy Markdown

@gyllstromk has exported this pull request. If you are a Meta employee, you can view the originating Diff in D93759269.

gyllstromk added a commit to gyllstromk/gloo that referenced this pull request Mar 6, 2026
Summary:
X-link: meta-pytorch/torchcomms#960

X-link: pytorch/pytorch#176671

ROCm 7.0+ HIP headers annotate API functions (hipStreamDestroy,
hipMemcpyAsync, hipStreamSynchronize, hipSetDevice, hipGetDevice, hipFree,
hipHostUnregister, hipDeviceEnablePeerAccess, cuGetErrorString) with
[[nodiscard]]. Combined with -Werror, this causes build failures wherever
return values are discarded.

Originally discovered building with ROCm 7.2 headers, but confirmed to
also affect ROCm 7.0 builds (reported independently by yvliu and hqguo).
The [[nodiscard]] attribute is present in both ROCm 7.0 and 7.2 HIP
headers — the fix is the same for both versions.

Changes:
- Add (void) casts to suppress [[nodiscard]] warnings across comms/
  (tcp_devmem, ctran, rcclx), gloo/, and caffe2/ (nativert) — 12 C++ files
- Fix BUCK dependency issues in comms/tcp_devmem/nccl (replace devmgr-client
  with common:common) and comms/tcp_devmem/unpack (explicit glog dep path)
  that surface when building these targets under ROCm constraints

The (void) casts are no-ops on CUDA and older ROCm — safe to land
regardless of ROCm version.

Reviewed By: bbeckca

Differential Revision: D93759269

@Skylion007 Skylion007 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Not sure clang-format is going to like the out of bound \ at the end of the macro, but otherwise looks good.

@pytorch-bot pytorch-bot Bot added the ciflow/trunk Trigger trunk jobs on your pull request label Mar 7, 2026
gyllstromk added a commit to gyllstromk/gloo that referenced this pull request Mar 9, 2026
Summary:
X-link: meta-pytorch/torchcomms#960

X-link: pytorch/pytorch#176671

ROCm 7.0+ HIP headers annotate API functions (hipStreamDestroy,
hipMemcpyAsync, hipStreamSynchronize, hipSetDevice, hipGetDevice, hipFree,
hipHostUnregister, hipDeviceEnablePeerAccess, cuGetErrorString) with
[[nodiscard]]. Combined with -Werror, this causes build failures wherever
return values are discarded.

Originally discovered building with ROCm 7.2 headers, but confirmed to
also affect ROCm 7.0 builds (reported independently by yvliu and hqguo).
The [[nodiscard]] attribute is present in both ROCm 7.0 and 7.2 HIP
headers — the fix is the same for both versions.

Changes:
- Add (void) casts to suppress [[nodiscard]] warnings across comms/
  (tcp_devmem, ctran, rcclx), gloo/, and caffe2/ (nativert) — 12 C++ files
- Fix BUCK dependency issues in comms/tcp_devmem/nccl (replace devmgr-client
  with common:common) and comms/tcp_devmem/unpack (explicit glog dep path)
  that surface when building these targets under ROCm constraints

The (void) casts are no-ops on CUDA and older ROCm — safe to land
regardless of ROCm version.

Reviewed By: bbeckca

Differential Revision: D93759269
pytorch-bot Bot pushed a commit that referenced this pull request Mar 9, 2026
…omms, gloo, caffe2 (#176671)

Summary:
X-link: pytorch/gloo#494

X-link: meta-pytorch/torchcomms#960


ROCm 7.0+ HIP headers annotate API functions (hipStreamDestroy,
hipMemcpyAsync, hipStreamSynchronize, hipSetDevice, hipGetDevice, hipFree,
hipHostUnregister, hipDeviceEnablePeerAccess, cuGetErrorString) with
[[nodiscard]]. Combined with -Werror, this causes build failures wherever
return values are discarded.

Originally discovered building with ROCm 7.2 headers, but confirmed to
also affect ROCm 7.0 builds (reported independently by yvliu and hqguo).
The [[nodiscard]] attribute is present in both ROCm 7.0 and 7.2 HIP
headers — the fix is the same for both versions.

Changes:
- Add (void) casts to suppress [[nodiscard]] warnings across comms/
  (tcp_devmem, ctran, rcclx), gloo/, and caffe2/ (nativert) — 12 C++ files
- Fix BUCK dependency issues in comms/tcp_devmem/nccl (replace devmgr-client
  with common:common) and comms/tcp_devmem/unpack (explicit glog dep path)
  that surface when building these targets under ROCm constraints

The (void) casts are no-ops on CUDA and older ROCm — safe to land
regardless of ROCm version.

Test Plan:
## Reproducing the [[nodiscard]] build errors (ROCm 7.0+)

ROCm 7.0 HIP headers annotate CUDA-mapped API functions with
`[[nodiscard]]` (e.g. `hipStreamDestroy`, `hipSetDevice`, `hipFree`).
With `-Werror` enabled, any call site that discards the return value
fails to compile:

```
error: ignoring return value of function declared with 'nodiscard'
attribute [-Werror,-Wunused-result]
    cudaSetDevice(device);
    ^~~~~~~~~~~~~~~~~~~~~~
```

To reproduce, build any affected target with ROCm >= 7.0. Example using
the gloo HIP collectives (which calls `cudaSetDevice` and
`cudaDeviceEnablePeerAccess` without checking the return value):

```bash
hipcc -std=c++17 -Werror \
  -I<pytorch_root> -I<rocm_7.0_path>/include \
  -c gloo/cuda_collectives_native.h
# → error: ignoring return value ... [-Werror,-Wunused-result]
```

The fix adds `(void)` casts to explicitly discard the return value,
which is the standard C++ pattern for suppressing `[[nodiscard]]`
warnings. The casts are no-ops on CUDA and older ROCm versions.

## Verification (fbcode, mode/amd-gpu with ROCm 7.0 headers)

```bash
# ctran (ibutils.cc, LogInit.cc)
buck2 build mode/amd-gpu fbcode//comms/ctran/backends/ib:ib
buck2 build mode/amd-gpu fbcode//comms/ctran/utils:utils

# rcclx (cudawrap.cc, register.cc, RcclxScubaLogger.h)
buck2 build mode/amd-gpu fbcode//comms/rcclx:rcclx-dev

# tcp_devmem (batch_unpack_producer.cc, shared_region.cc)
buck2 build mode/amd-gpu fbcode//comms/tcp_devmem/unpack:batch_unpack_producer
buck2 build mode/amd-gpu fbcode//comms/tcp_devmem/common:common

# gloo (cuda_collectives_native.h)
buck2 build mode/amd-gpu fbcode//gloo:gloo_gpu_hip
```

All targets build successfully. The BUCK dep fixes for
`comms/tcp_devmem/nccl` (nccl-gen, nccl-sim) and
`comms/tcp_devmem/unpack` resolve link-time errors that surface when
building under ROCm constraints.

Reviewed By: bbeckca

Differential Revision: D93759269
gyllstromk added a commit to gyllstromk/gloo that referenced this pull request Mar 9, 2026
…e2 (pytorch#494)

Summary:

X-link: meta-pytorch/torchcomms#960

X-link: pytorch/pytorch#176671

ROCm 7.0+ HIP headers annotate API functions (hipStreamDestroy,
hipMemcpyAsync, hipStreamSynchronize, hipSetDevice, hipGetDevice, hipFree,
hipHostUnregister, hipDeviceEnablePeerAccess, cuGetErrorString) with
[[nodiscard]]. Combined with -Werror, this causes build failures wherever
return values are discarded.

Originally discovered building with ROCm 7.2 headers, but confirmed to
also affect ROCm 7.0 builds (reported independently by yvliu and hqguo).
The [[nodiscard]] attribute is present in both ROCm 7.0 and 7.2 HIP
headers — the fix is the same for both versions.

Changes:
- Add (void) casts to suppress [[nodiscard]] warnings across comms/
  (tcp_devmem, ctran, rcclx), gloo/, and caffe2/ (nativert) — 12 C++ files
- Fix BUCK dependency issues in comms/tcp_devmem/nccl (replace devmgr-client
  with common:common) and comms/tcp_devmem/unpack (explicit glog dep path)
  that surface when building these targets under ROCm constraints

The (void) casts are no-ops on CUDA and older ROCm — safe to land
regardless of ROCm version.

Reviewed By: bbeckca

Differential Revision: D93759269
gyllstromk added a commit to gyllstromk/pytorch that referenced this pull request Mar 9, 2026
…omms, gloo, caffe2 (pytorch#176671)

Summary:
X-link: pytorch/gloo#494

X-link: meta-pytorch/torchcomms#960


ROCm 7.0+ HIP headers annotate API functions (hipStreamDestroy,
hipMemcpyAsync, hipStreamSynchronize, hipSetDevice, hipGetDevice, hipFree,
hipHostUnregister, hipDeviceEnablePeerAccess, cuGetErrorString) with
[[nodiscard]]. Combined with -Werror, this causes build failures wherever
return values are discarded.

Originally discovered building with ROCm 7.2 headers, but confirmed to
also affect ROCm 7.0 builds (reported independently by yvliu and hqguo).
The [[nodiscard]] attribute is present in both ROCm 7.0 and 7.2 HIP
headers — the fix is the same for both versions.

Changes:
- Add (void) casts to suppress [[nodiscard]] warnings across comms/
  (tcp_devmem, ctran, rcclx), gloo/, and caffe2/ (nativert) — 12 C++ files
- Fix BUCK dependency issues in comms/tcp_devmem/nccl (replace devmgr-client
  with common:common) and comms/tcp_devmem/unpack (explicit glog dep path)
  that surface when building these targets under ROCm constraints

The (void) casts are no-ops on CUDA and older ROCm — safe to land
regardless of ROCm version.

Test Plan:
## Reproducing the [[nodiscard]] build errors (ROCm 7.0+)

ROCm 7.0 HIP headers annotate CUDA-mapped API functions with
`[[nodiscard]]` (e.g. `hipStreamDestroy`, `hipSetDevice`, `hipFree`).
With `-Werror` enabled, any call site that discards the return value
fails to compile:

```
error: ignoring return value of function declared with 'nodiscard'
attribute [-Werror,-Wunused-result]
    cudaSetDevice(device);
    ^~~~~~~~~~~~~~~~~~~~~~
```

To reproduce, build any affected target with ROCm >= 7.0. Example using
the gloo HIP collectives (which calls `cudaSetDevice` and
`cudaDeviceEnablePeerAccess` without checking the return value):

```bash
hipcc -std=c++17 -Werror \
  -I<pytorch_root> -I<rocm_7.0_path>/include \
  -c gloo/cuda_collectives_native.h
# → error: ignoring return value ... [-Werror,-Wunused-result]
```

The fix adds `(void)` casts to explicitly discard the return value,
which is the standard C++ pattern for suppressing `[[nodiscard]]`
warnings. The casts are no-ops on CUDA and older ROCm versions.

## Verification (fbcode, mode/amd-gpu with ROCm 7.0 headers)

```bash
# ctran (ibutils.cc, LogInit.cc)
buck2 build mode/amd-gpu fbcode//comms/ctran/backends/ib:ib
buck2 build mode/amd-gpu fbcode//comms/ctran/utils:utils

# rcclx (cudawrap.cc, register.cc, RcclxScubaLogger.h)
buck2 build mode/amd-gpu fbcode//comms/rcclx:rcclx-dev

# tcp_devmem (batch_unpack_producer.cc, shared_region.cc)
buck2 build mode/amd-gpu fbcode//comms/tcp_devmem/unpack:batch_unpack_producer
buck2 build mode/amd-gpu fbcode//comms/tcp_devmem/common:common

# gloo (cuda_collectives_native.h)
buck2 build mode/amd-gpu fbcode//gloo:gloo_gpu_hip
```

All targets build successfully. The BUCK dep fixes for
`comms/tcp_devmem/nccl` (nccl-gen, nccl-sim) and
`comms/tcp_devmem/unpack` resolve link-time errors that surface when
building under ROCm constraints.

Reviewed By: bbeckca

Differential Revision: D93759269
gyllstromk added a commit to gyllstromk/gloo that referenced this pull request Mar 9, 2026
…e2 (pytorch#494)

Summary:
Pull Request resolved: pytorch#494

X-link: meta-pytorch/torchcomms#960

X-link: pytorch/pytorch#176671

ROCm 7.0+ HIP headers annotate API functions (hipStreamDestroy,
hipMemcpyAsync, hipStreamSynchronize, hipSetDevice, hipGetDevice, hipFree,
hipHostUnregister, hipDeviceEnablePeerAccess, cuGetErrorString) with
[[nodiscard]]. Combined with -Werror, this causes build failures wherever
return values are discarded.

Originally discovered building with ROCm 7.2 headers, but confirmed to
also affect ROCm 7.0 builds (reported independently by yvliu and hqguo).
The [[nodiscard]] attribute is present in both ROCm 7.0 and 7.2 HIP
headers — the fix is the same for both versions.

Changes:
- Add (void) casts to suppress [[nodiscard]] warnings across comms/
  (tcp_devmem, ctran, rcclx), gloo/, and caffe2/ (nativert) — 12 C++ files
- Fix BUCK dependency issues in comms/tcp_devmem/nccl (replace devmgr-client
  with common:common) and comms/tcp_devmem/unpack (explicit glog dep path)
  that surface when building these targets under ROCm constraints

The (void) casts are no-ops on CUDA and older ROCm — safe to land
regardless of ROCm version.

Reviewed By: bbeckca

Differential Revision: D93759269
gyllstromk added a commit to gyllstromk/pytorch that referenced this pull request Mar 9, 2026
…omms, gloo, caffe2 (pytorch#176671)

Summary:
X-link: pytorch/gloo#494

X-link: meta-pytorch/torchcomms#960

Pull Request resolved: pytorch#176671

ROCm 7.0+ HIP headers annotate API functions (hipStreamDestroy,
hipMemcpyAsync, hipStreamSynchronize, hipSetDevice, hipGetDevice, hipFree,
hipHostUnregister, hipDeviceEnablePeerAccess, cuGetErrorString) with
[[nodiscard]]. Combined with -Werror, this causes build failures wherever
return values are discarded.

Originally discovered building with ROCm 7.2 headers, but confirmed to
also affect ROCm 7.0 builds (reported independently by yvliu and hqguo).
The [[nodiscard]] attribute is present in both ROCm 7.0 and 7.2 HIP
headers — the fix is the same for both versions.

Changes:
- Add (void) casts to suppress [[nodiscard]] warnings across comms/
  (tcp_devmem, ctran, rcclx), gloo/, and caffe2/ (nativert) — 12 C++ files
- Fix BUCK dependency issues in comms/tcp_devmem/nccl (replace devmgr-client
  with common:common) and comms/tcp_devmem/unpack (explicit glog dep path)
  that surface when building these targets under ROCm constraints

The (void) casts are no-ops on CUDA and older ROCm — safe to land
regardless of ROCm version.

Test Plan:
## Reproducing the [[nodiscard]] build errors (ROCm 7.0+)

ROCm 7.0 HIP headers annotate CUDA-mapped API functions with
`[[nodiscard]]` (e.g. `hipStreamDestroy`, `hipSetDevice`, `hipFree`).
With `-Werror` enabled, any call site that discards the return value
fails to compile:

```
error: ignoring return value of function declared with 'nodiscard'
attribute [-Werror,-Wunused-result]
    cudaSetDevice(device);
    ^~~~~~~~~~~~~~~~~~~~~~
```

To reproduce, build any affected target with ROCm >= 7.0. Example using
the gloo HIP collectives (which calls `cudaSetDevice` and
`cudaDeviceEnablePeerAccess` without checking the return value):

```bash
hipcc -std=c++17 -Werror \
  -I<pytorch_root> -I<rocm_7.0_path>/include \
  -c gloo/cuda_collectives_native.h
# → error: ignoring return value ... [-Werror,-Wunused-result]
```

The fix adds `(void)` casts to explicitly discard the return value,
which is the standard C++ pattern for suppressing `[[nodiscard]]`
warnings. The casts are no-ops on CUDA and older ROCm versions.

## Verification (fbcode, mode/amd-gpu with ROCm 7.0 headers)

```bash
# ctran (ibutils.cc, LogInit.cc)
buck2 build mode/amd-gpu fbcode//comms/ctran/backends/ib:ib
buck2 build mode/amd-gpu fbcode//comms/ctran/utils:utils

# rcclx (cudawrap.cc, register.cc, RcclxScubaLogger.h)
buck2 build mode/amd-gpu fbcode//comms/rcclx:rcclx-dev

# tcp_devmem (batch_unpack_producer.cc, shared_region.cc)
buck2 build mode/amd-gpu fbcode//comms/tcp_devmem/unpack:batch_unpack_producer
buck2 build mode/amd-gpu fbcode//comms/tcp_devmem/common:common

# gloo (cuda_collectives_native.h)
buck2 build mode/amd-gpu fbcode//gloo:gloo_gpu_hip
```

All targets build successfully. The BUCK dep fixes for
`comms/tcp_devmem/nccl` (nccl-gen, nccl-sim) and
`comms/tcp_devmem/unpack` resolve link-time errors that surface when
building under ROCm constraints.

Reviewed By: bbeckca

Differential Revision: D93759269
@pytorch-bot

pytorch-bot Bot commented Mar 11, 2026

Copy link
Copy Markdown

This PR needs a release notes: label

If your changes are user facing and intended to be a part of release notes, please use a label starting with release notes:.

If not, please add the topic: not user facing label.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "topic: not user facing"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

@gyllstromk

Copy link
Copy Markdown
Contributor Author

@pytorchbot merge

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge failed

Reason: This PR has internal changes and must be landed via Phabricator! Please try reimporting/rexporting the PR!

Details for Dev Infra team Raised by workflow job

@pytorch-bot

pytorch-bot Bot commented Mar 11, 2026

Copy link
Copy Markdown

This PR needs a release notes: label

If your changes are user facing and intended to be a part of release notes, please use a label starting with release notes:.

If not, please add the topic: not user facing label.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "topic: not user facing"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

pytorch-bot Bot pushed a commit that referenced this pull request Mar 12, 2026
…comms, gloo, caffe2 (#176671)

Summary:
ROCm 7.0+ HIP headers annotate API functions (hipStreamDestroy,
hipMemcpyAsync, hipStreamSynchronize, hipSetDevice, hipGetDevice, hipFree,
hipHostUnregister, hipDeviceEnablePeerAccess, cuGetErrorString) with
[[nodiscard]]. Combined with -Werror, this causes build failures wherever
return values are discarded.

Originally discovered building with ROCm 7.2 headers, but confirmed to
also affect ROCm 7.0 builds (reported independently by yvliu and hqguo).
The [[nodiscard]] attribute is present in both ROCm 7.0 and 7.2 HIP
headers — the fix is the same for both versions.

Changes:
- Add (void) casts to suppress [[nodiscard]] warnings across comms/
  (tcp_devmem, ctran, rcclx), gloo/, and caffe2/ (nativert) — 12 C++ files
- Fix BUCK dependency issues in comms/tcp_devmem/nccl (replace devmgr-client
  with common:common) and comms/tcp_devmem/unpack (explicit glog dep path)
  that surface when building these targets under ROCm constraints

The (void) casts are no-ops on CUDA and older ROCm — safe to land
regardless of ROCm version.


Test Plan: buck2 build mode/amd-gpu -m rocm72 fbcode//comms/tcp_devmem/unpack:batch_unpack_producer fbcode//gloo:cuda_collectives_native — builds successfully

Differential Revision: D93759269

Pulled By: gyllstromk
…omms, gloo, caffe2 (pytorch#176671)

Summary:
ROCm 7.0+ HIP headers annotate API functions (hipStreamDestroy,
hipMemcpyAsync, hipStreamSynchronize, hipSetDevice, hipGetDevice, hipFree,
hipHostUnregister, hipDeviceEnablePeerAccess, cuGetErrorString) with
[[nodiscard]]. Combined with -Werror, this causes build failures wherever
return values are discarded.

Originally discovered building with ROCm 7.2 headers, but confirmed to
also affect ROCm 7.0 builds (reported independently by yvliu and hqguo).
The [[nodiscard]] attribute is present in both ROCm 7.0 and 7.2 HIP
headers — the fix is the same for both versions.

Changes:
- Add (void) casts to suppress [[nodiscard]] warnings across comms/
  (tcp_devmem, ctran, rcclx), gloo/, and caffe2/ (nativert) — 12 C++ files
- Fix BUCK dependency issues in comms/tcp_devmem/nccl (replace devmgr-client
  with common:common) and comms/tcp_devmem/unpack (explicit glog dep path)
  that surface when building these targets under ROCm constraints

The (void) casts are no-ops on CUDA and older ROCm — safe to land
regardless of ROCm version.

Pull Request resolved: pytorch#176671

Test Plan: buck2 build mode/amd-gpu -m rocm72 fbcode//comms/tcp_devmem/unpack:batch_unpack_producer fbcode//gloo:cuda_collectives_native — builds successfully

Differential Revision: D93759269

Pulled By: gyllstromk
@meta-codesync meta-codesync Bot changed the title [rocm][7.0/7.2] Fix [[nodiscard]] build errors and BUCK deps across comms, gloo, caffe2 [rocm][7.0/7.2] Fix [[nodiscard]] build errors and BUCK deps across comms, gloo, caffe2 (#176671) Mar 12, 2026
@huydhn
huydhn requested a review from jeffdaily March 13, 2026 00:45
@huydhn

huydhn commented Mar 13, 2026

Copy link
Copy Markdown
Contributor

@pytorchbot drci

@huydhn

huydhn commented Mar 13, 2026

Copy link
Copy Markdown
Contributor

@ptyorchbot merge

@huydhn

huydhn commented Mar 13, 2026

Copy link
Copy Markdown
Contributor

@pytorchbot merge

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge failed

Reason: This PR needs a release notes: label
If your changes are user facing and intended to be a part of release notes, please use a label starting with release notes:.

If not, please add the topic: not user facing label.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "topic: not user facing"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

Details for Dev Infra team Raised by workflow job

@pytorch-bot

pytorch-bot Bot commented Mar 13, 2026

Copy link
Copy Markdown

This PR needs a release notes: label

If your changes are user facing and intended to be a part of release notes, please use a label starting with release notes:.

If not, please add the topic: not user facing label.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "topic: not user facing"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

@huydhn huydhn added the topic: not user facing topic category label Mar 13, 2026
@huydhn

huydhn commented Mar 13, 2026

Copy link
Copy Markdown
Contributor

@pytorchbot merge -i

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged while ignoring the following 2 checks: trunk / linux-jammy-rocm-py3.10 / test (default, 4, 6, linux.rocm.gpu.gfx950.1), trunk / linux-jammy-cuda13.0-py3.10-gcc11 / test (default, 3, 5, lf.linux.g6.4xlarge.experimental.nvidia.gpu)

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

EmanueleCoradin pushed a commit to EmanueleCoradin/pytorch that referenced this pull request Mar 30, 2026
…omms, gloo, caffe2 (pytorch#176671) (pytorch#176671)

Summary:
ROCm 7.0+ HIP headers annotate API functions (hipStreamDestroy,
hipMemcpyAsync, hipStreamSynchronize, hipSetDevice, hipGetDevice, hipFree,
hipHostUnregister, hipDeviceEnablePeerAccess, cuGetErrorString) with
[[nodiscard]]. Combined with -Werror, this causes build failures wherever
return values are discarded.

Originally discovered building with ROCm 7.2 headers, but confirmed to
also affect ROCm 7.0 builds (reported independently by yvliu and hqguo).
The [[nodiscard]] attribute is present in both ROCm 7.0 and 7.2 HIP
headers — the fix is the same for both versions.

Changes:
- Add (void) casts to suppress [[nodiscard]] warnings across comms/
  (tcp_devmem, ctran, rcclx), gloo/, and caffe2/ (nativert) — 12 C++ files
- Fix BUCK dependency issues in comms/tcp_devmem/nccl (replace devmgr-client
  with common:common) and comms/tcp_devmem/unpack (explicit glog dep path)
  that surface when building these targets under ROCm constraints

The (void) casts are no-ops on CUDA and older ROCm — safe to land
regardless of ROCm version.

Test Plan: buck2 build mode/amd-gpu -m rocm72 fbcode//comms/tcp_devmem/unpack:batch_unpack_producer fbcode//gloo:cuda_collectives_native — builds successfully

Differential Revision: D93759269

Pulled By: gyllstromk

Pull Request resolved: pytorch#176671
Approved by: https://github.com/Skylion007
gplutop7 pushed a commit to gplutop7/pytorch that referenced this pull request Jul 15, 2026
…omms, gloo, caffe2 (pytorch#176671) (pytorch#176671)

Summary:
ROCm 7.0+ HIP headers annotate API functions (hipStreamDestroy,
hipMemcpyAsync, hipStreamSynchronize, hipSetDevice, hipGetDevice, hipFree,
hipHostUnregister, hipDeviceEnablePeerAccess, cuGetErrorString) with
[[nodiscard]]. Combined with -Werror, this causes build failures wherever
return values are discarded.

Originally discovered building with ROCm 7.2 headers, but confirmed to
also affect ROCm 7.0 builds (reported independently by yvliu and hqguo).
The [[nodiscard]] attribute is present in both ROCm 7.0 and 7.2 HIP
headers — the fix is the same for both versions.

Changes:
- Add (void) casts to suppress [[nodiscard]] warnings across comms/
  (tcp_devmem, ctran, rcclx), gloo/, and caffe2/ (nativert) — 12 C++ files
- Fix BUCK dependency issues in comms/tcp_devmem/nccl (replace devmgr-client
  with common:common) and comms/tcp_devmem/unpack (explicit glog dep path)
  that surface when building these targets under ROCm constraints

The (void) casts are no-ops on CUDA and older ROCm — safe to land
regardless of ROCm version.

Test Plan: buck2 build mode/amd-gpu -m rocm72 fbcode//comms/tcp_devmem/unpack:batch_unpack_producer fbcode//gloo:cuda_collectives_native — builds successfully

Differential Revision: D93759269

Pulled By: gyllstromk

Pull Request resolved: pytorch#176671
Approved by: https://github.com/Skylion007
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/rocm-mi300 Trigger "default" config CI on ROCm MI300 ciflow/trunk Trigger trunk jobs on your pull request fb-exported Merged meta-exported module: rocm AMD GPU support for Pytorch topic: not user facing topic category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants