Skip to content

refactor: unify AWEX converters and adapters across v1 and v2 - #1684

Merged
sitabulaixizawaluduo merged 43 commits into
mainfrom
feature/v2-awex-native-converters
Oct 16, 2026
Merged

sitabulaixizawaluduo merged 43 commits into
mainfrom
feature/v2-awex-native-converters

Conversation

@sitabulaixizawaluduo

@sitabulaixizawaluduo sitabulaixizawaluduo commented Sep 7, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Unify the Megatron and SGLang AWEX integrations so v1 colocated weight updates and v2 separated weight updates share adapter implementations and native AWEX model conversion.

Shared adapters

  • Centralize Megatron, SGLang, and FSDP AWEX adapters and the training/inference Protocols in areal/engine/awex/.
  • Connect v1 and v2 entry points directly to the shared adapters and remove the legacy reader/writer facades and superseded v2 adapter modules.
  • Keep NCCL group setup, metadata exchange, DTE configuration/detection, and device utilities alongside the adapters, with no imports from areal.v2 in the shared AWEX package.
  • Reuse MegatronWeightResidency for weight, optimizer, and gradient memory management.
  • Retain v1 colocated IPC transfer and v2 separated full-weight and delta-weight transfer paths.

Native conversion and metadata

  • Use AWEX's native Megatron and SGLang converters, rank extraction, and sharding metadata.
  • Pass inference converter context through the weight-update gateway to training workers before generating parameter metadata.
  • Propagate the training parameter layout to SGLang metadata generation, including an explicit HF layout for FSDP.
  • Replace duplicated conversion and metadata handling with shared adapter logic.

Type of Change

  • ♻️ Refactoring

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.

AwexFSDPAdapter now imports and calls batch_send_recv_by_peer, so this mock targets a symbol that no longer exists in the FSDP module. The FSDP test case raises AttributeError before reaching the barrier assertion. Please patch batch_send_recv_by_peer instead, and verify that the transfer is invoked before the Gloo completion barrier.

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.

Fixed in a17882b. The parameterized FSDP/Megatron/SGLang test now patches batch_send_recv_by_peer, checks its arguments for both use_group settings, and asserts that the transfer returns before the Gloo completion barrier. The SGLang copy test now asserts transfer -> copy -> synchronize -> barrier. I also updated the two DTE module-loader stubs to expose the new helper.

Validation: full pre-commit, Ruff, and Python compilation passed. Unit tests were not run locally.

Comment on lines +1755 to +1764
model_config, _ = PretrainedConfig.get_config_dict(actor.path)
if model_config.get("model_type") == "qwen2" or "Qwen2ForCausalLM" in (
model_config.get("architectures") or []
):
raise ValueError(
"Qwen2/Qwen2.5 text models do not support AWEX weight updates. "
"For RL, set actor._version=v1, rollout._version=v1, and "
"actor.weight_update_mode=xccl or disk. Controller v2 is not "
"supported for these models' RL weight updates."
)

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.

This guard also rejects Qwen2/Qwen2.5 with v2 + use_lora=True, but the existing trainer routes that configuration through disk-based adapter updates, bypassing AWEX conversion. Is there a separate incompatibility that requires rejecting this path? If not, could we scope the guard to configurations that actually select AWEX?

Comment on lines +52 to +59
for peer in sorted(ops_by_peer):
peer_ops = ops_by_peer[peer]
batch_send_recv(
send_ops=peer_ops if send_ops else [],
recv_ops=peer_ops if recv_ops else [],
blocking=True,
use_group=True,
)

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.

Is peer serialization required for the shared adapter/native converter integration to work? It appears independent of the refactor and changes the default transfer scheduling. Unless there is a demonstrated correctness or resource issue that makes it necessary, could we preserve the existing scheduling here and move this change to a separate PR with before/after measurements?

Le8r0nJames
Le8r0nJames previously approved these changes Sep 11, 2026
Share Megatron and SGLang weight-update adapters so both versions use
native AWEX conversion and sharding metadata.

Key changes:
- Consolidate v1 colocate and v2 separation adapter implementations
- Preserve legacy entry points and shared Megatron weight residency
- Forward inference converter context through the weight-update gateway
- Propagate parameter layouts between training and inference workers
- Retain full-weight and delta-weight separation transfer paths
@github-actions

github-actions Bot commented Oct 3, 2026

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had recent activity within the last 14 days.

Please add a comment or push new commits to keep it active.

Thank you for your contribution!

@github-actions github-actions Bot added the stale label Oct 3, 2026
Carry the new CPU-staged optimizer residency and IPC export lifetime
through the shared AWEX adapter while preserving the PR module layout.
@sitabulaixizawaluduo sitabulaixizawaluduo added safe-to-test Ready to run unit-tests in a PR. and removed safe-to-test Ready to run unit-tests in a PR. labels Oct 16, 2026
Controller v2 selects disk updates for LoRA and AWEX otherwise,
regardless of weight_update_mode. Match the guard to that dispatch so
Qwen2 LoRA runs are allowed and non-LoRA AWEX runs remain rejected.
Le8r0nJames
Le8r0nJames previously approved these changes Oct 16, 2026

@Le8r0nJames Le8r0nJames 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

The Megatron AWEX fallback lacks Qwen2 conversion mappings, while
FSDP publishes HF-layout weights without that converter. Avoid
rejecting the FSDP path before its own metadata validation.
@sitabulaixizawaluduo
sitabulaixizawaluduo merged commit f43c93e into main Oct 16, 2026
6 checks passed
@sitabulaixizawaluduo
sitabulaixizawaluduo deleted the feature/v2-awex-native-converters branch October 16, 2026 12:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

safe-to-test Ready to run unit-tests in a PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants