Feature/Qwen3_VL - #782
Conversation
Summary of ChangesHello @coder0143, 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 integrates the Qwen3-VL multimodal model into SGLang-JAX, significantly enhancing its capabilities to process and generate content based on both visual and textual inputs. The changes introduce a sophisticated vision encoder that leverages DeepStack for efficient feature extraction and a text decoder that incorporates a specialized multimodal rotary position embedding scheme. This foundational work paves the way for advanced multimodal AI applications within the JAX ecosystem. 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
|
|
great work @coder0143 , |
|
On it! |
|
Hello @pengchengneo , I have tested the model loading through the inference script: (It works!) I have written a base script for inference which can be run by: (for multi-tpu), can you test it? |
|
@coder0143 , here is the log for the script |
|
but when I try run command like it will report bug like below, seems it still has tiny bug here Could please fix it and I will test it again. And could please paste e2e accuracy test result with evalscope here to show your implemention is aligned with Qwen3-VL paper's result, if you don't have resources for that, I can also help you test it |
|
Hello @pengchengneo , thankyou for testing, I don't have the resources for testing for e2e accuracy, and the sharding conventions in sgl-jax are quite different. Could you please review my model code along with the inference code and suggest changes to add appropriate sharding and test for e2e, thankyou. |
| return hidden_states, residual, kv_fused, layer_callback_flag | ||
|
|
||
|
|
||
| class Qwen3_VL_Model(nnx.Module): |
There was a problem hiding this comment.
Could this class extend Qwen3 from "python/sgl_jax/srt/models/qwen3.py" ?
| return x_t | ||
|
|
||
|
|
||
| class MRotaryEmbedding: |
There was a problem hiding this comment.
This class is similar to Qwen2_5_VL's MRotaryEmbedding; could we reuse that instead?
There was a problem hiding this comment.
this maybe optimized by Qwen3-Omni's PR, you can refer to #793
| mesh=self.mesh, | ||
| dtype=self.dtype, | ||
| ) | ||
| weight_mappings = self._create_qwen3_weight_mappings() |
There was a problem hiding this comment.
resuse qwen3's weight mapping ?
| return (weight, weight) | ||
| return (self.model.embed_tokens.embedding.value, self.lm_head.embedding.value) | ||
|
|
||
| def set_embed_and_head( |
There was a problem hiding this comment.
this may not by used because it is used for Eagle's MTP algorithm
|
|
||
| return mappings | ||
|
|
||
| def get_embed_and_head(self): |
There was a problem hiding this comment.
this may not by used because it is used for Eagle's MTP algorithm
OK, and Could please fix lint error and the bug I reported previously #782 (comment) |
|
Can you refer to this PR's test #743 to do some testing? @coder0143 |
I think he doesnot have enough resources to test all sizes, I will help him test when he fix all bugs. @pathfinder-pf |
Garrybest
left a comment
There was a problem hiding this comment.
Hi @coder0143, could you please test the precision of this model? Some Refs: https://github.com/sgl-project/sglang-jax/blob/main/python/sgl_jax/test/multimodal/test_qwen3_omni_moe_encoder.py#L23-L160
You can test it on CPU in order to make sure your model implement is right. And TPU machine is not compulsory. Make sure the output of forward in JAX is all close to that in torch transformers on CPU.
|
Is this complete? Thanks |
|
I just had an exam, have resumed working on this, bonsai model is fully done here: jax-ml/bonsai#161 with the sharding and tests. I have started working on some fixes, will then work on tests. |
|
@coder0143 any progress about this PR ? |
|
Yup I'm working on it, will make the changes |
|
@coder0143 hello, any porgress? if you have no time , I can help you finish remain works |
|
@pengchengneo Please do, I have the complete implementation done with optimal sharding configs (fsdp + tp) and multimodal jit support in bonsai(my fork is fully completed: link: https://github.com/coder0143/bonsai/tree/main/bonsai/models/qwen3_vl). You can check the tests here: https://www.kaggle.com/code/prathamshahmldlds/test-bonsai-qwen3-vl |
|
@coder0143 hi, please give me your githubid and github's email, once I finish this model, I will merge it myself and add coauthor info for you |
|
@pengchengneo Thanks for taking it up and adding me as a co-author, my github email is: shahpratham688@gmail.com and github id is: 113518804 , username: @coder0143 . Btw, would love to be connected with you on linkedin! |
|
@pengchengneo Also, I have started working on Qwen3.5 (hybrid GatedDeltaNet) in bonsai, will let you know once its done! |
get it |
|
Does sglang-jax supports qwen3-vl now for inferencing? |
|
@Dineshkumar-Anandan-ZS0367 , the work is going on, there is an optimised bonsai implementation you can use here: https://www.kaggle.com/code/prathamshahmldlds/qwen3vl-in-jax?scriptVersionId=304494350 |
Motivation
Qwen3-VL model support. Issue here: #693
Modifications
Some changes from Qwen 2.5 VL:
Accuracy Tests
Benchmarking and Profiling
Checklist