Skip to content

Conversation

@kabrahamAMD
Copy link
Contributor

@kabrahamAMD kabrahamAMD commented Jan 16, 2026

This PR adds reflection for wmma fwd as well as xdl and wmma bwd_weight kernels to the ck builder

To allow reflection of bwd weight kernels, several std::optional parameters were added to conv_traits.hpp. These include:

  • gemm_padding: previously existing parameter made optional as not all kernels have this parameter
  • num_gemm_k_prefetch_stage: added

@Snektron Snektron changed the title [CK Builder] Add reflection for wmma and bwd weight instances to ck builder reflection [CK_BUILDER] Add reflection for wmma and bwd weight instances to ck builder reflection Jan 16, 2026
@shumway
Copy link
Collaborator

shumway commented Jan 16, 2026

It's a lot easer to get comments on a draft if you can explain the what and why in your draft PR description. 😜 I think I can see what you are doing here, but generally introduce what the PR is doing and what you want feedback on.

builder::ElementwiseOperation output_element_op;

builder::GemmPadding gemm_padding;
std::optional<builder::GemmPadding> gemm_padding = std::nullopt;
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is really good, and you should lead your PR description with this change to ConvTraits (the "what" of the PR), as well as why we are making these optional now (the "why"). One question I have is where we should use std::optional versus using std::variant.

That's the design discussion we should focus on: how should ConvTraits be generalized for backward weights. This PR should update code comments and our relect/README.md file so that everyone understands this important generalization.

/// @brief Helper function to report unsupported layout combinations with a clear error message.
/// @details This consteval function uses throw (not static_assert) to ensure the error is not
/// silently ignored during SFINAE. The thrown string becomes part of the compiler error message.
/// @details This consteval function is designed to fail at compile time with a descriptive
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's leave the longer description. This may be obvious to you, but the fact this gets around SFINEA is an important detail. It's kind of a weird pattern, I think, and consteval throw is a new C++20 technique. I like your simplification of the comment, but I don't know how well most of our developers understand this pattern. Just a suggestion. What do you think?

/// @brief Derives the data type from a device kernel `Instance` type.
/// Returns a `builder::DataType` enum value (e.g., FP16, BF16, FP32, BF8).
// Note: maybe move to types.hpp?
template <typename DataTypeFromInstance>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks for deleting this redundant comment noise! I meant to shorten this comment. Also, feel free to remove the doxgen-specific markup in these comments.


#pragma once

// Fwd instances
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm trying to decide if we need this instance_to_conv_traits.hpp file. I left it in as part of the refactoring, but it may be that we can always use the specific includes. I worry some about files like this leading to longer compile times. Let me know your thoughts on this, and I'll consider this for my next refactoring and cleanup.

@shumway
Copy link
Collaborator

shumway commented Jan 16, 2026

What I've read so far looks really good. My two suggestions for the PR description:

  1. Lead with an description about adding std::optional fields to ConvTraits to generalize to backwards weights. Should we consider std::variant for some of this? Conceptually, how are ConvTriats different for forward and backward convolutions. Does it make sense to have one conv traits for forward and backwards, or would FwdConvTraits and BwdWeiConvTraits be better. (I think one ConvTraits is better, but you should document that design choice.
  2. Summarize the changes to the conv traits helpers. We will likely do more cleanup and refactoring there, and capturing some of your ideas in the PR description will help us with future work.

@kabrahamAMD kabrahamAMD force-pushed the kabraham/builder_bwd_reflection branch from 8936a15 to 71df5c5 Compare January 20, 2026 12:05
@kabrahamAMD kabrahamAMD marked this pull request as ready for review January 20, 2026 12:30
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