feat: [Qwen3.5] Support block-wise FP8 quantization and model adaptation#18926
feat: [Qwen3.5] Support block-wise FP8 quantization and model adaptation#18926ispobock merged 5 commits intosgl-project:mainfrom
Conversation
- Restrict ignored layer prefix replacement to Mistral-3 models to avoid unintended side effects. - Update Qwen3.5 quantization configuration prefix from 'model' to 'mtp'. - Disable quantization for Qwen3-VL vision encoders to resolve incompatibility issues. - Refactor prefixes to 'model.visual' and 'model.language_model' to accurately reflect model hierarchy. - Remove redundant layer name replacements and ensure naming consistency for vision layers.
- Add `_load_merged_block_scale` for processing block-level quantization scales. - Compute block dimensions and offsets from quantization settings. - Enable shard-by-shard weight block loading with tensor parallelism support. - Integrate `BlockQuantScaleParameter` handling into `weight_loader_v2`.
Summary of ChangesHello @zju-stu-lizheng, 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 significantly enhances the quantization capabilities by introducing block-wise FP8 support for the Qwen3.5 series. It also refines the model adaptation logic across several architectures, including Qwen3.5, Qwen3-VL, and Mistral-3, to ensure proper handling of quantization configurations and layer naming conventions. These changes aim to improve compatibility and robustness when applying advanced quantization techniques to these models. 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
Activity
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 support for block-wise FP8 quantization for Qwen3.5 and refactors model adaptation logic for several models, including Qwen3-VL and Mistral-3. The changes are well-structured and align with the goals described.
My review includes a suggestion to refactor a loop for calculating shard sizes and offsets into a more concise and Pythonic implementation using itertools.accumulate. I also pointed out a minor typo in a comment. Overall, the changes look good and improve quantization support and model compatibility.
| shard_block_sizes = [] | ||
| shard_block_offsets = [] | ||
| current_block_offset = 0 | ||
| for output_size in self.output_sizes: | ||
| shard_block_size = (output_size + block_n - 1) // block_n | ||
| shard_block_sizes.append(shard_block_size) | ||
| shard_block_offsets.append(current_block_offset) | ||
| current_block_offset += shard_block_size |
There was a problem hiding this comment.
The calculation of shard_block_sizes and shard_block_offsets can be made more concise and Pythonic by using a list comprehension and itertools.accumulate. This improves readability and maintainability.
shard_block_sizes = [
(output_size + block_n - 1) // block_n for output_size in self.output_sizes
]
shard_block_offsets = [0] + list(itertools.accumulate(shard_block_sizes[:-1]))- Deprecate special handling for the 'language_model.mtp' prefix. - Refactor prefix replacement to avoid unintended side effects from over-replacement. - Keep the essential 'mtp.' to 'model.' replacement rule intact. - Remove the redundant 'model.norm' replacement to prevent regressions.
|
@zju-stu-lizheng About the VLM update, could you please paste the running command for this enhancement? |
|
/tag-and-rerun-ci |
|
The running command for loading fp8 checkpoint @yuan-luo : TP_SIZE=8 |
@zju-stu-lizheng Thanks. |
Overview
This PR introduces support for block-wise FP8 quantization for the Qwen3.5 series and refines model adaptation logic for several architectures (Mistral-3, Qwen3-VL) to ensure compatibility with specialized quantization prefixes.
Key Changes
Block-wise FP8 Scale Loading
Implemented _load_merged_block_scale to handle block-level scale loading for merged column parallel linear layers.
Added logic to calculate block sizes and offsets based on quantization configurations.
Supported shard-wise weight block loading with full Tensor Parallel (TP) slicing support.
Enhanced weight_loader_v2 to handle BlockQuantScaleParameter types.
Model Adaptation & Prefix Alignment
Qwen3.5: Updated quantization configuration prefix from model to mtp to align with specific architecture requirements.
Qwen3-VL: Disabled quantization for vision encoders to resolve known incompatibility issues and updated hierarchy prefixes to model.visual and model.language_model.
Mistral-3: Restricted layer prefix replacements to prevent unintended side effects in other models.
Consistency: Refactored layer naming logic and removed redundant/unused replacements to ensure cleaner model initialization.
Acknowledgments
Special thanks to @cao1zhg for the collaboration and valuable contributions to this implementation.
Checklist