Skip to content

modify the cu_seqlens_q_padded&cu_seqlens_k_padded acquisition way, add the parameter in python api - #1615

Merged
valarLip merged 7 commits into
mainfrom
mmd/fix/fwd_v3
Dec 16, 2025
Merged

valarLip merged 7 commits into
mainfrom
mmd/fix/fwd_v3

Conversation

@minmengdie

Copy link
Copy Markdown
Contributor

Motivation

  1. modify the cu_seqlens_q_padded&cu_seqlens_k_padded acquisition way in cpp api
  2. add the parameter in python api

Technical Details

Test Plan

python3 reproduce_loadpt.py
bash smoke_test_fwd_v3.sh

Test Result

image

Submission Checklist

Copilot AI left a 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.

Pull request overview

This PR refactors the handling of padded cumulative sequence length pointers in the FMHA (Fused Multi-Head Attention) v3 API. The key change is moving the cu_seqlens_q_padded and cu_seqlens_k_padded parameters from being passed as separate function arguments to being part of the mha_fwd_args structure, accessed via cu_seqlen_q_ptr and cu_seqlen_k_ptr fields.

Key Changes:

  • Removed seqstart_q_padding_ptr and seqstart_k_padding_ptr parameters from internal v3 dispatcher functions
  • Added cu_seqlens_q_padded and cu_seqlens_k_padded as optional parameters to Python API functions
  • Modified C++ implementation to retrieve padded pointers from the mha_fwd_args struct instead of separate function parameters

Reviewed changes

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

Show a summary per file
File Description
hsa/gfx950/fmha_v3_fwd/codegen.py Updated dispatcher function signatures to remove padding pointer parameters; modified argument assignment to use struct fields
hsa/gfx942/fmha_v3_fwd/codegen.py Updated dispatcher function signatures to remove padding pointer parameters; modified argument assignment to use struct fields
csrc/py_itfs_cu/asm_mha_varlen_fwd.cu Added cu_seqlens_q_padded and cu_seqlens_k_padded parameters to function signature and passed them to args construction
csrc/include/torch/mha_v3_varlen_fwd.h Added cu_seqlens_q_padded and cu_seqlens_k_padded parameters to function declaration
csrc/include/rocm_ops.hpp Added Python bindings for cu_seqlens_q_padded and cu_seqlens_k_padded parameters
csrc/include/mha_fwd.h Removed default parameters from fmha_fwd_v3 function declarations in gfx942 and gfx950 namespaces
csrc/cpp_itfs/mha_fwd_generate.py Updated v3 function call to remove padding pointer arguments
aiter/ops/mha.py Added cu_seqlens_q_padded and cu_seqlens_k_padded parameters to Python API; removed check that prevented using these parameters

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

Comment thread csrc/py_itfs_cu/asm_mha_varlen_fwd.cu Outdated
Comment thread csrc/py_itfs_cu/asm_mha_varlen_fwd.cu Outdated
Comment thread hsa/gfx942/fmha_v3_fwd/codegen.py Outdated
@minmengdie
minmengdie requested a review from wangye805 December 12, 2025 06:27
Comment thread hsa/gfx942/fmha_v3_fwd/codegen.py Outdated
Comment thread hsa/gfx950/fmha_v3_fwd/codegen.py Outdated
@minmengdie
minmengdie requested a review from valarLip December 16, 2025 01:37
@valarLip
valarLip merged commit 0aa43a4 into main Dec 16, 2025
28 of 30 checks passed
@valarLip
valarLip deleted the mmd/fix/fwd_v3 branch December 16, 2025 03:13
zhuyuhua-v pushed a commit that referenced this pull request Dec 17, 2025
…dd the parameter in python api (#1615)

* modify the cu_seqlens_q_padded cu_seqlens_k_padded

* fix

* fix the ck parameter

* delete the log

* exchange the ptr_qseq_padding and ptr_qseq

* batch mode not support padded
ZhangLirong-amd pushed a commit that referenced this pull request Dec 29, 2025
…dd the parameter in python api (#1615)

* modify the cu_seqlens_q_padded cu_seqlens_k_padded

* fix

* fix the ck parameter

* delete the log

* exchange the ptr_qseq_padding and ptr_qseq

* batch mode not support padded
valarLip pushed a commit that referenced this pull request Mar 18, 2026
…dd the parameter in python api (#1615)

* modify the cu_seqlens_q_padded cu_seqlens_k_padded

* fix

* fix the ck parameter

* delete the log

* exchange the ptr_qseq_padding and ptr_qseq

* batch mode not support padded
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