-
Notifications
You must be signed in to change notification settings - Fork 47
Add auto-config selection for fused AG+matmul with 28 tuned HBM buffer configs #506
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
Changes from all 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 |
|---|---|---|
|
|
@@ -164,9 +164,22 @@ def all_gather_matmul_preamble( | |
| B: torch.Tensor, | ||
| config: Optional[FusedConfig] = None, | ||
| ) -> FusedWorkspace: | ||
| """Allocate workspace for all_gather_matmul (none needed for pull pattern).""" | ||
| """Allocate workspace for all_gather_matmul (none needed for pull pattern). | ||
|
|
||
| When config=None, uses auto-selection to pick the best known configuration. | ||
| """ | ||
| if config is None: | ||
| config = FusedConfig() | ||
| from .auto_config import select_ag_mm_config | ||
|
|
||
| M_auto, K_local_auto = A_sharded.shape | ||
| K_auto, N_auto = B.shape | ||
| world_size_auto = shmem.get_num_ranks() | ||
| auto_result = select_ag_mm_config(M_auto, N_auto, K_auto, world_size=world_size_auto) | ||
| if not auto_result.enabled: | ||
| raise RuntimeError( | ||
| f"iris AG+MM auto-config disabled: {auto_result.source}. Pass config=FusedConfig(...) to override." | ||
| ) | ||
| config = auto_result.to_fused_config() | ||
|
|
||
| M, K_local = A_sharded.shape | ||
| K, N = B.shape | ||
|
|
@@ -194,9 +207,28 @@ def all_gather_matmul( | |
| config: Optional[FusedConfig] = None, | ||
| workspace: Optional[FusedWorkspace] = None, | ||
| ) -> FusedWorkspace: | ||
| """Fused all-gather and matrix multiplication using pull pattern.""" | ||
| """Fused all-gather and matrix multiplication using pull pattern. | ||
|
|
||
| When config=None, uses auto-selection to pick the best known configuration | ||
| for the given (M, N, K, world_size) on the current GPU. If the auto-config | ||
| disables iris for this combination (e.g., ws<8 on MI300X), raises RuntimeError | ||
| advising fallback to PyTorch. To bypass auto-selection, pass an explicit | ||
| FusedConfig instance. | ||
| """ | ||
| if config is None: | ||
| config = FusedConfig() | ||
| from .auto_config import select_ag_mm_config | ||
|
|
||
| M_auto, K_local_auto = A_sharded.shape | ||
| K_auto, N_auto = B.shape | ||
| world_size_auto = shmem.get_num_ranks() | ||
| auto_result = select_ag_mm_config(M_auto, N_auto, K_auto, world_size=world_size_auto) | ||
| if not auto_result.enabled: | ||
| raise RuntimeError( | ||
| f"iris AG+MM auto-config disabled for this shape/world_size: " | ||
| f"{auto_result.source}. Pass config=FusedConfig(...) to override, " | ||
| f"or use PyTorch all_gather + matmul instead." | ||
| ) | ||
|
Comment on lines
+225
to
+230
|
||
| config = auto_result.to_fused_config() | ||
|
|
||
| M, K_local = A_sharded.shape | ||
| K, N = B.shape | ||
|
|
||
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.
Auto-config is being selected using the local M from
A_sharded.shape[0], but the config convention/tests treat M as the post-allgather (global) M (typicallyM_local * world_size). This will systematically pick the wrong champion/heuristic branch (e.g., bm=128 vs 256) and can materially degrade performance or select incompatible params. UseM_auto = A_sharded.shape[0] * world_size_auto(or whatever the kernel’s actual gathered-M is) when callingselect_ag_mm_config().