Megatron-LM icon indicating copy to clipboard operation
Megatron-LM copied to clipboard

FusedDispatch and FusedCombine use default config

Open dadadada-147 opened this issue 7 months ago • 10 comments

Currently, FusedDispatch and FusedCombine use default config, which limit performance. Is it possible to allow user-defined configurations? For example, by reading a config file to set the chunk size accordingly. fused_a2a.py

dadadada-147 avatar Apr 15 '26 11:04 dadadada-147

Are there specific configurations you want to use? The only one currently supported is --moe-deepep-num-sms which sets the number of SMs.

We welcome contributions from the community! Feel free to create a PR to support this.

Phlip79 avatar Apr 15 '26 18:04 Phlip79

Hiii @Phlip79 , I would like to work on this

DhineshPonnarasan avatar Apr 25 '26 08:04 DhineshPonnarasan

@DhineshPonnarasan What arguments do you feel are missing? Which impact do you expect they will have? Do you have a proper setup to run experiments and check the performance?

asolergi-nv avatar Apr 27 '26 14:04 asolergi-nv

Hiii @asolergi-nv , For now I was mainly thinking of exposing chunk_size (along with the existing num_sms) since those seem to have the most direct impact on how the fused A2A runs. I didn’t want to introduce too many parameters upfront without clearly understanding their effect, but I’m open to adding more if there are specific ones you think would be useful.

In terms of impact, my expectation is that chunk_size would affect how work is partitioned during the all-to-all, which could influence communication/computation overlap depending on the workload (token distribution, number of experts, etc.). Not expecting universal gains more about enabling tuning.

I haven’t run a full set of experiments yet I wanted to first validate that this direction makes sense. Next step from my side would be to run some sweeps (chunk size / num_sms) and compare against the default.

If there’s a preferred setup or specific benchmarks you’d like me to use, I’m happy to follow that. I can put together results and open a PR with that included.

DhineshPonnarasan avatar Apr 27 '26 19:04 DhineshPonnarasan

Hi @asolergi-nv , @Phlip79

I have implemented the configuration infrastructure and would like to open a PR. Here's what's included:

  • FusedA2AConfig dataclass (chunk_size, num_sms) resolved once in validate_args with precedence: --moe-a2a-num-sms CLI > MOE_A2A_NUM_SMS env > JSON/YAML config file > defaults.
  • num_sms is fully functional — wired through TransformerConfig → MoETokenDispatcher → _DeepepManager, unifying the two previously inconsistent SM-count sources.
  • chunk_size is accepted and stored in FusedA2AConfig but not yet applied at the kernel level — I could not find a chunk_size parameter in Buffer.dispatch() or Buffer.get_dispatch_layout() in the current DeepEP API. Is this something you'd want me to investigate further or should I open the PR for num_sms now and treat chunk_size as a reserved parameter pending DeepEP support?.
  • 27 unit + integration tests covering precedence rules, fail-fast validation, and full data-flow.

Happy to run num_sms sweeps if you can point me to a benchmark script or preferred model config.

DhineshPonnarasan avatar May 01 '26 07:05 DhineshPonnarasan

What arguments do you feel are missing? Which impact do you expect they will have? Do you have a proper setup to run experiments and check the performance?

@dadadada-147 can you comment on this? Our experience show most of the performance tuning is about setting setting SMs which is already available.

YangFei1990 avatar May 22 '26 17:05 YangFei1990

@DhineshPonnarasan In intranode and internode, deep_ep accept a config parameter : deepep config which is defined at config.hpp . At present, DeepEP relies on hard-coded configuration values, but the optimal settings are hardware-dependent and differ for each specific chip:hardcode config

dadadada-147 avatar Jun 02 '26 09:06 dadadada-147

Hi @dadadada-147, thanks for pointing this out!

I have implemented this based on your links. Here's what was done:

  • Added _build_deepep_config() which takes the hardware-tuned Buffer.get_dispatch_config() / Buffer.get_combine_config() baseline and overrides only the fields the user explicitly sets.
  • chunk_size maps to Config.num_max_nvl_chunked_send_tokens and is now fully wired end-to-end: --moe-a2a-chunk-size CLI / MOE_A2A_CHUNK_SIZE env / JSON+YAML config file → FusedA2AConfig.chunk_size → _build_deepep_config() → buffer.dispatch(config=...) / buffer.combine(config=...).
  • All RDMA and buffer-size params are preserved from the hardware default — only the user-specified fields are overridden.
  • 27 tests pass.

If this looks good, I’m ready to open a PR.

DhineshPonnarasan avatar Jun 05 '26 21:06 DhineshPonnarasan

Hi @dadadada-147, thanks for pointing this out!

I have implemented this based on your links. Here's what was done:

  • Added _build_deepep_config() which takes the hardware-tuned Buffer.get_dispatch_config() / Buffer.get_combine_config() baseline and overrides only the fields the user explicitly sets.
  • chunk_size maps to Config.num_max_nvl_chunked_send_tokens and is now fully wired end-to-end: --moe-a2a-chunk-size CLI / MOE_A2A_CHUNK_SIZE env / JSON+YAML config file → FusedA2AConfig.chunk_size → _build_deepep_config() → buffer.dispatch(config=...) / buffer.combine(config=...).
  • All RDMA and buffer-size params are preserved from the hardware default — only the user-specified fields are overridden.
  • 27 tests pass.

If this looks good, I’m ready to open a PR.

Looks great! Feel free to submit a PR.

dadadada-147 avatar Jun 08 '26 09:06 dadadada-147

Hi @dadadada-147,

I have opened PR #5230 for this issue.

The implementation adds configurable DeepEP settings for fused A2A dispatch/combine, including support for overriding chunk_size while preserving the existing hardware-tuned defaults when no overrides are provided.

Thanks again for the DeepEP references and guidance.

DhineshPonnarasan avatar Jun 09 '26 11:06 DhineshPonnarasan