-
Notifications
You must be signed in to change notification settings - Fork 549
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Integrate CK PR1453 for improving fp8 gemm (#2971)
Summary: Integrate ROCm/composable_kernel#1453 and disable conditional OOB check, which improves both memory bound and compute bound cases * ~~Add a flag expect better register allocation (perf. regression with ROCm 6.2+)~~ Move all flags to D61204625 * Enable bf16 atomic_add D60544251 * Add 256x256x128 tile for fp8 gemm * Optimize OOB check strategy, reduce conditional mask usage and instance number of gemm_multiply_multiply. * Disable conditional OOB check Pull Request resolved: #2971 X-link: facebookresearch/FBGEMM#68 Reviewed By: danzimm Differential Revision: D60996231 fbshipit-source-id: 9b1e9841bfef7b37139c9095a71625b28177c004
- Loading branch information
1 parent
4ae45b7
commit 440cbb0
Showing
11 changed files
with
122 additions
and
44 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
72 changes: 72 additions & 0 deletions
72
...s/fp8_rowwise_256x256x256x128_16x16_8x8_8x32x1_8x32x1_1x32x1x8_8x8x1_1x2_intrawave_v3.hip
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
#include "fp8_rowwise_common.h" | ||
|
||
at::Tensor | ||
fp8_rowwise_256x256x256x128_16x16_8x8_8x32x1_8x32x1_1x32x1x8_8x8x1_1x2_intrawave_v3( | ||
at::Tensor XQ, | ||
at::Tensor WQ, | ||
at::Tensor x_scale, | ||
at::Tensor w_scale, | ||
at::Tensor Y) { | ||
// A kernel that seems to work well on mid sized tensors. | ||
|
||
// Check if this input needs to be padded. | ||
int M = size_to_dim_(XQ.dim() - 1, XQ.sizes()); | ||
int N = WQ.size(0); | ||
int K = WQ.size(1); | ||
bool pad = (K % 128 != 0); | ||
|
||
// Dispatch based on whether padding is needed or not. | ||
if (pad) { | ||
using DeviceGemmInstance = DeviceGemmHelper< | ||
256, | ||
256, | ||
256, | ||
128, | ||
16, | ||
16, | ||
8, | ||
8, | ||
S<8, 32, 1>, | ||
S<8, 32, 1>, | ||
S<1, 32, 1, 8>, | ||
S<8, 8, 1>, | ||
1, | ||
2, | ||
ck::BlockGemmPipelineScheduler::Intrawave, | ||
ck::BlockGemmPipelineVersion::v3, | ||
ck::tensor_operation::device::GemmSpecialization::KPadding>; | ||
// Run kernel instance. | ||
return f8f8bf16_rowwise_impl<DeviceGemmInstance>( | ||
XQ, WQ, x_scale, w_scale, Y); | ||
} else { | ||
using DeviceGemmInstance = DeviceGemmHelper< | ||
256, | ||
256, | ||
256, | ||
128, | ||
16, | ||
16, | ||
8, | ||
8, | ||
S<8, 32, 1>, | ||
S<8, 32, 1>, | ||
S<1, 32, 1, 8>, | ||
S<8, 8, 1>, | ||
1, | ||
2, | ||
ck::BlockGemmPipelineScheduler::Intrawave, | ||
ck::BlockGemmPipelineVersion::v3, | ||
ck::tensor_operation::device::GemmSpecialization::Default>; | ||
// Run kernel instance. | ||
return f8f8bf16_rowwise_impl<DeviceGemmInstance>( | ||
XQ, WQ, x_scale, w_scale, Y); | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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