Skip to content

TF32 POC in Conv3d on MI30x platform#2763

Merged
yingluAMD merged 1 commit into
ROCm:developfrom
yingluAMD:xf32_0814
Sep 15, 2025
Merged

TF32 POC in Conv3d on MI30x platform#2763
yingluAMD merged 1 commit into
ROCm:developfrom
yingluAMD:xf32_0814

Conversation

@yingluAMD
Copy link
Copy Markdown
Contributor

@yingluAMD yingluAMD commented Sep 1, 2025

Proposed changes

Demonstrate TF32(XF32 in CDNA3 ISA) kernel in conv3d. Also add lots of instances for miopen.

Checklist

Please put an x into the boxes that apply. You can also fill these out after creating the PR. If you're not sure, please don't hesitate to ask.

  • I have added tests relevant to the introduced functionality, and the unit tests are passing locally
  • I have added the test to REGRESSION_TESTS list defined at the top of CMakeLists.txt in tests/CMakeLists.txt, IF the test takes more than 30 seconds to run.
  • I have added inline documentation which enables the maintainers with understanding the motivation
  • I have removed the stale documentation which is no longer relevant after this pull request
  • (If this change is user-facing) I have added release notes which provide the end users with a brief summary of the improvement from this pull request
  • I have run clang-format on all changed files
  • Any dependent changes have been merged

Discussion

If this is a relatively large or complex change, feel free to start a discussion by explaining why you chose the solution you did and what alternatives you considered

Comment thread example/01_gemm/gemm_xdl_lds_direct_load_fp32_tf32.cpp
Comment thread .gitignore
@@ -70,4 +70,3 @@ build*/
__pycache__/

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Missclick?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes. It seems a space is auto deleted by VSCode. Will try to recover it.

Comment thread example/01_gemm/common.hpp Outdated
}

template <typename DataType>
template <typename DataType, typename GemmType = DataType>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you change it to ComputeType to keep naming convention?

Copy link
Copy Markdown
Contributor Author

@yingluAMD yingluAMD Sep 6, 2025

Choose a reason for hiding this comment

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

Sure. Use ComputeDataType to align with device_gemm_xdl_cshuffle_lds_direct_load.hpp#L61

Comment thread example/01_gemm/run_gemm_example.inc Outdated

// use macro to minimize code change
#ifndef EXAMPLE_WITH_GEMM_DATATYPE
using GemmDataType = AccDataType;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ComputeType

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

}

template <typename DataType>
template <typename DataType, typename GemmType = DataType>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Compute Type

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

Comment on lines +7 to +9
#ifndef EXAMPLE_WITH_GEMM_DATATYPE
using GemmDataType = AccDataType;
#endif
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ComputeDataType

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

typename CElementwiseOperation,
typename ComputeTypeA = CDataType,
typename ComputeTypeB = ComputeTypeA>
typename ComputeTypeA = CDataType,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

adatatype

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ok.

typename DsLayout,
typename ELayout,
ConvolutionForwardSpecialization ConvSpec>
using device_grouped_conv_fwd_xdl_dynamic_op_f32_tf32_instances = std::tuple<
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We probably dont need dynamic op instances since it has not been integrated with MIOpen

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ok

add_device_grouped_conv3d_fwd_xdl_ngcdhw_gkczyx_ngkdhw_f32_mem_inter_instances(
op_ptrs);
}
if constexpr(is_same_v<InDataType, float> && is_same_v<WeiDataType, float> &&
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we need something like CK_ENABLE_TF32?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

CK API use different template params ComputeDataTypeA/B to distinguish tf32 or fp32 compute. No incorrect usage will occur.
While MIOpen use MIOPEN_TF32_OVERRIDE (vs NVIDIA_TF32_OVERRIDE) to disable TF32 mode which means MIOpen will select different CK kernel. That should be enough.

namespace ck {
namespace tensor_operation {
namespace device {
namespace instance {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Plese dont extend gndhwc layout since it is not used widely

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ok

@yingluAMD yingluAMD requested review from bartekxk and linqun September 8, 2025 02:00
Copy link
Copy Markdown
Contributor

@linqun linqun left a comment

Choose a reason for hiding this comment

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

looks good to me.

@yingluAMD yingluAMD force-pushed the xf32_0814 branch 2 times, most recently from 4c9b427 to f986e71 Compare September 11, 2025 03:20
@illsilin illsilin requested a review from aska-0096 as a code owner September 12, 2025 02:59
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Here a/b_thread_buf define in which format data stored in the register, wondering if define TF32 in register will introduce type convert overhead instead of cutting-off by MFMA instruction. Have you checked the dumped ISA?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Checked on ISA and other public docs. FP32 is automatically trucked to TF32 in matrix core. Explicit data convert is not needed. We can refer to Nvidia TF32 introduction also(Link) which use a picture show the workflow.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Here we define the data in a_block_buf is FloatA and in a_thread_buf is ElementDataTypeA, is type convert overhead introduced?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Okay.. ElementDataTypeA still float here, tf32 only used to select the correct tf32 mfma

@aska-0096
Copy link
Copy Markdown
Contributor

aska-0096 commented Sep 12, 2025

it looks good me. It fix/enable several tf32 infra in ck, while implement a kernel with f32 input and tf32 computation to benefit the higher math rate. Let's wait CI pass and @bartekxk 's review resolved

Copy link
Copy Markdown
Contributor

@bartekxk bartekxk left a comment

Choose a reason for hiding this comment

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

LGTM , just one last comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pls Dont print any message without:
if(ck::EnvIsEnabled(CK_ENV(CK_LOGGING)))

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed. Add if(ck::EnvIsEnabled(CK_ENV(CK_LOGGING))) before print error message.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You missed this place

@yingluAMD yingluAMD merged commit c511021 into ROCm:develop Sep 15, 2025
41 of 46 checks passed
illsilin added a commit that referenced this pull request Sep 15, 2025
illsilin added a commit that referenced this pull request Sep 15, 2025
yingluAMD added a commit that referenced this pull request Sep 16, 2025
illsilin pushed a commit that referenced this pull request Sep 17, 2025
* Revert "Revert "feature:tf32:add initial conv3d fwd kernel support (#2763)" (#2848)"

This reverts commit 03b59f8.

* fix compile error on gf12x

* only run tf32 example on gfx942

* only build tf32 instance on gfx942

* ckProfiler:only support tf32 in gfx942

* delete unuseful messages
AviralGoelAMD pushed a commit that referenced this pull request Oct 16, 2025
* Revert "Revert "feature:tf32:add initial conv3d fwd kernel support (#2763)" (#2848)"

This reverts commit 03b59f8.

* fix compile error on gf12x

* only run tf32 example on gfx942

* only build tf32 instance on gfx942

* ckProfiler:only support tf32 in gfx942

* delete unuseful messages
yingluAMD added a commit to ROCm/rocm-libraries that referenced this pull request Nov 16, 2025
## Motivation

gfx942 series support TF32 in matrix core natively. While TF32 is not supported in MIOpen now. This PR is a POC of enabling TF32.

## Technical Details

All kernel is changed in CK(PR:[2763](ROCm/composable_kernel#2763)). Below
are the changes in miopen:
- Change problem and kernel instance invoker to invoker TF32 kernel in
CK.
- Add environment to control whether use TF32.
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.

4 participants