Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ __pycache__/

!.devcontainer/devcontainer.json
!.github/scripts/examples_config.json
!iris/ops/configs/*.json


resources/
Expand Down
5 changes: 4 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@ include LICENSE
include iris/README.md

# Include build configuration
include pyproject.toml
include pyproject.toml

# Include AG+MM auto-config JSON files
recursive-include iris/ops/configs *.json
19 changes: 19 additions & 0 deletions iris/ops/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@

from .config import FusedConfig
from .workspace import FusedWorkspace
from .auto_config import (
AutoConfigResult,
select_ag_mm_config,
list_known_shapes,
load_regression_sizes,
clear_config_cache,
detect_gpu_arch,
SUPPORTED_TRANSPOSES,
SUPPORTED_ARCHITECTURES,
)

# Import operations
# from .matmul import matmul # Simple single-GPU GEMM - TODO: implement
Expand Down Expand Up @@ -172,6 +182,15 @@ def matmul_reduce_scatter(self, output_tensor, A, B, bias=None, async_op=False,
# Configuration
"FusedConfig",
"FusedWorkspace",
# Auto-selection
"AutoConfigResult",
"select_ag_mm_config",
"list_known_shapes",
"load_regression_sizes",
"clear_config_cache",
"detect_gpu_arch",
"SUPPORTED_TRANSPOSES",
"SUPPORTED_ARCHITECTURES",
# Namespace
"OpsNamespace",
# Operations
Expand Down
40 changes: 36 additions & 4 deletions iris/ops/all_gather_matmul.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Comment on lines +174 to +176

Copilot AI Apr 14, 2026

Copy link

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 (typically M_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. Use M_auto = A_sharded.shape[0] * world_size_auto (or whatever the kernel’s actual gathered-M is) when calling select_ag_mm_config().

Suggested change
M_auto, K_local_auto = A_sharded.shape
K_auto, N_auto = B.shape
world_size_auto = shmem.get_num_ranks()
M_local_auto, K_local_auto = A_sharded.shape
K_auto, N_auto = B.shape
world_size_auto = shmem.get_num_ranks()
M_auto = M_local_auto * world_size_auto

Copilot uses AI. Check for mistakes.
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
Expand Down Expand Up @@ -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

Copilot AI Apr 14, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR description says ws<8 "automatically falls back to PyTorch", but the integration currently raises RuntimeError instead of performing a fallback. This is a user-visible behavior change and also contradicts the stated design. Either (mandatory) implement the actual PyTorch fallback here (and in all_gather_matmul_preamble), or (alternative) update the PR description/docs to clearly state that the fused path raises and the caller must explicitly choose the PyTorch path.

Copilot uses AI. Check for mistakes.
config = auto_result.to_fused_config()

M, K_local = A_sharded.shape
K, N = B.shape
Expand Down
Loading
Loading