Skip to content

feat: implement megatron weight update with awex#1239

Merged
garrett4wade merged 1 commit into
mainfrom
yr/megatron-awex
Apr 23, 2026
Merged

feat: implement megatron weight update with awex#1239
garrett4wade merged 1 commit into
mainfrom
yr/megatron-awex

Conversation

@ran-yan-hk

Copy link
Copy Markdown
Collaborator

Description

Following PR#1214, add support for Megatron engine for weight update with awex.

This implements a full connect → update_weights → disconnect lifecycle orchestrated
by an HTTP gateway. Megatron and SGLang adapters handle parameter shard mapping. For pure DP, Megatron is integrated in the same way as FSDP; however, Megatron TP's performance may not full optimized (but runnable) due to its built-in all-gather operations.

Current scope: Megatron engine (pure DP or pure TP ore hybrid DP and TP) + SGLang (pure DP) only. PP/EP sharding
is not yet supported.

Related Issue

NA

Type of Change

  • 🐛 Bug fix
  • ✨ New feature
  • 💥 Breaking change
  • 📝 Documentation update
  • ♻️ Refactoring
  • ⚡ Performance improvement
  • ✅ Test coverage improvement

Checklist

  • I have read the Contributing Guide
  • Pre-commit hooks pass (pre-commit run --all-files)
  • Relevant tests pass; new tests added for new functionality
  • Documentation updated (if applicable; built with ./docs/build_all.sh)
  • Branch is up to date with main
  • Self-reviewed via /review-pr command
  • This PR was created by a coding agent via /create-pr
  • This PR is a breaking change

Breaking Change Details (if applicable):

NA

Additional Context

Key files:

areal/experimental/training_service/worker/awex.py: Implement auto detection on training backend.
areal/experimental/weight_update/awex/megatron_adapter.py: Implement Megatron adapter to be compatible with awex.
tests/experimental/weight_update/test_nccl_integration.py: Integrate Megatron engine test for pure DP, pure TP, and hybrid DP + TP.


@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces the AwexMegatronAdapter to support weight updates for Megatron-based training engines, enabling integration with the Awex weight update system for both Data Parallelism (DP) and Tensor Parallelism (TP) configurations. The changes include the adapter implementation, factory integration, and new end-to-end tests. Review feedback highlights critical memory optimization opportunities, specifically recommending that parameter gathering and iteration be filtered by required names to prevent Out-Of-Memory (OOM) errors on large models. Additionally, it was noted that the adapter's docstring should be updated to correctly reflect its support for TP.

Comment thread areal/experimental/weight_update/awex/megatron_adapter.py
Comment thread areal/experimental/weight_update/awex/megatron_adapter.py
Comment thread areal/experimental/weight_update/awex/megatron_adapter.py
Comment thread areal/experimental/weight_update/awex/megatron_adapter.py
Comment thread areal/experimental/weight_update/awex/megatron_adapter.py
@ran-yan-hk ran-yan-hk changed the title implement megatron weight update with awex feat: implement megatron weight update with awex Apr 23, 2026
Comment on lines +249 to +255
gathered = all_gather_param(
mcore_name,
param,
fp8_direct_convert=False,
quantization_config=None,
duplicated_param_names=self._engine._duplicated_param_names,
)

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.

Just FYI this all-gather should be removed in the future.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Sure. This experimental version is runnable but performance issues will be fixed soon.

@garrett4wade garrett4wade 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.

LGTM

@garrett4wade garrett4wade merged commit 6e69226 into main Apr 23, 2026
6 checks passed
@garrett4wade garrett4wade deleted the yr/megatron-awex branch April 23, 2026 09:33
SathyaGnanakumar pushed a commit to danielkiely/AReaL that referenced this pull request Apr 29, 2026
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