Skip to content

ukernel test improvements - #15542

Merged
bjacob merged 1 commit into
mainfrom
bjacob-ukernel-test-improvements
Nov 14, 2023
Merged

bjacob merged 1 commit into
mainfrom
bjacob-ukernel-test-improvements

Conversation

@bjacob

@bjacob bjacob commented Nov 10, 2023 •

Copy link
Copy Markdown
Collaborator
  • Consistently compare with/without skipping of intermediate roundings. A catch is that the ukernel may fall back to a generic code path (and that fallback is consistently exercised by the test, even when a non-fallback path is also available and tested). And generic code paths ("tile functions") never skipped intermediate roundings, even if allowed to by the flag. This caused complicated test code retrying again on error. This PR simply adds the skipping-intermediate-roundings generic tile functions, so the test code is simpler, and concretely I just needed that for ukernels: add bf16 * bf16 -> bf16 optimized tile functions for x86 and arm64. #15543 as I'm adding bf16-accumulator tile functions that are skipping intermediate roundings.
    • I had to also update iree-e2e-matmul-test to switch to skipping intermediate roundings. Unlike the ukernels' own tests, which really must test both flavors, in iree-e2e-matmul-test we are e2e testing what the compiler produces, and that is skippig intermediate roundings at least by default, and while that could be overridden with --iree-llvmcpu-skip-intermediate-roundings=false, we don't currently test that in e2e matmul tests.
  • Generate better random test input values. Some were too large - when we generate random bfloat16 to accumulate into bfloat16, they better be very small as we don't want to grow accumulators to the point where they would start rounding. It's OK, because bfloat16 kernels use bfloat16 arithmetic instructions, not bit hacks, so correctness is sufficiently tested on very small values. Conversely, for int8/int16 test input values, we were generating a very narrow range and that was potentially missing important coverage as some of our int kernels are starting to do evil bit hacks (Optimized vecmat ukernel tile functions for i16 x u4 -> i32 on AVX-512-VNNI #15525).

@bjacob
bjacob force-pushed the bjacob-ukernel-test-improvements branch from 0cfef67 to 2fe4ae1 Compare November 10, 2023 20:16
@bjacob
bjacob marked this pull request as ready for review November 10, 2023 20:43
@bjacob
bjacob requested a review from benvanik as a code owner November 10, 2023 20:43
@bjacob

bjacob commented Nov 14, 2023

Copy link
Copy Markdown
Collaborator Author

PTAL @benvanik

@bjacob
bjacob merged commit 16e4346 into main Nov 14, 2023
@bjacob
bjacob deleted the bjacob-ukernel-test-improvements branch November 14, 2023 15:58
ramiro050 pushed a commit to ramiro050/iree that referenced this pull request Dec 19, 2023
* Consistently compare with/without skipping of intermediate roundings.
A catch is that the ukernel may fall back to a generic code path (and
that fallback is consistently exercised by the test, even when a
non-fallback path is also available and tested). And generic code paths
("tile functions") never skipped intermediate roundings, even if allowed
to by the flag. This caused complicated test code retrying again on
error. This PR simply adds the skipping-intermediate-roundings generic
tile functions, so the test code is simpler, and concretely I just
needed that for iree-org#15543 as I'm adding bf16-accumulator tile functions
that are skipping intermediate roundings.
* I had to also update `iree-e2e-matmul-test` to switch to skipping
intermediate roundings. Unlike the ukernels' own tests, which really
must test both flavors, in `iree-e2e-matmul-test` we are e2e testing
what the compiler produces, and that is skippig intermediate roundings
at least by default, and while that could be overridden with
`--iree-llvmcpu-skip-intermediate-roundings=false`, we don't currently
test that in e2e matmul tests.
* Generate better random test input values. Some were too large - when
we generate random bfloat16 to accumulate into bfloat16, they better be
very small as we don't want to grow accumulators to the point where they
would start rounding. It's OK, because bfloat16 kernels use bfloat16
arithmetic instructions, not bit hacks, so correctness is sufficiently
tested on very small values. Conversely, for int8/int16 test input
values, we were generating a very narrow range and that was potentially
missing important coverage as some of our int kernels are starting to do
evil bit hacks (iree-org#15525).
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.

2 participants