fix: draft model IMA by overide max_positional_embeddings#10787
fix: draft model IMA by overide max_positional_embeddings#10787zhyncs merged 3 commits intosgl-project:mainfrom
Conversation
Co-authored-by: Qiaolin Yu <qy254@cornell.edu>
Summary of ChangesHello @JustinTong0323, 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 addresses an issue (Fix #10713) by implementing a targeted fix for draft models. The core change ensures that when a draft model's context length is adjusted, its 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. 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
|
|
@JustinTong0323 can you add ut for this |
There was a problem hiding this comment.
Code Review
This pull request introduces a fix for handling draft models with extended context lengths. When a context_length is provided that is longer than the model's default, and overrides are enabled, the change now also updates the max_position_embeddings in the draft model's configuration. This ensures that the draft model's positional embeddings are correctly sized for the extended context, which is crucial for speculative decoding scenarios. The change is well-placed and includes a helpful warning log. The implementation looks correct and follows the existing patterns in the codebase.
|
Maybe merge with #10788 |
| ): | ||
| logger.warning(msg) | ||
| self.context_len = context_length | ||
| if is_draft_model: |
There was a problem hiding this comment.
get_bool_env_var("SGLANG_ALLOW_OVERWRITE_LONGER_CONTEXT_LEN") get environ var from sglang.srt.environ
…t#10787) Co-authored-by: Qiaolin Yu <qy254@cornell.edu>
Motivation
Fix #10713
Root cause is the rope cache calculated by model's
max_positional_embeddings, which is default to 2048. So if the input(after batching) longer then this number, IMA occurs.sglang/python/sglang/srt/layers/rotary_embedding.py
Lines 132 to 141 in ea33867
Modifications
Accuracy Tests
Benchmarking and Profiling
Checklist