Skip to content

Commit 2aa8cd0

Browse files
cthimeta-codesync[bot]
authored andcommitted
Add better assertions for MXFP8 group gemm (#5203)
Summary: Pull Request resolved: #5203 X-link: https://github.com/facebookresearch/FBGEMM/pull/2200 Currently only supporst BF16 out, but would silently fail if someone tries FP32 out. Add explicit assertion for this. And some small code refactor. Reviewed By: q10, summerdengfb, jianyuh Differential Revision: D88747914 fbshipit-source-id: da8337816d7792c3abb64ce67e768bd8ef539873
1 parent c246916 commit 2aa8cd0

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

fbgemm_gpu/experimental/gen_ai/src/quantize/cutlass_extensions/mx8mx8bf16_grouped.cu

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,9 @@ at::Tensor mx8mx8bf16_grouped_mm(
165165
TORCH_CHECK(false, "Invalid input shapes. Must be one of 2D-2D, 2D-3D.");
166166
}
167167

168+
TORCH_CHECK(output_actual.dtype() == at::kBFloat16, "output must be bf16.");
168169
// Early exit for empty inputs.
169-
if (M == 0) {
170+
if (output_actual.numel() == 0) {
170171
return output_actual;
171172
}
172173

fbgemm_gpu/experimental/gen_ai/src/quantize/cutlass_extensions/mx8mx8bf16_grouped/mx8mx8bf16_grouped_common.cuh

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,11 @@ at::Tensor mx8mx8bf16_grouped_impl(
6565
at::Tensor offsets) {
6666
c10::cuda::CUDAGuard deviceGuard(XQ.device());
6767
// The number of groups the kernel uses may vary.
68-
int kernel_groups = G;
68+
const int kernel_groups = G;
6969

7070
at::TensorOptions options;
7171
options = XQ.options();
7272

73-
// Return early if there are no elements in the output.
74-
if (output.numel() == 0) {
75-
return output;
76-
}
77-
7873
// WQ is shape (K,N) or (E,K,N) in column major layout, to align with
7974
// torch._scaled_grouped_mm. We transpose here to match cutlass kernel
8075
// requirements.

0 commit comments

Comments
 (0)