Add Conv2dLayer/Conv3dLayer to fix PyTorch 2.9.1 CuDNN Conv3d bug#20282
Add Conv2dLayer/Conv3dLayer to fix PyTorch 2.9.1 CuDNN Conv3d bug#20282mickqian merged 1 commit intosgl-project:mainfrom
Conversation
…mization Add unified Conv2d/Conv3d abstraction in sglang/srt/layers/conv.py that automatically uses unfold+F.linear when kernel_size == stride, padding == 0, dilation == 1, groups == 1. This is ~4-14x faster for patch embeddings and avoids the PyTorch 2.9.1 + CuDNN < 9.15 Conv3d bug. Migrate 15 vision models to use the new layers and remove the global check_torch_2_9_1_cudnn_compatibility() check from server_args.py. Co-Authored-By: wili-65535 <wili-65535@users.noreply.github.com>
|
/tag-and-rerun-ci |
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 introduces custom 2D and 3D convolution layers designed to enhance performance and stability, particularly for patch embeddings in multimodal models. The primary motivation is to resolve a critical bug in PyTorch 2.9.1's 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. Changelog
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 Conv2dLayer and Conv3dLayer as optimized replacements for PyTorch's native convolution layers, primarily to address a bug in PyTorch 2.9.1 with older CuDNN versions. The use of an unfold+linear optimization is a clever workaround. The migration of various models to these new layers is well-executed, and the refactoring in glm4v.py is a notable improvement in code clarity. The addition of comprehensive unit tests is also commendable. I have a couple of suggestions to enhance the readability and robustness of the new convolution layers.
|
/rerun-failed-ci |
|
@mickqian @JustinTong0323 what do you think of this pr? |
mickqian
left a comment
There was a problem hiding this comment.
we need some performance and accuracy report for this one
|
accuracy: performance: |
|
vlm affected only, bypassing |
…gl-project#20282) Co-authored-by: wili-65535 <wili-65535@users.noreply.github.com>
…gl-project#20282) Co-authored-by: wili-65535 <wili-65535@users.noreply.github.com>
Motivation
Very thanks for the benchmark data in this PR: #19788
Conv2dLayer/Conv3dLayerinsglang/srt/layers/conv.py. Conv3dLayer enables unfold+linear by default to avoid the PyTorch 2.9.1 + CuDNN < 9.15 Conv3dbug (Severe Performance Regression in Conv3D / bf16 in PyTorch 2.9.1 pytorch/pytorch#168167). Conv2dLayer is a drop-in replacement for
nn.Conv2dwith linear optimization opt-in.check_torch_2_9_1_cudnn_compatibility()fromserver_args.py.Modifications
Accuracy Tests
Benchmarking and Profiling
Checklist
Review Process
/tag-run-ci-label,/rerun-failed-ci,/tag-and-rerun-ci