refactor(archon): extract runner and weight sync into separate modules#882
Conversation
Summary of ChangesHello @rchardx, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request focuses on improving the modularity and clarity of the ArchonEngine, a core component for distributed ML training. By extracting distinct functionalities like microbatch runners and weight synchronization into their own modules, the engine's codebase becomes more organized and easier to manage. Additionally, the initialization process is made more transparent, and the planner agent's usage guidelines are refined to ensure it's applied effectively. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request is an excellent refactoring of the ArchonEngine. By extracting the runner logic into archon_runner.py and the weight synchronization logic into archon_weight_sync.py, the main engine class has become significantly more modular and maintainable. The reorganization of the __init__ and create_process_group methods with structured sections is a great improvement for readability. Moving imports behind TYPE_CHECKING is also a good practice for reducing startup overhead.
My only concern is with the changes in planner.md, where a potentially useful section with specific guidelines has been removed. Please see the detailed comment.
Overall, the code changes are of high quality and significantly improve the codebase's structure.
There was a problem hiding this comment.
Pull request overview
This refactor modularizes the Archon training engine by extracting pipeline/forward-backward execution and weight synchronization functionality into dedicated modules, while tightening imports and updating the planner agent guidelines. The intent is structural only, preserving existing behavior but improving readability and maintainability.
Changes:
- Extracted
SequentialRunnerandPipelinedRunnerintoareal/experimental/engine/archon_runner.pyand wired ArchonEngine’sforward_backward_batchthrough a unifiedForwardBackwardRunnerabstraction. - Extracted XCCL and disk-based weight synchronization logic into
areal/experimental/engine/archon_weight_sync.py, replacing the inline_init_weight_update_from_distributed/_update_weights_from_*methods and introducingWeightSyncState. - Simplified
ArchonEngineby reorganizing initialization, parallelism setup, and runner creation, moving some imports behindTYPE_CHECKING; updated.claude/agents/planner.mdwith clearer “when to use” guidance and planning templates.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
areal/experimental/engine/archon_weight_sync.py |
New module encapsulating Archon’s weight sync mechanisms (XCCL group init, DTensor handling, broadcast buckets, and disk-based sync), factored out from ArchonEngine. |
areal/experimental/engine/archon_runner.py |
New module defining ForwardBackwardRunner plus concrete SequentialRunner and PipelinedRunner (Schedule1F1B) used by Archon for non-PP and PP execution, respectively. |
areal/experimental/engine/archon_engine.py |
Refactored to use the new runner and weight-sync helpers, reorganized initialization and parallelism configuration, added WeightSyncState integration, and reduced runtime imports via TYPE_CHECKING. |
.claude/agents/planner.md |
Updated planner agent documentation: renamed “When to Activate” to “When to Use”, added concrete “do not use for” cases, clarified requirements/clarification questions, and tightened the planning output templates and maintainer guidelines. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
c6d7701 to
15ffff9
Compare
Extract forward/backward execution and weight synchronization logic from ArchonEngine into dedicated modules for better separation of concerns. Key changes: - Add ForwardBackwardRunner abstraction with SequentialRunner and PipelinedRunner implementations - Extract weight sync logic to WeightSyncState and dedicated functions - Simplify planner agent guidelines with clearer structure
15ffff9 to
d316f86
Compare
areal-project#882) Extract forward/backward execution and weight synchronization logic from ArchonEngine into dedicated modules for better separation of concerns. Key changes: - Add ForwardBackwardRunner abstraction with SequentialRunner and PipelinedRunner implementations - Extract weight sync logic to WeightSyncState and dedicated functions - Simplify planner agent guidelines with clearer structure
areal-project#882) Extract forward/backward execution and weight synchronization logic from ArchonEngine into dedicated modules for better separation of concerns. Key changes: - Add ForwardBackwardRunner abstraction with SequentialRunner and PipelinedRunner implementations - Extract weight sync logic to WeightSyncState and dedicated functions - Simplify planner agent guidelines with clearer structure
Description
Extract forward/backward execution and weight synchronization logic from ArchonEngine into dedicated modules for better separation of concerns.
Key changes:
Type of Change
work as expected)
Checklist
jb build docs/gemini review)