Skip to content

MIOpen error tolerance - #3638

Closed
Beanavil wants to merge 2 commits into
ROCm:developfrom
StreamHPC:miopen-error-tolerance
Closed

Beanavil wants to merge 2 commits into
ROCm:developfrom
StreamHPC:miopen-error-tolerance

Conversation

@Beanavil

Copy link
Copy Markdown
Member

Scope

While testing the variant 0 for bnorm backward spatial single, we observed that the error tolerance in MIOpenDriver is sub-optimal. For instance, the following results were observed

Backwards prop batch norm verification passed on dx (0.151171)
Backwards prop batch norm verification passed on dscale (0.277024)
Backwards prop batch norm verification passed on dbias (0.217736)
Backwards Prop Batch Norm Verifies on CPU and GPU.

Notice that the execution is successful, according to the driver checks. However, the error reported is high so this should actually be failing.

Notes for the reviewer

  • Fixed the maxrms definition because it was too big compared to the rms values being computed (due to the rms normalization done). The VerifyForward method seems to also be using the same value for maxrms as the new implementation in VerifyBackward.
  • Fixed the normalization of the rms. Previously we were finding the maximum absolute value from both the reference values and the results, but this may not be correct because it reduces the significance of the rms: if the results differ a lot from the reference values (e.g. ref values are order of 10 and results are order 1000) then the normalization will divide the rms obtained (which will be order of 100) by a number order of 1000 and then the normalized rms will be 100/1000 = 0.1 which is way lower than what it should be.
    • The new implementation only takes into account the reference results for computing the normalization factor

@Beanavil Beanavil changed the title MiOpen error tolerance MIOpen error tolerance Mar 17, 2025
Comment thread test/verify.hpp Outdated

// Reference values are r1, measured values are r2
template <class R1, class R2>
double rms_range(R1&& r1, R2&& r2)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should rename these arguments to make it clear that r1 is intended to be the reference.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done!

Comment thread test/verify.hpp
Comment on lines -224 to +229
double mag2 = static_cast<double>(*std::max_element(r2.begin(), r2.end(), compare_mag));
double mag =
std::max({std::fabs(mag1), std::fabs(mag2), std::numeric_limits<double>::min()});
return std::sqrt(square_difference) / (std::sqrt(n) * mag);
double normalizer = std::max({std::fabs(mag1), std::numeric_limits<double>::min()});
return std::sqrt(square_difference) / (std::sqrt(n) * normalizer);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hehe this will be a spicy one.
Interesting find though!

@BrianHarrisonAMD

Copy link
Copy Markdown
Contributor

Starting CI!

averinevg
averinevg previously approved these changes Mar 19, 2025

@averinevg averinevg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment thread test/verify.hpp Outdated
@Beanavil
Beanavil force-pushed the miopen-error-tolerance branch from dd06398 to 389e109 Compare March 21, 2025 15:59
cderb
cderb previously approved these changes Mar 21, 2025
@BrianHarrisonAMD

Copy link
Copy Markdown
Contributor

Restarting CI again.

@BrianHarrisonAMD

Copy link
Copy Markdown
Contributor

Failing on formatting.
Please run the formatting script.

@Beanavil
Beanavil force-pushed the miopen-error-tolerance branch from 389e109 to fea5f7d Compare March 31, 2025 08:21
@Beanavil

Copy link
Copy Markdown
Member Author

@BrianHarrisonAMD opsie, missed to run this before. Should be ok now!

@Beanavil

Copy link
Copy Markdown
Member Author

Btw I see that some smoke tests are failing for gfx90a (MI200), but I have double-checked on our side and they pass on our MI200s, how should we proceed for those?

@BrianHarrisonAMD

Copy link
Copy Markdown
Contributor

Btw I see that some smoke tests are failing for gfx90a (MI200), but I have double-checked on our side and they pass on our MI200s, how should we proceed for those?

Looks like it was stopped / aborted before fully finishing.
Ill run the internal CI to see if it passes.

@Beanavil
Beanavil force-pushed the miopen-error-tolerance branch from fea5f7d to 83c6070 Compare May 13, 2025 07:30
@Beanavil

Copy link
Copy Markdown
Member Author

@BrianHarrisonAMD any updates on this?

@BrianHarrisonAMD

Copy link
Copy Markdown
Contributor

I can start the build again, and let @BradPepersAMD know about it.

@BrianHarrisonAMD

Copy link
Copy Markdown
Contributor

CI running now.

@Beanavil
Beanavil force-pushed the miopen-error-tolerance branch from 83c6070 to 0ecf7af Compare May 21, 2025 10:47
@BradPepersAMD

Copy link
Copy Markdown
Collaborator

Did this pass CI and are we good to merge this now?

@BrianHarrisonAMD

Copy link
Copy Markdown
Contributor

We need to update this with latest, and re-run CI on it.
Since it impacts all tests, and driver commands we need to do a large sweep on these changes before they can be safely merged.

@amd-hsivasun

Copy link
Copy Markdown

Imported to ROCm/rocm-libraries

EwanC added a commit to ROCm/rocm-libraries that referenced this pull request Jul 9, 2026
## Scope

While testing the variant 0 for bnorm backward spatial single, we
observed that the error tolerance in MIOpenDriver is sub-optimal. For
instance, the following results were observed


Notice that the execution is successful, according to the driver checks.
However, the error reported is high so this should actually be failing.

## Notes for the reviewer
- Fixed the definition because it was too big compared to the rms values
being computed (due to the rms normalization done). The method seems to
also be using the same value for as the new implementation in .
- Fixed the normalization of the rms. Previously we were finding the
maximum absolute value from both the reference values and the results,
but this may not be correct because it reduces the significance of the
rms: if the results differ a lot from the reference values (e.g. ref
values are order of 10 and results are order 1000) then the
normalization will divide the rms obtained (which will be order of 100)
by a number order of 1000 and then the normalized rms will be 100/1000 =
0.1 which is way lower than what it should be.
- The new implementation only takes into account the reference results
for computing the normalization factor


---
🔁 Imported from
[ROCm/MIOpen#3638](ROCm/MIOpen#3638)
🧑‍💻 Originally authored by @Beanavil

---------

Co-authored-by: Beatriz Navidad Vilches <beatriz@streamhpc.com>
Co-authored-by: assistant-librarian[bot] <assistant-librarian[bot]@users.noreply.github.com>
Co-authored-by: JonathanLichtnerAMD <195780826+JonathanLichtnerAMD@users.noreply.github.com>
Co-authored-by: Milo Lurati <70884255+MiloLurati@users.noreply.github.com>
Co-authored-by: Bálint Siklósi <25982046+sikba@users.noreply.github.com>
Co-authored-by: Balint Siklosi <balint.siklosi@streamhpc.com>
Co-authored-by: SreecharanGundaboluAMD <sgundabo@amd.com>
Co-authored-by: Ewan Crawford <ewan.crawford@streamhpc.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants