Repository navigation
moe-cache: fix pre-existing HIP nodiscard errors blocking the -Werror gate - #302
Merged
Merged
Conversation
HIP marks hipError_t [[nodiscard]] (CUDA does not mark cudaError_t this way), so the ubuntu-22-hip-quality-check -Werror build fails on every discarded-return CUDA runtime call in this file. All affected sites are best-effort cleanup/rollback/teardown calls whose result was already intentionally ignored, matching the file's existing (void)cudaGetLastError() idiom. Explicitly void the results rather than introducing new error checks, so CUDA runtime behavior is unchanged.
7 tasks done
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.
What
ubuntu-22-hip-quality-checkbuilds with-Werrorand fails on 19 discarded-return CUDA runtime calls inmoe-cache.cu:HIP declares
hipError_tas[[nodiscard]]. CUDA does not markcudaError_tthat way, so these compile clean under nvcc and hard-error under HIP. Nothing here is new. The gate has been red on every PR in the repo for this reason, and contributors keep being asked to look at a failure that is not theirs.I confirmed it is pre-existing rather than introduced by any open PR. Against #300, which touches this file, the reported line numbers are exactly the base-branch sites plus that PR's insertions:
The fix
(void)on all 19, which is the idiom this file already uses. There are six pre-existing(void)cudaGetLastError();sites inmoe-cache.cu(lines 771, 796, 1062, 1077, 1254, 2495), so this is matching local convention rather than introducing one.Deliberately not
CUDA_CHECK. That macro callsggml_cuda_error, which is[[noreturn]]and aborts. All 19 sites are teardown, rollback, or best-effort drain, and eight of them are insidemoe_cache_free_device, which is called frommoe_cache_session_destroy. Converting those toCUDA_CHECKwould introduce aborts during shutdown, which is a behavior change and a worse one. The file's ownmoe_cache_cuda_ok(...)soft-check helper was also considered and rejected for the same reason: none of these sites were checked before, and making them checked is a separate decision from making them compile.Every hunk is a single-statement
(void)wrap. No reordering, no control flow change, no statements added or removed. This is compile-time only and CUDA behavior is bit-for-bit identical.Verification
I have no HIP or CUDA toolchain on this machine, so the HIP build itself was not run locally. This needs the CI job to confirm green. Being explicit about that rather than implying it was tested.
What I did verify locally, since the whole fix rests on one assumption:
That reproduces the CI diagnostic exactly, same wording and same
-Wunused-valueflag, and the(void)form compiles clean under the same flags. So the suppression mechanism is confirmed even though the real HIP compile is not.Also swept the file for all 47
cuda*(occurrences and classified each as assigned, wrapped inmoe_cache_cuda_ok, already(void), or bare. The 19 bare ones are the ones changed here, and none remain.