Skip to content

Fix known issues in mha cpp api#1966

Open
slippedJim wants to merge 1 commit intomainfrom
jim/dev/fix_mha_c_api
Open

Fix known issues in mha cpp api#1966
slippedJim wants to merge 1 commit intomainfrom
jim/dev/fix_mha_c_api

Conversation

@slippedJim
Copy link
Contributor

Motivation

Technical Details

Test Plan

Test Result

Submission Checklist

@slippedJim slippedJim requested review from a team and Copilot February 4, 2026 06:02
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes known issues in the MHA (Multi-Head Attention) C++ API by updating a deprecated function call and improving dimension padding logic.

Changes:

  • Updated copyright year to 2026
  • Replaced deprecated composes function with make_composes
  • Refactored dimension padding logic to remove assertions and handle mismatched dimensions gracefully

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
op_tests/cpp/mha/benchmark_mha_fwd.cpp Updated copyright year and replaced deprecated composes function with make_composes
csrc/cpp_itfs/mha_bwd.cu Removed assertions and added conditional logic to handle dimension padding cases

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

return std::make_tuple(hdim_q, hdim_v);
assert(hdim_q == hdim_v);
if(hdim_q <= 64)
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

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

This line contains only whitespace. Remove the trailing whitespace for cleaner code formatting.

Suggested change

Copilot uses AI. Check for mistakes.
}

assert(false);
return std::make_tuple(hdim_q, hdim_v);
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

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

When hdim_q != hdim_v and the special case (hdim_q == 192 && hdim_v == 128) is not met, the function returns unpadded dimensions without any validation or error handling. This silently allows unsupported dimension combinations to proceed, which could lead to runtime errors. Consider adding validation or error handling for unsupported dimension pairs.

Copilot uses AI. Check for mistakes.
@slippedJim slippedJim requested review from a team and wangye805 February 5, 2026 02:55
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.

2 participants