-
Notifications
You must be signed in to change notification settings - Fork 257
[Feat] Add FP8 training support #758
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Summary of ChangesHello @fishcrap, 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 significantly upgrades AReaL by integrating comprehensive FP8 training support. The primary goal is to enable memory-efficient training with reduced precision without compromising model stability. This is achieved through the introduction of new FP8 quantization and dequantization utilities, extensive configuration options via the CLI, and updates to model loading and saving processes to handle FP8 weights. The core 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. 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.
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 comprehensive FP8 training support, including new utilities for quantization/dequantization, CLI configurations, and updates to model loading/saving to handle FP8 weights. The changes are extensive and well-structured. I've identified a few areas with TODO or FIXME comments in the new code, particularly in tests and utility functions, that should be addressed to ensure correctness and clarity. The overall implementation seems robust, with good integration into the existing MegatronEngine and the addition of a comprehensive test suite.
1c640a0 to
ad45cb3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The critical issue is that we should enforce HF fp8 base model if fp8 training is enabled.
| bucket_size: int | None = None | ||
| average_in_collective: bool = False | ||
| fp8_param_gather: bool = False | ||
| data_parallel_sharding_strategy: str = field( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it for FSDP or DDP? Does no_shard means no sharding for optimizer states or parameters?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete this field
| recompute_modules: list[str] | None = None | ||
|
|
||
| # MoE | ||
| moe_router_dtype: str | None = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
default to float32?
|
|
||
| def get_device_stats(self) -> DeviceRuntimeInfo: | ||
| return DeviceRuntimeInfo.get_current() | ||
| def _check_and_apply_fp8_config(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should also check transformer_engine installation here. If transformer_engine is not installed, e.g., in a uv pip install environment, a runtime error should be raised
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should also revert the above change
| # FP8 Training Configuration | ||
| fp8: str | None = field( | ||
| default=None, | ||
| metadata={ | ||
| "help": "Enable FP8 precision training. Options: " | ||
| "'e4m3' (uniform e4m3), " | ||
| "'hybrid' (e4m3 for activations/weights, e5m2 for output activation gradients)." | ||
| }, | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we provide an example yaml config for fp8 qwen3 training? We'd better provide a learning curve with the config (fp8 vs bf16 training curve).
Description
This PR adds comprehensive FP8 (8-bit floating point) training support to AReaL, enabling memory-efficient training with low precision while maintaining training stability. The implementation includes:
fp8_utils.pyandfp8_kernels.pymodules providing blockwise and per-tensor quantization supportTrainEngineConfigwith FP8-related options (fp8 mode, recipe, parameter quantization, etc.)MegatronEngineto support FP8 training with proper configuration propagationThe implementation supports the blockwise scheme, with integration into Transformer Engine's FP8 infrastructure for efficient GEMM operations.
Related Issue
Fixes #(issue)
Type of Change
Checklist
jb build docs/gemini review)Breaking Change Details (if applicable):
N/A - This is a new feature that adds optional FP8 support without breaking existing functionality.
Additional Context
TODO: