[AMD] Use exact CU share for gfx950 segment-plan headroom (#39503)
Co-authored-by: jacky.cheng <yichiche@amd.com>
This commit is contained in:
@@ -323,9 +323,24 @@ def _seg_plan_target_wgs() -> int:
|
||||
return _SEG_PLAN_TARGET_WGS
|
||||
|
||||
|
||||
def mtp_verify_attn_seg_max(num_seqs: int, num_kv_heads: int) -> int:
|
||||
"""Static grid.x for the planned split: 2x the legacy per-seq count, clamped to 16..64."""
|
||||
return max(16, min(64, 2 * mtp_verify_attn_num_segments(num_seqs, num_kv_heads)))
|
||||
def mtp_verify_attn_seg_max(
|
||||
num_seqs: int, num_kv_heads: int, num_cus: int | None = None
|
||||
) -> int:
|
||||
"""Static grid.x for the planned split: 2x the exact equal-share CU budget,
|
||||
clamped to 16..64.
|
||||
|
||||
Unlike mtp_verify_attn_num_segments (the legacy fixed split), the share is
|
||||
not rounded down to a power of two: that quantization costs a long request
|
||||
in a skewed batch half its headroom at every batch discontinuity, while the
|
||||
planner's own workgroup budget already prevents oversubscription.
|
||||
|
||||
num_cus defaults to the device count; pass it to keep the cap independent of
|
||||
the current device (a CPX partition exposes 32 of an MI355X's 256).
|
||||
"""
|
||||
if num_cus is None:
|
||||
num_cus = _seg_plan_target_wgs()
|
||||
uniform_share = max(1, num_cus // max(1, num_seqs * num_kv_heads))
|
||||
return max(16, min(64, 2 * uniform_share))
|
||||
|
||||
|
||||
def _get_plan_kernel():
|
||||
|
||||
Reference in New Issue
Block a user