[loss refactor] [1] add snapshot test on loss functions#752
[loss refactor] [1] add snapshot test on loss functions#752yueming-yuan wants to merge 7 commits intomainfrom
Conversation
Summary of ChangesHello, 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 enhances the robustness of loss function development by introducing a new snapshot testing framework. It also integrates a novel REINFORCE-based loss function designed for asynchronous reinforcement learning, accompanied by an example script to showcase its application. Highlights
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. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a new REINFORCE + double-sided IS masking loss function (reinforce_icepop_loss.py) and integrates it into an example script (run_glm47_flash_async_icepop.py). It also adds comprehensive snapshot tests for various loss functions, ensuring their outputs remain consistent across changes. The new loss function implementation appears correct and follows standard practices for gradient handling and metric reporting. The snapshot testing framework is well-designed for reproducibility and thoroughness. However, there are several hardcoded configuration values in the example script that could be made more flexible, and a dependency installation uses a specific commit hash which can be fragile.
| U.exec_command( | ||
| "pip install git+https://github.com/huggingface/transformers.git@76732b4e7120808ff989edbd16401f61fa6a0afa" | ||
| ) |
There was a problem hiding this comment.
The pip install command uses a specific commit hash for huggingface/transformers. Relying on a specific commit hash can be fragile, as the commit might be force-pushed or the repository structure could change, leading to build failures. It's generally better to pin to a stable version tag or a well-maintained branch if possible, or include this as a dependency in a requirements.txt file with a version range.
If a specific version is absolutely necessary, consider adding a comment explaining why this particular commit is used.
| num_gpus_per_node: int = 8 | ||
| hardware: Literal["H200"] = "H200" | ||
| enable_eval: bool = True | ||
| extra_args: str = "" | ||
| data_dir: str = "/root/datasets" | ||
| model_dir: str = "/root/models" | ||
| megatron_path: str = "/root/Megatron-LM" |
There was a problem hiding this comment.
The num_gpus_per_node, hardware, data_dir, model_dir, and megatron_path are hardcoded in the ScriptArgs dataclass. Hardcoding these values makes the script less portable across different environments or setups. It would be more robust to allow these to be configurable via environment variables or command-line arguments, especially the paths.
For example, data_dir and model_dir could default to environment variables like os.getenv("MILES_DATA_DIR", "/root/datasets").
| ) | ||
|
|
||
| # tp=4 because GLM-4.7-Flash has 20 attention heads (tp must divide num_heads) | ||
| sglang_args = ( |
There was a problem hiding this comment.
The --rollout-num-gpus-per-engine 4 argument is hardcoded, with a comment indicating it's derived from the model's attention heads (tp must divide num_heads). To adhere to the general rule of avoiding hardcoded model dimensions and deriving them from configuration, this value should ideally be calculated programmatically based on the num_heads of GLM-4.7-Flash rather than being a magic number.
No description provided.