Repository navigation
test(hip-kernel-provider): compare workspaces instead of hardcoding a device-dependent size - #12478
Conversation
✅ All Checks Passed — Ready for Review
📖 Need help? See the Policy FAQ for details on every check and how to fix failures. |
|
🎉 All checks passed! This PR is ready for review. |
8e82819 to
e48f676
Compare
… device-dependent size
`GetWorkspaceSizeWithoutOptionalTensorsReturnsNonzero` and
`GetMaxWorkspaceSizeBpropWithoutOptionalTensorsReturnsNonzero` assert the
fallback mean/rstd workspace as an absolute `16u`, but the backward workspace
is the sum of that term and a parallel reduction buffer whose presence depends
on the compute-unit count of the machine running the tests:
reqd = 4 * localSize * multiProcessorCount
isParallel = innerSize <= reqd && innerSize * outerSize > reqd
For their shape that is true for one band of CU counts and false outside it, so
the expected value is only correct on some machines and both tests fail on the
rest. Test pools that mix hardware therefore pass or fail by runner draw.
Assert the difference between the same shape with and without mean/inv_variance
instead. The parallel term is identical for both graphs, so it cancels: the
difference is the fallback mean/rstd workspace alone on every machine, with no
CU-dependent expected value and no assumption about which branch was taken.
e48f676 to
b7ec1f8
Compare
EwanC
left a comment
There was a problem hiding this comment.
Thanks for tracking down this issue and coming up with a fix.
Patch makes sense to me, to rephrase in my own understanding: The plan needs a workspace in either of the cases a) no provided optional stats tensors b) parallel case which is determined based on device CUs. The test assumption was that the parallel case wouldn't be triggered and only the optional tensors would be used in workspace size calculation, but actually some of the devices stressed by CI did have a number of CUs that hit the parallel case and the extra size requirement threw off the hardcoded 16 workspace size value.
TLDR, LGTM
TheRock Submodule Bump ActivityNewest first
|
Summary
Fixes #12479.
Two layernorm backward workspace tests pass or fail depending on the compute-unit count of the machine running them. Any PR can be blocked at random, and they are equally broken on
develop— the green runs simply landed on machines outside the failing band.TestLayernormBwdPlan.GetWorkspaceSizeWithoutOptionalTensorsReturnsNonzeroTestLayernormPlanBuilder.GetMaxWorkspaceSizeBpropWithoutOptionalTensorsReturnsNonzeroExample failure: run 35807379268, job 107050043339 —
Which is: 2408464vs the expected16u.Root cause
The backward workspace is the sum of two terms (
LayernormBwdPlan.cpp:148-169, helpers at:344-372):Both tests want the second term, and assert it as an absolute
16u. That only holds when the first term is zero, which for their shape (outerSize=2,innerSize=150528) means a CU count outside the band[37, 73]. Inside that band the parallel branch is taken and adds 2408448 bytes, which is the failure above. Whether a given run lands inside the band is a property of the machine, not of the change under test.Change
Assert the difference between the same shape with and without
mean/inv_variance. Both graphs have identical dims and strides, so they take the same branch and carry the same parallel reduction buffer — it cancels, leaving the fallback mean/rstd term alone:No CU-dependent expected value, no assumption about which branch the machine takes, and the original shape is kept so both branches still get exercised by whichever machines run the suite. Test-only; no product code changes.
Verification
Full
hip_kernel_provider_testsunit suite on the development machine: 531 tests, 524 passed, 7 skipped, 0 failed.The cancellation was checked with the parallel branch live, using a throwaway probe (not committed) with
dims {8,3,224,224}— a shape that satisfiesisParallelon that machine's CU count:withStatsis the parallel reduction buffer alone (nonzero, so the branch is active) and the delta is exactly4 * 2 * outerSize * stride=4 * 2 * 8 * 1= 64 — the fallback term, independent of the parallel term.The original CU dependence was reproduced by driving the public statics with fabricated
hipDeviceProp_tvalues:ws=2408464inside the band matches the linked CI failure byte for byte.