Skip to content

Add MoE expert parallel training runtime#26

Merged
alay2shah merged 9 commits into
mainfrom
feature/expert-parallelism
Jun 9, 2026
Merged

Add MoE expert parallel training runtime#26
alay2shah merged 9 commits into
mainfrom
feature/expert-parallelism

Conversation

@alay2shah

@alay2shah alay2shah commented May 28, 2026

Copy link
Copy Markdown
Collaborator

Summary

This PR adds first-class MoE training support with an expert-parallel runtime, manual sharded checkpoint export, and a cleaned-up package structure rebased onto the current GRPO mainline.

Major changes:

  • Add MoE SFT/DPO training paths with EP token dispatch, grouped expert compute, FSDP2 wrapping over the DP mesh, activation checkpointing, MoE metrics, and memory tracing.
  • Add manual sharded checkpoint save/export support that can reconstruct HF-compatible checkpoints from FSDP2/EP runs.
  • Reorganize runtime modules into clearer packages: data_loading, training, checkpointing, distribution, config, cli, and rl.
  • Keep GRPO helpers in the reorganized layout: training loops under training/, rollout/reward/env helpers under rl/, and user reward examples under repo-root rewards/.
  • Add Ray/Slurm distribution helpers, multinode Ray startup/teardown, and rank/data sharding protections.
  • Include one standard MoE EP SFT example config alongside the other committed examples.
  • Expand regression coverage for config parsing, data loading, MoE losses/runtime, rank groups, checkpoint metadata/export, GRPO integration, and trainer lifecycle behavior.

Validation

  • uv run ruff check src tests
  • uv run ruff format --check src tests
  • uv run pre-commit run --all-files
  • uv run pytest tests/test_config_parsing.py tests/test_grpo_config.py tests/test_grpo_data.py tests/test_rewards_loader.py tests/test_vllm_server.py tests/test_rl_env_adapter.py tests/test_load_models.py tests/test_ray_cluster_support.py tests/test_training_configs.py tests/test_moe_ep_runtime.py tests/test_moe_losses.py tests/test_moe_trainers.py tests/test_sft_loss_masks.py tests/test_trainer_mixins.py -> 323 passed, 5 warnings in 52.33s

Notes

The GPU e2e tests remain marked/skipped in local CPU-style test runs. Recent Slurm validation runs covered the DP4/EP2 and DP4/EP4 save paths before this final cleanup pass.

@alay2shah alay2shah changed the title [codex] Add MoE expert parallel training runtime Add MoE expert parallel training runtime May 28, 2026
@alay2shah
alay2shah requested a review from EdoardoMosca May 29, 2026 12:35
@alay2shah

Copy link
Copy Markdown
Collaborator Author

Tested on DP4, EP2 packed 32k sequences on 1 node and multinode DP4, EP4 packed 32k sequences

@alay2shah

Copy link
Copy Markdown
Collaborator Author

Currently rebasing on new GRPO main

@alay2shah
alay2shah force-pushed the feature/expert-parallelism branch from 523bd13 to fb0291a Compare May 29, 2026 17:45
@alay2shah
alay2shah marked this pull request as ready for review May 29, 2026 22:35

@EdoardoMosca EdoardoMosca left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Apologies for the delay, partially my fault that now you have merging conflict with main

The branch feels very clean and nicely structured

🟢 formatting and linting are good
🟢 ran non-GPU tests

given the PR size I tackled it with codex but everything it found are things that don't worry me

nit: manual_sharded_checkpoint_format was being removed from the Trainer/DPOConfig kwargs before validation ran, so invalid values were not caught. I applied a small fix. You can revert if you feel I'm being overconcerned

@alay2shah
alay2shah force-pushed the feature/expert-parallelism branch from 8747ba0 to f178b7b Compare June 9, 2026 18:27
@alay2shah
alay2shah merged commit 0a4e9f6 into main Jun 9, 2026
1 check passed
@alay2shah
alay2shah deleted the feature/expert-parallelism branch June 9, 2026 18:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants