|
24 | 24 | from .tritonblas_launch_wave_schedule import build_launch_wave_plan |
25 | 25 |
|
26 | 26 |
|
| 27 | +_MAX_ONE_SHOT_INBOX_ELEMENTS = 2**31 |
| 28 | + |
| 29 | + |
27 | 30 | @triton.jit() |
28 | 31 | def _partitioned_xcd_matmul_kernel( |
29 | 32 | A, |
@@ -423,6 +426,16 @@ def _ceil_div(value: int, divisor: int) -> int: |
423 | 426 | return (value + divisor - 1) // divisor |
424 | 427 |
|
425 | 428 |
|
| 429 | +def _validate_one_shot_inbox_size(M: int, N: int, world_size: int): |
| 430 | + inbox_elements = world_size * M * N |
| 431 | + if inbox_elements > _MAX_ONE_SHOT_INBOX_ELEMENTS: |
| 432 | + raise ValueError( |
| 433 | + "matmul_all_reduce_copy_engine one_shot requires world_size * M * N <= 2**31 elements " |
| 434 | + "because the current local-reduce kernels use 32-bit element offsets; " |
| 435 | + f"got world_size={world_size}, M={M}, N={N}, elements={inbox_elements}." |
| 436 | + ) |
| 437 | + |
| 438 | + |
426 | 439 | def _partitioned_xcd_gemm_num_sms(launch: dict, world_size: int) -> int: |
427 | 440 | cached = launch.get("gemm_num_sms") |
428 | 441 | if cached is not None: |
@@ -916,9 +929,11 @@ def matmul_all_reduce_copy_engine_preamble( |
916 | 929 | dtype = A.dtype |
917 | 930 | world_size = shmem.get_num_ranks() |
918 | 931 |
|
919 | | - # Validate config |
920 | 932 | config.validate(world_size=world_size) |
921 | 933 |
|
| 934 | + if config.all_reduce_variant == "one_shot": |
| 935 | + _validate_one_shot_inbox_size(M, N, world_size) |
| 936 | + |
922 | 937 | if config.all_reduce_variant == "two_shot" and M % world_size != 0: |
923 | 938 | raise ValueError( |
924 | 939 | "matmul_all_reduce_copy_engine two_shot requires M to be divisible by world_size " |
@@ -1047,6 +1062,9 @@ def matmul_all_reduce_copy_engine( |
1047 | 1062 |
|
1048 | 1063 | config.validate(world_size=world_size) |
1049 | 1064 |
|
| 1065 | + if config.all_reduce_variant == "one_shot": |
| 1066 | + _validate_one_shot_inbox_size(M, N, world_size) |
| 1067 | + |
1050 | 1068 | # Prepare workspace if needed |
1051 | 1069 | if workspace is None: |
1052 | 1070 | workspace = matmul_all_reduce_copy_engine_preamble( |
|
0 commit comments