Repository navigation
ukernels: add bf16 * bf16 -> bf16 optimized tile functions for x86 and arm64. - #15543
Merged
Merged
Conversation
This was referenced Nov 10, 2023
bjacob
force-pushed
the
bjacob-ukernel-test-improvements
branch
from
November 10, 2023 20:16
0cfef67 to
2fe4ae1
Compare
bjacob
force-pushed
the
bjacob-ukernel-bf16bf16bf16
branch
3 times, most recently
from
November 10, 2023 21:40
b2d7384 to
6508cec
Compare
bjacob
marked this pull request as ready for review
November 10, 2023 21:44
Collaborator
Author
|
PTAL @benvanik |
bjacob
added a commit
that referenced
this pull request
Nov 14, 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 #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 (#15525).
bjacob
force-pushed
the
bjacob-ukernel-bf16bf16bf16
branch
from
November 14, 2023 15:59
6508cec to
3e19a88
Compare
Collaborator
Author
benvanik
approved these changes
Nov 14, 2023
ScottTodd
reviewed
Nov 14, 2023
Comment on lines
+63
to
+64
| __m256i loaded = _mm256_loadu_si256((const __m256i*)(out_ptr + i * 16)); | ||
| acc[i] = _mm512_cvtpbh_ps(*(const __m256bh*)&loaded); |
Member
There was a problem hiding this comment.
I see errors here building on my Windows machine:
[build] [739/7322 9% :: 11.296] Building C object runtime\src\iree\builtins\ukernel\arch\x86_64\CMakeFiles\iree_builtins_ukernel_arch_x86_64_x86_64_avx512_bf16.objects.dir\mmt4d_x86_64_avx512_bf16.c.obj
[build] FAILED: runtime/src/iree/builtins/ukernel/arch/x86_64/CMakeFiles/iree_builtins_ukernel_arch_x86_64_x86_64_avx512_bf16.objects.dir/mmt4d_x86_64_avx512_bf16.c.obj
[build] ccache C:\PROGRA~2\MICROS~1\2022\Preview\VC\Tools\MSVC\1431~1.311\bin\Hostx64\x64\cl.exe /nologo -external:ID:\dev\projects\iree -external:ID:\dev\projects\iree-build -external:ID:\dev\projects\iree\runtime\src\iree\.. -external:ID:\dev\projects\iree-build\runtime\src\iree\.. -external:W0 /DWIN32 /D_WINDOWS /Z7 /O2 /Ob1 -MD /DWIN32_LEAN_AND_MEAN /DNOMINMAX /D_USE_MATH_DEFINES /D_CRT_SECURE_NO_WARNINGS /D_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES /GR- /bigobj /Zc:preprocessor /std:c11 /W3 /wd4200 /wd4018 /wd4146 /wd4244 /wd4267 /wd4005 /wd4065 /wd4141 /wd4624 /wd5105 /arch:AVX512 -std:c11 /showIncludes /Foruntime\src\iree\builtins\ukernel\arch\x86_64\CMakeFiles\iree_builtins_ukernel_arch_x86_64_x86_64_avx512_bf16.objects.dir\mmt4d_x86_64_avx512_bf16.c.obj /Fdruntime\src\iree\builtins\ukernel\arch\x86_64\CMakeFiles\iree_builtins_ukernel_arch_x86_64_x86_64_avx512_bf16.objects.dir\ /FS -c D:\dev\projects\iree\runtime\src\iree\builtins\ukernel\arch\x86_64\mmt4d_x86_64_avx512_bf16.c
[build] D:\dev\projects\iree\runtime\src\iree\builtins\ukernel\arch\x86_64\mmt4d_x86_64_avx512_bf16.c(64): warning C4013: '_mm512_cvtpbh_ps' undefined; assuming extern returning int
[build] D:\dev\projects\iree\runtime\src\iree\builtins\ukernel\arch\x86_64\mmt4d_x86_64_avx512_bf16.c(64): error C2440: '=': cannot convert from 'int' to '__m512'
CI looks green though. Guess my machine has avx512 and the CI doesn't, or something like that?
bjacob
added a commit
that referenced
this pull request
Nov 15, 2023
…#15589) As reported by @ScottTodd in #15543 (comment) At least this MSVC version, identified by `_MSC_VER=1930`, lacks the `_mm512_cvtpbh_ps` intrinsic. On the other hand, the CI builders are doing OK, and they have `_MSC_VER=1937`.
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).
ramiro050
pushed a commit
to ramiro050/iree
that referenced
this pull request
Dec 19, 2023
…and arm64. (iree-org#15543) This should fix the "50x slowdown" performance issue iree-org#15504.
ramiro050
pushed a commit
to ramiro050/iree
that referenced
this pull request
Dec 19, 2023
…iree-org#15589) As reported by @ScottTodd in iree-org#15543 (comment) At least this MSVC version, identified by `_MSC_VER=1930`, lacks the `_mm512_cvtpbh_ps` intrinsic. On the other hand, the CI builders are doing OK, and they have `_MSC_VER=1937`.
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.
This should fix the "50x slowdown" performance issue #15504.