[Perf][PCP] Shard decode requests across PCP ranks (#52162)

Signed-off-by: QiuChunshuo <qiuchunshuo@huawei.com>
Co-authored-by: Lucas Wilkinson <LucasWilkinson@users.noreply.github.com>
This commit is contained in:
Qiu Chunshuo
2026-10-01 23:50:13 -04:00
committed by GitHub
co-authored by Lucas Wilkinson
parent a810316c08
commit 8486f1ebfe
13 changed files with 406 additions and 33 deletions
@@ -489,6 +489,14 @@ class FlashMLASparseMetadataBuilder(
num_tokens - metadata.num_decode_tokens,
)
FP8Meta = FlashMLASparseMetadata.FP8SeparatePrefillDecode
# PCP decode sharding can leave a rank with only its collective-padding
# row when the global decode batch is smaller than the PCP world size.
# The row has no actual query tokens and must not be interpreted as a
# zero-length decode request by the sparse FP8 metadata builder.
if num_tokens == 0:
return FP8Meta()
decode_query_len = 0
active_num_decodes = num_decodes
if num_decodes > 0:
@@ -498,7 +506,6 @@ class FlashMLASparseMetadataBuilder(
active_num_decodes = num_decode_tokens // decode_query_len
assert active_num_decodes * decode_query_len == num_decode_tokens
FP8Meta = FlashMLASparseMetadata.FP8SeparatePrefillDecode
fp8_metadata = FP8Meta(
num_decodes=active_num_decodes,
num_prefills=num_prefills,