Skip to content

Conversation

@pabloantoniom
Copy link
Contributor

@pabloantoniom pabloantoniom commented Dec 24, 2025

Motivation

Technical Details

This PR makes either arch or mhal.arch attributes mandatory on any kernel. If none are present, lowering will fail

1. Problems

Problem 1

Tests where gemm features do not match arch features

Solution: TODO

Problem 2

We use features to specify that a rock.gemm is accel / not accel, but if we are removing gemmfeatures, we lose that ability.

Solution (2 possibilities):

  1. Add a new attribute to rock.gemm to indicate if is accel / non-accel (explicit in the IR)
  2. Use isAccel(aType, bType) to infer, based on the arch and types, if the rock.gemm is accel / non-accel (implicit in the IR).

Problem 3

The rocmlir-gen flags that modify the features (now we are getting the features from the arch, so the options do not make sense anymore)

Solution: TODO

TODOs

  • Make GemmFeatures an AmdArchDb internal enum and not available in the IR
  • Do we want to keep arch in gemm features? If not, make sure to remove all in the tests
  • There is a mistmach between which mixed types are supported for accel in rocmlir-gen and in WmmaInsGroup.cpp/MfmaInsnGroup.cpp. The former disallows any mixed types, where the later allows for certain combinations. Should we update rocmlir-gen to make this consistent?

2. Changes to tests:

All changes under mlir/tests can be identified in 3 categories:

  1. Dont use -mfma / -wmma in rocmlir-gen
  2. Add arch attributes
  3. Set the right arch to match the features

Test Plan

Test Result

Submission Checklist

GemmFeatures getDefaultFeatures(Type dataType);

/// Get the default features for multiple types (intersects features)
GemmFeatures getDefaultFeatures(ArrayRef<Type> types);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought the idea was to get rid of GemmFeatures? At least that's what I think the end goal should be. Isn't it possible to remove GemmFeatures completely in this PR?

bool hasAtomicAdd(Type dataType);

/// Check if f16 atomic add is supported (arch-only)
bool hasAtomicAddF16() const;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: hasAtomicAdd(Type) instead of three similar functions.

bool isMfma(Type dataTypeA, Type dataTypeB);

/// Check if wmma is supported for given types
bool isWmma(Type dataTypeA, Type dataTypeB);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we do isAccel() instead of isMfma/isWmma?

bool isWmma(Type dataTypeA, Type dataTypeB);

/// Check if direct-to-LDS is supported for given type and numBytes
bool isDirectToLDS(Type dataType, int64_t numBytes = 0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't the dataType enough? why do we need numBytes?

assert(config.operation.value() == ConvOpType::BwdWeight);

kernelCount = 1;
if (isAccel(config.features)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we remove isAccel()?

return false;

// Then check type supports direct-to-LDS
return isDirectToLDS(dataType, numBytes);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we support (or want to support?) async direct to LDS for 64/8/16 as well?

return isDirectToLDS(dataType, numBytes);
}

bool mlir::rock::AmdArchInfo::hasDot() const {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dot is not used anywhere AFAIK, we can get rid of it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants