Skip to content

Commit

Permalink
Fix not enabling fp8 WMMA on Navi4 by default (#1677)
Browse files Browse the repository at this point in the history
Fix not enabling WMMA on Navi4 by default

getDefaultFeatures() in the architecture database hadn't been told
that sometimes there's a fp8 WMMA, so it wasn't sending those
operations down that path.

This commit fixes the issue and tests that enablement.
  • Loading branch information
krzysz00 authored Oct 9, 2024
1 parent a1f9fe1 commit 82378ac
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
6 changes: 4 additions & 2 deletions mlir/lib/Dialect/Rock/utility/AmdArchDb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,10 @@ GemmFeatures mlir::rock::AmdArchInfo::getDefaultFeatures(Type dataType) {
bool isWmma = bitEnumContainsAll(theseFeatures, GemmFeatures::wmma);
Type elementType = getElementTypeOrSelf(dataType);
if (isWmma) {
if (!elementType.isF16() && !elementType.isBF16() &&
!elementType.isInteger(8)) {
if (!(isa<Float16Type, BFloat16Type>(elementType) ||
elementType.isInteger(8) ||
(hasFp8ConversionInstrs &&
isa<Float8E5M2Type, Float8E4M3FNType>(elementType)))) {
theseFeatures = bitEnumClear(theseFeatures, GemmFeatures::wmma);
}
}
Expand Down
12 changes: 12 additions & 0 deletions mlir/test/rocmlir-gen/wmma-enablement.mlir
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// RUN: rocmlir-gen --arch gfx1201 --operation gemm --operation gemm -wmma infer -t f16 -p | grep '|wmma' | count 1
// RUN: rocmlir-gen --arch gfx1201 --operation gemm -wmma infer -t fp8_fp8 -p | grep '|wmma' | count 1
// RUN: rocmlir-gen --arch gfx1201 --operation gemm -wmma infer -t bf8_bf8 -p | grep '|wmma' | count 1
// RUN: rocmlir-gen --arch gfx1201 --operation gemm -wmma infer -t fp8_fp8 -force-f8-types=fnuz -p | not grep '|wmma'

// RUN: rocmlir-gen --arch gfx1100 --operation gemm -wmma infer -t f16 -p | grep '|wmma' | count 1
// RUN: rocmlir-gen --arch gfx1100 --operation gemm -wmma infer -t fp8_fp8 -p | not grep '|wmma'

// YES: rock.gemm
// YES-SAME: features = {{[^ ]*}}wmma
// NO: rock.gemm
// NO-NOT: wmma

0 comments on commit 82378ac

Please sign in to comment.