Skip to content

Fix three -Wunused-variable sites in HIP-built sources - #6202

Open
q10 wants to merge 1 commit into
pytorch:mainfrom
q10:export-D115963368
Open

Fix three -Wunused-variable sites in HIP-built sources#6202
q10 wants to merge 1 commit into
pytorch:mainfrom
q10:export-D115963368

Conversation

@q10

@q10 q10 commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

Summary:
Fixes the -Wunused-variable diagnostics in HIP-built sources that are not
demoted by a -Wno-error= and therefore become hard errors once -Werror is
restored on HIP.

Each of the three needed a different fix, because "unused variable" meant something
different in each case. None of them are actually dead code in every configuration.

1. moe/index_shuffling.cu -- storage_factor -> [[maybe_unused]]

It is used on CUDA, by the num_tokens_per_tile computation, but that block sits
under #ifndef USE_ROCM; the ROCm branch keys off num_experts instead. Meanwhile
the ROCm DISPATCH_E_* macros take the value as parameter S and discard it. So the
variable is genuinely unused on ROCm and genuinely used on CUDA.

Marked rather than moved or #ifdef-ed: both paths still name it as a macro
argument, so relocating the declaration would mean duplicating it or widening the
guard around unrelated code.

2. quantize/quantize.cu -- ret moved inside #ifndef USE_ROCM

Declared just above the guard, but its only assignments and its only read
(use_shmem = ret == cudaSuccess) are all inside #ifndef USE_ROCM; the ROCm branch
just sets use_shmem = false. The declaration belongs in the block. This is a pure
move -- no [[maybe_unused]] needed, and the CUDA path is untouched.

3. ck_extensions/bf16_grouped/bf16_grouped_gemm.hip -- dead K removed

int64_t K = B.size(2); with no reader. M and N next to it are both used; K
only appears in TORCH_CHECK message strings, which are string literals and do not
reference the variable. HIP-only file, so no dual-path concern -- deleted.

This is partial. The census that scoped this covered only 13% of the build before
the ROCm job timed out, so more -Wunused-variable sites may appear once it
completes.

Reviewed By: cthi

Differential Revision: D115963368

Summary:
Fixes the `-Wunused-variable` diagnostics in HIP-built sources that are **not**
demoted by a `-Wno-error=` and therefore become hard errors once `-Werror` is
restored on HIP.

Each of the three needed a different fix, because "unused variable" meant something
different in each case. None of them are actually dead code in every configuration.

**1. `moe/index_shuffling.cu` -- `storage_factor` -> `[[maybe_unused]]`**

It *is* used on CUDA, by the `num_tokens_per_tile` computation, but that block sits
under `#ifndef USE_ROCM`; the ROCm branch keys off `num_experts` instead. Meanwhile
the ROCm `DISPATCH_E_*` macros take the value as parameter `S` and discard it. So the
variable is genuinely unused on ROCm and genuinely used on CUDA.

Marked rather than moved or `#ifdef`-ed: both paths still name it as a macro
argument, so relocating the declaration would mean duplicating it or widening the
guard around unrelated code.

**2. `quantize/quantize.cu` -- `ret` moved inside `#ifndef USE_ROCM`**

Declared just above the guard, but its only assignments and its only read
(`use_shmem = ret == cudaSuccess`) are all inside `#ifndef USE_ROCM`; the ROCm branch
just sets `use_shmem = false`. The declaration belongs in the block. This is a pure
move -- no `[[maybe_unused]]` needed, and the CUDA path is untouched.

**3. `ck_extensions/bf16_grouped/bf16_grouped_gemm.hip` -- dead `K` removed**

`int64_t K = B.size(2);` with no reader. `M` and `N` next to it are both used; `K`
only appears in `TORCH_CHECK` message strings, which are string literals and do not
reference the variable. HIP-only file, so no dual-path concern -- deleted.

**This is partial.** The census that scoped this covered only 13% of the build before
the ROCm job timed out, so more `-Wunused-variable` sites may appear once it
completes.

Reviewed By: cthi

Differential Revision: D115963368
@meta-cla meta-cla Bot added the cla signed label Aug 23, 2026
@meta-codesync

meta-codesync Bot commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant