tuned moe config #4287
Open
amd-hhashemi wants to merge 4 commits into
Open
Conversation
Contributor
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates gfx1250 (Gluon/TDM) kernel tuning and memory-load behavior to improve MoE GEMM configuration selection and adjust TDM async-load caching behavior.
Changes:
- Added a shape/bucket-based tuned config table for
get_kernel_config_gluon()in the MoE A8W4 path. - Updated the Gluon MoE config heuristic logic (block sizes / buffer counts) used when a tuned entry is not found.
- Adjusted gfx1250 batched BF16 GEMM TDM pipeline loads to apply a cache modifier to B-tensor loads.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| aiter/ops/triton/moe/moe_op_gemm_a8w4.py | Introduces a tuned-config lookup + revised heuristic for Gluon MoE GEMM kernel configuration selection. |
| aiter/ops/triton/_gluon_kernels/gfx1250/gemm/batched/batched_gemm_bf16.py | Changes TDM async-load ordering and applies a cache modifier for B loads in the pipeline. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+349
to
+354
| if k <= 512: | ||
| block_k = 256 | ||
| elif k <= 1024: | ||
| block_k = 512 if k % 512 == 0 else 256 | ||
| else: | ||
| block_k = 512 |
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
aiter/ops/triton/moe/moe_op_gemm_a8w4.py:357
- In the heuristic fallback for gfx1250/gluon (block_m==16),
block_kis reduced untilblock_kreaches 32, but the loop can still exit withk % block_k != 0. The gfx1250 gluon kernel uses TDM async_load withblock_shape=(BLOCK_M, BLOCK_K)and no tail masking, so a non-divisible K risks out-of-bounds reads or incorrect accumulation. Add an explicit guard after the loop (or an earlyk % 32 == 0check) to fail fast on unsupported K shapes.
if k <= 512:
block_k = 256
elif k <= 1024:
block_k = 512 if k % 512 == 0 else 256
else:
block_k = 512
while block_k > 32 and k % block_k != 0:
block_k //= 2
Comment on lines
+246
to
+276
| _GLUON_TUNED_CONFIGS = { | ||
| # block_n block_k num_buffers | ||
| # --- K=384 (down-proj, inter_dim=384) --- | ||
| (16, 7168, 384, "tiny"): (64, 128, 3), | ||
| (16, 7168, 384, "small"): (64, 128, 3), | ||
| (16, 7168, 384, "medium"): (64, 128, 3), | ||
| (16, 7168, 384, "medium2"): (128, 128, 3), | ||
| (16, 7168, 384, "large"): (256, 128, 1), | ||
| (16, 7168, 384, "xlarge"): (256, 128, 2), | ||
| # --- K=512 (down-proj, inter_dim=512) --- | ||
| (16, 7168, 512, "tiny"): (64, 256, 3), | ||
| (16, 7168, 512, "small"): (512, 512, 2), | ||
| (16, 7168, 512, "medium"): (512, 256, 2), | ||
| (16, 7168, 512, "medium2"): (512, 512, 1), | ||
| (16, 7168, 512, "large"): (512, 256, 1), | ||
| (16, 7168, 512, "xlarge"): (512, 512, 1), | ||
| # --- K=768 (down-proj, inter_dim=768) --- | ||
| (16, 7168, 768, "tiny"): (64, 256, 3), | ||
| (16, 7168, 768, "small"): (64, 256, 3), | ||
| (16, 7168, 768, "medium"): (512, 256, 2), | ||
| (16, 7168, 768, "medium2"): (512, 256, 2), | ||
| (16, 7168, 768, "large"): (512, 256, 1), | ||
| (16, 7168, 768, "xlarge"): (512, 256, 2), | ||
| # --- K=1536 (down-proj, inter_dim=1536) --- | ||
| (16, 7168, 1536, "tiny"): (256, 512, 2), | ||
| (16, 7168, 1536, "small"): (512, 512, 2), | ||
| (16, 7168, 1536, "medium"): (128, 512, 2), | ||
| (16, 7168, 1536, "medium2"): (512, 512, 1), | ||
| (16, 7168, 1536, "large"): (256, 256, 2), | ||
| (16, 7168, 1536, "xlarge"): (512, 256, 2), | ||
| # --- K=2048 (down-proj, inter_dim=2048) --- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Speedups from tuning (last column):