-
Notifications
You must be signed in to change notification settings - Fork 90
support deepseek-v2-lite online train and support yarn rope #224
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?
support deepseek-v2-lite online train and support yarn rope #224
Conversation
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.
Summary of Changes
Hello @jiapingW, 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 introduces comprehensive support for online training of the DeepSeek-V2-Lite model with the Eagle3 architecture. It addresses the previous lack of YARN (Yet another RoPE N-dimensional) position encoding support by integrating the YARN rotary embedding method and providing a dedicated script to facilitate this training process.
Highlights
- YARN RoPE Implementation: Implemented the LlamaYarnRotaryEmbedding class and associated helper functions in
specforge/modeling/draft/llama3_eagle.py
to enable YARN (Yet another RoPE N-dimensional) position encoding. - YARN Integration: Modified the LlamaAttention module to dynamically select and apply the newly implemented YARN rotary embedding based on configuration, ensuring compatibility with DeepSeek-V2-Lite.
- DeepSeek-V2-Lite Online Training Script: Introduced a new shell script (
examples/run_deepseek_v2_lite_eagle3_online.sh
) to streamline the online training process for DeepSeek-V2-Lite using the Eagle3 architecture and the updated YARN configuration. - Configuration Update: Updated the
configs/deepseek-v2-lite-eagle3.json
file to correctly specify "rope_type": "yarn", aligning with the new YARN implementation.
Using Gemini Code Assist
The 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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
Feature | Command | Description |
---|---|---|
Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
Help | /gemini help |
Displays a list of available commands. |
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 .gemini/
folder in the base of the repository. Detailed instructions can be found here.
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
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
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 adds support for YaRN rope scaling to enable online training for deepseek-v2-lite
. The changes include a new LlamaYarnRotaryEmbedding
class with its helper functions, updates to the model configuration to use YaRN, and a new example script for training. The implementation of YaRN appears correct. I have a couple of minor suggestions to improve code style and adherence to conventions.
--learning-rate 1e-4 \ | ||
--max-length 2048 \ | ||
--chat-template deepseek \ | ||
--cache-dir $ROOT_DIR/cache No newline at end of file |
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.
def yarn_linear_ramp_mask(min, max, dim): | ||
if min == max: | ||
max += 0.001 # Prevent singularity | ||
|
||
linear_func = (torch.arange(dim, dtype=torch.float32) - min) / (max - min) | ||
ramp_func = torch.clamp(linear_func, 0, 1) | ||
return ramp_func |
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 function parameters min
and max
shadow Python's built-in functions. While it doesn't cause an issue in this specific function, it's a bad practice that can lead to subtle bugs if the built-in functions were needed. It's recommended to use alternative names like min_val
and max_val
to avoid shadowing.1
def yarn_linear_ramp_mask(min, max, dim): | |
if min == max: | |
max += 0.001 # Prevent singularity | |
linear_func = (torch.arange(dim, dtype=torch.float32) - min) / (max - min) | |
ramp_func = torch.clamp(linear_func, 0, 1) | |
return ramp_func | |
def yarn_linear_ramp_mask(min_val, max_val, dim): | |
if min_val == max_val: | |
max_val += 0.001 # Prevent singularity | |
linear_func = (torch.arange(dim, dtype=torch.float32) - min_val) / (max_val - min_val) | |
ramp_func = torch.clamp(linear_func, 0, 1) | |
return ramp_func |
Style Guide References
Footnotes
-
As per PEP 8, it is recommended to avoid using names that shadow built-in functions. ↩
Hello, does the use of yarn rotation position encoding improve the accuracy of eagle3 compared to not using any rotation position encoding? |
I trained DeepSeek-v2-Lite on ShareGPT for one epoch using YARN. The accuracy for position 1 was 0.36. I didn't use the standard rope for training. Due to limited resources, I couldn't train with a long context. I think using rope and YARN shouldn't significantly impact training performance unless you're training with very long inputs. |
Motivation
Since only the config for deepseek-v2-lite training is provided, we found after running LlamaForEagle3 that it does not support yarn position encoding. Therefore, I added adaptation for yarn position encoding and trained Deepseek-v2-lite using the test data online.
Modifications
Related Issues
Fix this issue: #219
We will also add support for YARN in sglang later.
Accuracy Test
Benchmark & Profiling
Checklist