test(miopen): add CTC loss numel>INT_MAX scale coverage (ALMIOPEN-2148) - #10252
Open
peymanr wants to merge 4 commits into
Open
test(miopen): add CTC loss numel>INT_MAX scale coverage (ALMIOPEN-2148)#10252peymanr wants to merge 4 commits into
peymanr wants to merge 4 commits into
Conversation
Add projects/miopen/test/gtest/ctc_large.cpp with a single Scale-tier test that runs MIOpen CTC loss forward pass on a shape where T*N*C = 1000*2048*1049 = 2,148,352,000 > INT_MAX (2,147,483,647). The existing gtest/ctc.cpp cases top out at ~64 M elements. At numel > INT_MAX the plain `int` dimension products inside ctc.cpp (class_sz * batch_size * max_time_step) overflow, producing negative workspace offsets and silent out-of-bounds access in the CTC kernel. The new test: - Skips gracefully via GTEST_SKIP() when free GPU memory < 19 GiB (logits alone require ~8.59 GiB float32; workspace adds ~1 GiB) - Allocates logits / gradients / losses directly on GPU to avoid an equivalent host allocation - Initialises probs with hipMemset(0) — uniform logits are valid CTC inputs (softmax(0,...,0) = uniform distribution) - Asserts every loss value is finite; NaN/Inf flags index overflow - No CPU reference comparison (host 8.59 GiB buffer is prohibitive) Suggested MIOpenDriver equivalent for manual verification: MIOpenDriver ctc -T 1000 -N 2048 -C 1048 --forw 1 -V 0 -t 1 JIRA ID: ALMIOPEN-2148
✅ All Checks Passed — Ready for Review
📖 Need help? See the Policy FAQ for details on every check and how to fix failures. |
Pre-commit check failed⛔ pre-commit failed Please run locally:
This repo uses |
Fix clang-format violations flagged by pre-commit CI. Resolves: ALMIOPEN-2148
|
🎉 All checks passed! This PR is ready for review. |
The three hipFree calls in the cleanup section of Run() were silently discarding hipError_t (declared nodiscard), causing -Werror,-Wunused-value build failures. Wrap with (void) cast to explicitly acknowledge the return value in teardown context. Fixes: MIOpen Build Hip Package CI failure (ALMIOPEN-2148).
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
Add a new gtest file
projects/miopen/test/gtest/ctc_large.cppwith a Scale-tier test that exercises MIOpen CTC loss at logit numel > INT_MAX.Motivation
The existing
gtest/ctc.cppcases top out at approximately 64 M elements (batch=128, T=100, C=5001). MIOpen's CTC kernel accumulates the logit tensor dimensions through plainintlocals inctc.cpp:When
T * N * CexceedsINT_MAX(2 147 483 647), these multiplications wrap to negative values, producing out-of-bounds workspace reads/writes and silently wrong losses. Large-vocabulary or long-sequence ASR models (e.g. T=1000, vocab=50k, batch=128) are in this regime.JIRA ID: ALMIOPEN-2148
What the test does
hipMemGetInfoand callsGTEST_SKIP()when free GPU memory < 19 GiB; safe to run on smaller devices.hipMemset(0)— uniform logits give a valid softmax input.NaNorInfsignals integer overflow in the workspace offset computation.MIOpenDriver equivalent for manual verification on TW325 (gfx942):
Test tier
The test uses a
TEST_Ffixture with aScale_GPU_CTC_numel_gt_INT_MAXcase name. It is picked up automatically byfile(GLOB TESTS *.cpp)in the gtestCMakeLists.txt— noCMakeLists.txtmodification required. TheScale_prefix and the memory guard prevent accidental execution in Smoke/Standard CI.Checklist
GTEST_SKIP()guard for insufficient GPU memorystatic_assertconfirms numel > INT_MAX at compile timeJIRA ID: ALMIOPEN-2148included in commit message and PR body🤖 Assisted by PR Pundit