-
Notifications
You must be signed in to change notification settings - Fork 520
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Minor CK FP8 Tuning Improvements (#2987)
Summary: X-link: facebookresearch/FBGEMM#80 Pull Request resolved: #2987 This diff makes a few small changes to improve CK FP8 performance based on recent improvements to ROCM and CK that have landed. We specifically use the large kernel added in D60996231 more liberally as it's quite good and reenable some files in the CK Profiler that can now compile. I also add some performance flags that are currently only enabled for CK as of this diff: D61266671 The latest llama benchmarks after this change are available [here](https://docs.google.com/spreadsheets/d/1GD44u4Sud_6T9iq_SJvYmSn8tx0bRd9niZPy2gVHK-s/edit?gid=482861329#gid=482861329). We also include fix for certain small K values that dont work with newer versions of the CK pipeline. Reviewed By: jianyuh, zjing14 Differential Revision: D61285882 fbshipit-source-id: 55113e76026b04cda63a4324bb2c5eb5c242ecb7
- Loading branch information
1 parent
82e00b1
commit 537aeb3
Showing
3 changed files
with
86 additions
and
2 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
72 changes: 72 additions & 0 deletions
72
...ls/fp8_rowwise_128x32x128x128_32x32_1x2_8x16x1_8x16x1_1x16x1x8_8x8x1_1x1_interwave_v2.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_128x32x128x128_32x32_1x2_8x16x1_8x16x1_1x16x1x8_8x8x1_1x1_interwave_v2( | ||
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< | ||
128, | ||
32, | ||
128, | ||
128, | ||
32, | ||
32, | ||
1, | ||
2, | ||
S<8, 16, 1>, | ||
S<8, 16, 1>, | ||
S<1, 16, 1, 8>, | ||
S<8, 8, 1>, | ||
1, | ||
1, | ||
ck::BlockGemmPipelineScheduler::Interwave, | ||
ck::BlockGemmPipelineVersion::v2, | ||
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< | ||
128, | ||
32, | ||
128, | ||
128, | ||
32, | ||
32, | ||
1, | ||
2, | ||
S<8, 16, 1>, | ||
S<8, 16, 1>, | ||
S<1, 16, 1, 8>, | ||
S<8, 8, 1>, | ||
1, | ||
1, | ||
ck::BlockGemmPipelineScheduler::Interwave, | ||
ck::BlockGemmPipelineVersion::v2, | ||
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