Conversation
b1dde07 to
ec27092
Compare
Add JSON-based config files to store tuned block_num/warp_per_block for dispatch and combine kernels. Benchmark scripts can auto-save tuning results; runtime loads config based on GPU arch, kernel type, EP size, and matches by dtype + hidden_dim + num_tokens. New files: tuning_config.py, batch tuning scripts, sample JSON.
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.
Motivation
The current EP dispatch/combine kernel launch parameters (block_num, warp_per_block, rdma_block_num) are either hardcoded or manually configured via environment variables. Different GPU architectures, EP sizes, token counts, and hidden dimensions require different optimal parameters. This PR adds an automated tuning config system that stores benchmark-derived optimal parameters in JSON files and loads them at runtime.
Technical Details
python/mori/ops/tuning_config.py: unified dtype registry, JSON config loader with validation/caching, runtime lookup (exact match on dtype + hidden_dim, ceiling match on num_tokens), and atomic save with keep-best merge strategy.{gpu_arch}_{kernel_type}_ep{ep_size}[_{quant}].json, containing separatedispatch_rulesandcombine_ruleslists to support independent dtypes (e.g., dispatch fp4 + combine bf16).dispatch_combine.py: AUTO mode loads config at init,_resolve_launch_paramsextended to accept dtype + tuning_rules, dispatch/combine/standard_moe methods pass actualinput.dtypefor lookup. Falls back to existing hardcoded defaults when no config match.bench_dispatch_combine.py,test_dispatch_combine_internode.py): new--hidden-dimand--save-tuning-configCLI args. Tuning results auto-saved to source repo for distribution.tools/batch_intranode_tuning.sh(single-node, sweeps tokens x hidden_dims) andtools/batch_internode_tuning.sh(multi-node via SSH).setup.pyandMANIFEST.inupdated to include JSON configs in wheel/sdist.Test Plan
--cmd tuning --save-tuning-config autowith EP4/bf16 at multiple token counts (64, 128, 512, 4096), verify JSON accumulates correctly with keep-best merge--save-tuning-config autoon 2-node setupTest Result
Single-node tuning on MI308X (gfx942) EP4 bf16 completed successfully. Generated
gfx942_IntraNode_ep4.jsonwith 4 rules (64/128/512/4096 tokens). JSON format validated, lookup returns correct LaunchParams, keep-best merge preserves higher-bandwidth results across repeated runs.Submission Checklist