feat: bugfix and accuracy fix for stablelm2_1_6b#15932
feat: bugfix and accuracy fix for stablelm2_1_6b#15932iforgetmyname merged 1 commit intosgl-project:ifmn/eagle-dp-attnfrom
Conversation
Summary of ChangesHello @McZyWu, 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 a critical bugfix and accuracy improvement for the 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.
Code Review
This pull request introduces a fix for an accuracy issue with stablelm-2-1-6b on NPU devices. The change modifies the forward_npu method in RotaryEmbedding to fall back to the native PyTorch implementation when SGLANG_ENABLE_TORCH_COMPILE is enabled. This seems to be a necessary workaround for issues with the NPU-specific kernel when using torch.compile. The change is logical, but I have a suggestion to improve code readability.
| if (query.dtype == torch.bfloat16 and self.cos_sin_cache.dtype == torch.float) or get_bool_env_var("SGLANG_ENABLE_TORCH_COMPILE"): | ||
| return self.forward_native(positions, query, key, offsets) |
There was a problem hiding this comment.
For better readability and maintainability, it's good practice to extract complex conditions into descriptive boolean variables. This makes the logic clearer at a glance.
| if (query.dtype == torch.bfloat16 and self.cos_sin_cache.dtype == torch.float) or get_bool_env_var("SGLANG_ENABLE_TORCH_COMPILE"): | |
| return self.forward_native(positions, query, key, offsets) | |
| is_unsupported_dtype = query.dtype == torch.bfloat16 and self.cos_sin_cache.dtype == torch.float | |
| is_torch_compile_enabled = get_bool_env_var("SGLANG_ENABLE_TORCH_COMPILE") | |
| if is_unsupported_dtype or is_torch_compile_enabled: | |
| return self.forward_native(positions, query, key, offsets) |
…glang into eagle-sche * 'ifmn/eagle-dp-attn' of https://github.com/sgl-project/sglang: (22 commits) dp scheduler enhance support with chunked prefill (sgl-project#16071) modify suffix decoding CI dependency update (sgl-project#16063) fix rotary_embedding init npu (sgl-project#16011) feat: bugfix and accuracy fix for stablelm2_1_6b (sgl-project#15932) Update model and feature support for Ascend NPU (sgl-project#16005) Bugfix for Llama4 (sgl-project#15929) Bugfix for ds-vl2 (sgl-project#15894) gme qwen vl runners fix (sgl-project#15899) add profiling in scheduler (sgl-project#15876) llama use triton rope op (sgl-project#15855) suffix decoding adapt npu suffix decoding adapt npu Add suffix decoding speculative algorithm from feature 13553 cherry sgl-project#15434: qwen3 vl performance update cherry sgl-project#15597: fix Qwen3-VL-30B-A3B-Instruct accuracy loss [Schedule] bug fix for schedule enhancer (sgl-project#15834) minilb support roundrobin (sgl-project#15824) fix torchair compile issue cherry sgl-project#15187: lora fix ... # Conflicts: # python/sglang/srt/managers/scheduler.py # python/sglang/srt/managers/scheduler_enhancer.py
Motivation
accuracy fix for stablelm-2-1-6b for npu, previously it was 0.0
Modifications
as follows
Accuracy Tests
0.2