Repository navigation
Skip PackedAttention random input generation when CUDA is unavailable - #34199
Merged
Merged
Conversation
Check the existing per-type CUDA architecture requirement before allocating or generating random inputs. Report unsupported environments as skipped and preserve all supported GPU test inputs. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Tianlei Wu (tianleiwu)
approved these changes
Nov 13, 2026
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues were identified for the change that skips unsupported CUDA configurations before random-input generation.
No open issues 🎉
What changed in this PR
Moves the CUDA availability check ahead of PackedAttention random-input generation, avoiding expensive fixture setup on unsupported environments.
Changes:
- Reports unsupported configurations as skipped before constructing an
OpTester. - Preserves per-type CUDA requirements and supported GPU test behavior across all three random-data tests.
No actionable findings.
| File | Description |
|---|---|
onnxruntime/test/contrib_ops/packed_attention_op_test.cc |
Moves the shared CUDA guard before random-data allocation and generation, removing the later conditional wrapper. |
Review effort: Balanced
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.
Description
Move the existing per-type
HasCudaEnvironment(is_float16 ? 530 : 0)check to the start ofRunModelWithRandomInput, before constructing the random generator, allocating token offsets, or generating inputs, weights, and biases. Unsupported environments now reportGTEST_SKIP()before anyOpTesteris constructed.The shared guard covers
TestWithRandomData,TestWithRandomDataWithRBP, andTestWithRandomDataLargeSeq. Supported GPU FP32/FP16/RBP/large-sequence dimensions, seeds, inputs, tolerances, reference comparisons, and minimum CUDA architectures are unchanged. The guard remains per invocation: lack of FP16 support does not prevent the mixed-type cases from exercising supported FP32 inputs. No CI, build optimization, cache, or image changes.Validation — head
b8eda7e79f5c9787ae23670802a2179fc0a2418f:ort-github-linux-16-arm64-eus2-ss, the same CPU runner pool as the reference. Its provider-test command was/onnxruntime_src/build/Debug/Debug/onnxruntime_provider_test "--gtest_output=xml:/onnxruntime_src/build/Debug/Debug/onnxruntime_provider_test.Debug.results.xml"— passed; 7,024 tests selected, including all three random-data cases, each explicitly reported skipped. This is not a zero-match pass.git diff --check— passed..\.venv\Scripts\clang-format.exe --dry-run --Werror onnxruntime\test\contrib_ops\packed_attention_op_test.cc— passed with clang-format 20.1.8..venv, aftercall "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat", ran.venv\Scripts\python.exe tools\ci_build\build.py --build_dir build\n --config Debug --update --build --parallel 12 --skip_submodule_sync --cmake_generator Ninja --target onnxruntime_provider_test --disable_memleak_checker— passed. Build log confirmspacked_attention_op_test.cc.objrecompiled and the executable relinked. Cache confirms Debug and CUDA OFF.build\n\Debug:onnxruntime_provider_test.exe --gtest_filter=PackedAttentionTest.TestWithRandomData* --gtest_list_tests— exit 0; listed exactly the three existing random-data tests.onnxruntime_provider_test.exe --gtest_filter=PackedAttentionTest.TestWithRandomData* --gtest_output=xml:C:\Users\erscor\.copilot\session-state\893b4970-454c-4884-9b9c-2c936909fed7\files\packed-attention-cpu-debug.xml— exit 0; 3 selected, 3 skipped, 0 failures. Local x64 XML reports 10 ms / 4 ms / 0 ms for random data / RBP / large sequence; gtest reports 16 ms suite time, 19 ms including global setup/teardown. These are separate x64 results, not the ARM64 performance comparison below.Local build notes: Visual Studio generation first hit Windows' 260-character MSBuild path limit, so validation used Ninja in this worktree. The initial default Debug executable compiled successfully and selected/skipped all three tests, but its experimental Windows memory-leak checker exited -1 at shutdown; even
--gtest_list_testsalone reported shutdown leaks. The clean local validation above uses the repository-supported--disable_memleak_checkeroption locally only; Debug optimization settings are unchanged. No repository build settings were edited.CUDA hardware/runtime is unavailable locally. GPU execution was not performed locally; the original architecture expression and supported GPU path were inspected for unchanged behavior. CPU-only runs verify early gating, not GPU numerical correctness.
Motivation and Context
The CUDA-only random-data tests previously generated large CPU fixtures before checking whether CUDA was available. Measured Linux ARM64 Debug comparison, using the completed reference job and successful after-change draft PR job:
PackedAttentionTest.prefix)TestWithRandomDataTestWithRandomDataWithRBPTestWithRandomDataLargeSeqThe reported slow pair's runtime fell by 99.998%, measured on the same ARM64 Debug CPU runner pool. Millisecond timings are rounded by gtest; 0 ms does not mean literally zero elapsed time.
The whole provider-test CTest entry went from 2,112.21 s to 1,706.48 s, an observed reduction of 405.73 s (19.21%). Treat that as descriptive, not a controlled whole-suite attribution: the reference selected 7,019 tests and the PR merge selected 7,024, and these are different CI runs/commits. The pair alone accounted for 18.94% of the reference provider-test time; all three accounted for 19.45%.
The supplied cold-run reference pair is consistent (266,686 + 133,286 ms); the supplied ARM64 Release reference pair was 2,333 + 1,170 ms. The additional ARM64 Release measurements are reported below; no GPU performance timings are claimed.
Independent change based on
main; does not modify or stack on #34163 or the ccache experiment.Cross-platform impact
Combined gtest time for all three existing random-data tests (including the large-sequence case):
Total measured aggregate test execution removed: 497,242 ms (8m17.242s) across these jobs, not an equivalent decrease in elapsed PR/CI time. Every after-change occurrence explicitly reports skipped; all compared jobs succeeded. Windows runs the provider tests twice (regular and example-plugin executions), and both executions are included. Gtest rounds timings to milliseconds.
Sources: Linux before / after; macOS before / after; Windows before / after. Linux compares the earlier experiment reference with this PR; macOS/Windows use successful main runs at this branch's base commit, 6080d7c. These are separate runs, not controlled repeated benchmarks.
Total workflow elapsed time: estimate versus observation
No net end-to-end workflow reduction was observed in these particular run pairs. Using the first job's
started_atthrough the final job'scompleted_at(excluding initial runner queue delay, but including later job scheduling gaps), GitHub reports:Including initial queue time, creation-to-final-job-completion was Linux 49m48s -> 54m33s, macOS 86m46s -> 94m49s, and Windows 43m14s -> 66m28s. In particular, the Windows after-run waited about 32m24s before its job started, versus 9m20s before; this is not test runtime.
The fixture savings are directly visible in individual test timings, but build/configuration/cache state, scheduling, other tests, and different commits confound whole-workflow comparisons. The ARM64 Debug provider-test entry itself decreased by 405.73s (19.21%), while the entire ARM64 Debug job increased from 43m38s to 50m22s; other work more than offset the test savings in this pair.
All-else-equal critical-path estimate: ARM64 Debug was the last-finishing Linux job in both runs. Removing its measured 410.914s of fixture work would shorten the reference Linux workflow execution span from 46m31s to about 39m40s: approximately 6m51s, or 14.7%, provided other timings remain fixed and no other job becomes the bottleneck. This is a modeled potential wall-clock saving, not an observed workflow speedup. Savings in parallel Linux jobs do not add to that critical-path reduction. The measured macOS CPU Debug job was not the final-finishing job (the ARM64 iPhone simulator was), so its 14.912s saving alone does not shorten that workflow's critical path. For the single-job Windows workflow, the isolated all-else-equal saving is about 6.623s (0.33% of baseline execution time).
Builds that do not execute these tests receive no benefit. Supported CUDA paths still generate and exercise the original fixtures; no GPU computation speedup is claimed.