Repository navigation
Support for half_t as a scalar type - #3360
brian-kelley wants to merge 21 commits into
Conversation
A few things need to happen, first we need to enable the logic in cmake, second we need to add some guard to only enable when half is not float otherwise we create double instantiations for the float type, thirds we will likely need to clean up some code in the library... Signed-off-by: Luc Berger-Vergiat <lberge@sandia.gov>
Now using the macro defined in Kokkos Core to signal support of half_t using native type instead of float. Adding test that exercise the half code path when the type is instantiated. Signed-off-by: Luc Berger-Vergiat <lberge@sandia.gov>
Signed-off-by: Luc Berger-Vergiat <lberge@sandia.gov>
Signed-off-by: Luc Berger-Vergiat <lberge@sandia.gov>
Co-Authored-By: Laguna S2.1 Signed-off-by: Brian Kelley <bmkelle@sandia.gov>
Make sure compiler launcher from Kokkos is used with check_cxx_symbol_exists, otherwise this test doesn't work for cuda. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Brian Kelley <bmkelle@sandia.gov>
batched dense/sparse, blas serial/team, most of sparse Co-Authored-By: Laguna S 2.1 Signed-off-by: Brian Kelley <bmkelle@sandia.gov>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Signed-off-by: Brian Kelley <bmkelle@sandia.gov>
Signed-off-by: Brian Kelley <bmkelle@sandia.gov>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Signed-off-by: Brian Kelley <bmkelle@sandia.gov>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Signed-off-by: Brian Kelley <bmkelle@sandia.gov>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Signed-off-by: Brian Kelley <bmkelle@sandia.gov>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Signed-off-by: Brian Kelley <bmkelle@sandia.gov>
Signed-off-by: Brian Kelley <bmkelle@sandia.gov>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Signed-off-by: Brian Kelley <bmkelle@sandia.gov>
Signed-off-by: Brian Kelley <bmkelle@sandia.gov>
and make nrm2w_squared test for half_t consistent with nrm2w Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Signed-off-by: Brian Kelley <bmkelle@sandia.gov>
Signed-off-by: Brian Kelley <bmkelle@sandia.gov>
lucbv
left a comment
There was a problem hiding this comment.
I do not think that everything needs to be addressed, but some of the comment should be turned into issues to work on later. Will do that when I get to the office...
| A[i * as] += ValueType(minus_abs_tiny) * ValueType(static_cast<float>(a_real < 0)); | ||
| A[i * as] += ValueType(abs_tiny) * ValueType(static_cast<float>(a_real >= 0)); |
There was a problem hiding this comment.
I would be curious to see if there is any performance reason not to implement this as a tertiary operator?
| A[i * as] += ValueType(minus_abs_tiny) * ValueType(static_cast<float>(a_real < 0)); | |
| A[i * as] += ValueType(abs_tiny) * ValueType(static_cast<float>(a_real >= 0)); | |
| A[i * as] += (a_real < 0) ? ValueType(minus_abs_tiny) : ValueType(0); | |
| A[i * as] += (a_real >= 0) ? ValueType(abs_tiny) * ValueType(0); |
| // and half_t is not an alias to float. | ||
| #if !defined(KOKKOSKERNELS_ETI_ONLY) && !defined(KOKKOSKERNELS_IMPL_CHECK_ETI_CALLS) && \ | ||
| defined(KOKKOS_HALF_T_IS_FLOAT) && !KOKKOS_HALF_T_IS_FLOAT | ||
| #if !defined(KOKKOSKERNELS_ETI_ONLY) && !defined(KOKKOSKERNELS_IMPL_CHECK_ETI_CALLS) && defined(KOKKOSKERNELS_INST_HALF) |
There was a problem hiding this comment.
Well, we are instantiating half_t now so we could probably revisit this logic?
There was a problem hiding this comment.
For laswp that does not compute any arithmetic operations I would have expected that we can use the arithmetic traits epsilon value?
| #pragma unroll | ||
| #endif | ||
| for (int i = 0; i < m; ++i) A[i * as0] *= alpha; | ||
| for (int i = 0; i < m; ++i) A[i * as0] *= ValueType(alpha); |
There was a problem hiding this comment.
This might not be really what we want especially if ScalarType is double and ValueType is lower precision?
This goes back to discussions about the definition of our rules for type promotion...
|
|
||
| template <class ScalarA, class ScalarB, class Device> | ||
| int test_dot() { | ||
| const int Nbig = std::is_same<ScalarA, Kokkos::Experimental::half_t>::value ? 128 : 1024; |
There was a problem hiding this comment.
Is the problem that we cannot add too many random generated numbers before risking overflow with half_t?
I am suspecting that we are doing the reduction with double by default which should be fine for rounding error but might not be possible to cast without overflow. That's something that we could test for in the algorithm itself in debug mode...
There was a problem hiding this comment.
ah, we don't have an InnerProductSpaceTraits or DotAccumulatingScalar specialization for half_t, so this was doing the accumulation in half_t. I'll try changing this to accumulate in float and then see if we can get away with the same vector length as other tests.
There was a problem hiding this comment.
Like we talked about yesterday, native dot was not accumulating in double (even for float vectors). I opened #3365 to fix this. If possible I'd like to get that merged first
| const int max_x = 1; | ||
| const int max_y = 1; | ||
| const int max_val = 1; |
| const int max_x = 10; | ||
| const int max_y = 10; | ||
| const int max_val = 10; |
| const int max_x = 10; | ||
| const int max_y = 10; | ||
| const int max_val = 10; |
| const int max_x = 1; | ||
| const int max_y = 1; | ||
| const mag_t max_val = static_cast<mag_t>(2); |
There was a problem hiding this comment.
We might want to promote the use of KokkosKernels::ArithTraits<>::one()/zero() to our LLM friends
Signed-off-by: Brian Kelley <bmkelle@sandia.gov>
Signed-off-by: Brian Kelley <bmkelle@sandia.gov>
- Fix selectEpsilonForScalarType; if KOKKOS_HALF_T_IS_FLOAT it should use the float value (2nd arg) when scalar_t is either half_t or float, not the half value (3rd arg). - Fix tolerances in ODE Newton tests (were wrong when KOKKOS_HALF_T_IS_FLOAT for same reason). Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Signed-off-by: Brian Kelley <bmkelle@sandia.gov>
KokkosKernels_INST_HALFhalf_t == float) then this option can't be turned onhalf_ttoprintfdirectly, and don't try to implicitly convert a bool to half_t.But a large majority of the changes are for enabling half_t coverage in tests:
TestUtils::selectEpsilonForScalarType<Scalar>(eps_double, eps_float, eps_half)to make this cleaner