Repository navigation
Implement fp16 x fp8, bf16 x fp8, fp8 x fp16, and fp8 x bf16 for the V3 pipeline #4276
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
90b950b
999b493
afba075
a9c5248
b381791
7a8c448
6ae8db7
6fa3fde
2e5fac9
9475ac1
abaa06b
3c4553a
d168d2f
1abad5a
5a304ff
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,109 @@ | ||
| // Copyright (c) Advanced Micro Devices, Inc., or its affiliates. | ||
| // SPDX-License-Identifier: MIT | ||
|
|
||
| #pragma once | ||
|
|
||
| #include "ck_tile/core.hpp" | ||
|
|
||
| // DetermineWarpPrecType is a set of rules to determine the right precision type to use | ||
| // for the warp GEMM, given the other precision type. This gives rise to a type conversion: | ||
| // type conversions are sometimes needed to obtain a pair of types that are compatible with | ||
| // the hardware matrix operations available. A typical use case is mixed precision GEMMs. | ||
|
|
||
| namespace ck_tile { | ||
| // For the most general case, default to no conversion. | ||
| template <typename APrecType, typename BPrecType> | ||
| struct DetermineWarpPrecType | ||
| { | ||
| using a_prec_type = APrecType; | ||
| using b_prec_type = BPrecType; | ||
| }; | ||
|
|
||
| // For pk_fp4_t x pk_fp4_t, keep pk_fp4_t | ||
| template <> | ||
| struct DetermineWarpPrecType<ck_tile::pk_fp4_t, ck_tile::pk_fp4_t> | ||
| { | ||
| using a_prec_type = ck_tile::pk_fp4_t; | ||
| using b_prec_type = ck_tile::pk_fp4_t; | ||
| }; | ||
|
|
||
| // For pk_int4_t x B, use the B type. | ||
| template <typename BPrecType> | ||
| struct DetermineWarpPrecType<ck_tile::pk_int4_t, BPrecType> | ||
| { | ||
| using a_prec_type = BPrecType; | ||
| using b_prec_type = BPrecType; | ||
| }; | ||
|
|
||
| // For A x pk_int4_t, use the A type. | ||
| template <typename APrecType> | ||
| struct DetermineWarpPrecType<APrecType, ck_tile::pk_int4_t> | ||
| { | ||
| using a_prec_type = APrecType; | ||
| using b_prec_type = APrecType; | ||
| }; | ||
|
|
||
| // For pk_fp4_t x B, use the B type. | ||
| template <typename BPrecType> | ||
| struct DetermineWarpPrecType<ck_tile::pk_fp4_t, BPrecType> | ||
| { | ||
| using a_prec_type = BPrecType; | ||
| using b_prec_type = BPrecType; | ||
| }; | ||
|
|
||
| // For A x pk_fp4_t, use the A type. | ||
| template <typename APrecType> | ||
| struct DetermineWarpPrecType<APrecType, ck_tile::pk_fp4_t> | ||
| { | ||
| using a_prec_type = APrecType; | ||
| using b_prec_type = APrecType; | ||
| }; | ||
|
|
||
| // For B x pk_fp4_raw_t, use the B type. | ||
| template <typename BPrecType> | ||
| struct DetermineWarpPrecType<ck_tile::pk_fp4_raw_t, BPrecType> | ||
| { | ||
| using a_prec_type = BPrecType; | ||
| using b_prec_type = BPrecType; | ||
| }; | ||
|
|
||
| // For A x pk_fp4_raw_t, use the A type. | ||
| template <typename APrecType> | ||
| struct DetermineWarpPrecType<APrecType, ck_tile::pk_fp4_raw_t> | ||
|
Comment on lines
+70
to
+72
|
||
| { | ||
| using a_prec_type = APrecType; | ||
| using b_prec_type = APrecType; | ||
| }; | ||
|
|
||
| // For fp8 x bf16, use fp8 | ||
| template <> | ||
| struct DetermineWarpPrecType<ck_tile::fp8_t, ck_tile::bf16_t> | ||
| { | ||
| using a_prec_type = ck_tile::fp8_t; | ||
| using b_prec_type = ck_tile::fp8_t; | ||
| }; | ||
|
|
||
| // For bf16 x fp8, use bf16 | ||
| template <> | ||
| struct DetermineWarpPrecType<ck_tile::bf16_t, ck_tile::fp8_t> | ||
| { | ||
| using a_prec_type = ck_tile::bf16_t; | ||
| using b_prec_type = ck_tile::bf16_t; | ||
| }; | ||
|
|
||
| // For fp8 x fp16, use fp8 | ||
| template <> | ||
| struct DetermineWarpPrecType<ck_tile::fp8_t, ck_tile::half_t> | ||
| { | ||
| using a_prec_type = ck_tile::fp8_t; | ||
| using b_prec_type = ck_tile::fp8_t; | ||
| }; | ||
|
|
||
| // For fp16 x fp8, use fp16 | ||
| template <> | ||
| struct DetermineWarpPrecType<ck_tile::half_t, ck_tile::fp8_t> | ||
| { | ||
| using a_prec_type = ck_tile::half_t; | ||
| using b_prec_type = ck_tile::half_t; | ||
| }; | ||
| }; // namespace ck_tile | ||
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comments for the
pk_fp4_raw_tspecializations don’t match the template argument order (line 64 ispk_fp4_raw_t x B, notB x pk_fp4_raw_t). Updating these comments would reduce confusion when extending the rule set.