-
Notifications
You must be signed in to change notification settings - Fork 281
MI350 mla ps mode suppport nhead128,1 128,2 128,3 128,4 64,4 64,2 32,4 through kernel hsa/gfx950/mla/mla_a16w16_qh32_qseqlen4_gqaratio32_ps.co #2727
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -464,7 +464,8 @@ void get_mla_metadata_v1_2_device(const torch::Tensor& seqlens_qo_indptr, // [ba | |||||||||||
| ((arch_id == "gfx950") && (num_heads == 32) && q_is_fp8 && kv_is_fp8 && | ||||||||||||
| (max_seqlen_qo == 4)) || | ||||||||||||
| ((arch_id == "gfx950") && (num_heads == 64) && q_is_fp8 && kv_is_fp8 && | ||||||||||||
| (max_seqlen_qo == 1)) || | ||||||||||||
| (max_seqlen_qo == 1)) || | ||||||||||||
| ((arch_id == "gfx950") && ((num_heads * max_seqlen_qo) % 128 == 0) && !q_is_fp8 && !kv_is_fp8) || | ||||||||||||
| ((arch_id == "gfx942") && (num_heads == 128) && q_is_fp8 && kv_is_fp8); | ||||||||||||
|
|
||||||||||||
| const bool use_qseqlen_fold = | ||||||||||||
|
|
@@ -493,7 +494,8 @@ void get_mla_metadata_v1_2_device(const torch::Tensor& seqlens_qo_indptr, // [ba | |||||||||||
| TORCH_CHECK((num_heads == 16) || (num_heads == 128) || | ||||||||||||
| ((num_heads == 32) && q_is_fp8 && kv_is_fp8) || | ||||||||||||
| ((num_heads == 64) && q_is_fp8 && kv_is_fp8 && (max_seqlen_qo == 1)) || | ||||||||||||
| ((num_heads == 8) && (max_seqlen_qo == 4) && q_is_fp8 && kv_is_fp8), | ||||||||||||
| ((num_heads == 8) && (max_seqlen_qo == 4) && q_is_fp8 && kv_is_fp8) || | ||||||||||||
| ((arch_id == "gfx950") && ((num_heads * max_seqlen_qo) % 128 == 0) && !q_is_fp8 && !kv_is_fp8), | ||||||||||||
| __func__, | ||||||||||||
| ": only supports #heads in [16, 64, 128], or (#head, uni_seqlen_qo) = (16*N, 1) where " | ||||||||||||
| "N is in [2, 8), or (#head, max_seqlen_qo) = (8, 4) where q and kv are fp8.") | ||||||||||||
|
Comment on lines
500
to
501
|
||||||||||||
| ": only supports #heads in [16, 64, 128], or (#head, uni_seqlen_qo) = (16*N, 1) where " | |
| "N is in [2, 8), or (#head, max_seqlen_qo) = (8, 4) where q and kv are fp8.") | |
| ": only supports #heads in [16, 128], or (#head, uni_seqlen_qo) = (16*N, 1) where " | |
| "N is in [2, 8) and q and kv are fp8, or (#head, max_seqlen_qo) = (8, 4) where q and kv " | |
| "are fp8, or on gfx950 with non-fp8 q/kv when (#head * max_seqlen_qo) % 128 == 0.") |
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -146,7 +146,7 @@ void mla_decode_stage1_asm_fwd( | |||
| args.scalar = softmax_scale; | ||||
| args.s_MQA = gqa_ratio * max_seqlen_q; | ||||
| args.s_kv_split = kv_split; | ||||
| args.s_Q_Bs = stride_Q; | ||||
| args.s_Q_Bs = stride_Q; | ||||
| args.s_Bs = stride_Page; | ||||
| args.s_log2_plen = log2_page; | ||||
| args.out_16_nosplit = kv_split; | ||||
|
|
@@ -260,12 +260,13 @@ void mla_decode_stage1_asm_fwd( | |||
| int prefill = 0; // decode stage | ||||
| int causal = 0; | ||||
| int config_max_seqlen_q = max_seqlen_q; | ||||
| int config_gqa_ratio = gqa_ratio; | ||||
| int sub_Q = 128; // default value | ||||
|
|
||||
| if(gqa_ratio == 128){ | ||||
| config_max_seqlen_q = 0; | ||||
| sub_Q = 128; | ||||
| if (q_type == "bf16" && kv_type == "bf16"){ | ||||
| if (q_type == "bf16" && kv_type == "bf16" && arch_id == "gfx942"){ | ||||
| ps = 0; // not use ps | ||||
| } | ||||
| } | ||||
|
|
@@ -338,9 +339,14 @@ void mla_decode_stage1_asm_fwd( | |||
| } | ||||
| } | ||||
|
|
||||
| if (arch_id == "gfx950" && q_type == "bf16" && kv_type == "bf16" && persistent && (gqa_ratio* max_seqlen_q % 128 == 0)){ | ||||
| config_max_seqlen_q = 4; | ||||
| config_gqa_ratio = 32; | ||||
| args.s_Q_Bs = gqa_ratio; | ||||
|
||||
| args.s_Q_Bs = gqa_ratio; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is trailing whitespace after the closing parenthesis on this line. This will cause
blackto reformat the file and fail the formatting check in CI; please remove the trailing spaces (or run black on the file).