Fix three -Wunused-variable sites in HIP-built sources - #6202
Open
q10 wants to merge 1 commit into
Open
Conversation
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
Contributor
|
@q10 has exported this pull request. If you are a Meta employee, you can view the originating Diff in D115963368. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
Fixes the
-Wunused-variablediagnostics in HIP-built sources that are notdemoted by a
-Wno-error=and therefore become hard errors once-Werrorisrestored 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_tilecomputation, but that block sitsunder
#ifndef USE_ROCM; the ROCm branch keys offnum_expertsinstead. Meanwhilethe ROCm
DISPATCH_E_*macros take the value as parameterSand discard it. So thevariable is genuinely unused on ROCm and genuinely used on CUDA.
Marked rather than moved or
#ifdef-ed: both paths still name it as a macroargument, so relocating the declaration would mean duplicating it or widening the
guard around unrelated code.
2.
quantize/quantize.cu--retmoved inside#ifndef USE_ROCMDeclared just above the guard, but its only assignments and its only read
(
use_shmem = ret == cudaSuccess) are all inside#ifndef USE_ROCM; the ROCm branchjust sets
use_shmem = false. The declaration belongs in the block. This is a puremove -- no
[[maybe_unused]]needed, and the CUDA path is untouched.3.
ck_extensions/bf16_grouped/bf16_grouped_gemm.hip-- deadKremovedint64_t K = B.size(2);with no reader.MandNnext to it are both used;Konly appears in
TORCH_CHECKmessage strings, which are string literals and do notreference 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-variablesites may appear once itcompletes.
Reviewed By: cthi
Differential Revision: D115963368