feat: enable bf16 fallback for o_proj in Qwen3-VL W8A8 quantization#1809
feat: enable bf16 fallback for o_proj in Qwen3-VL W8A8 quantization#1809nie-linfeng wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces support for non-quantized (bf16) o_proj in the Qwen3 decoder loader and layer implementation. It detects whether o_proj is quantized by checking the size of the attention output bias tensor, and dynamically updates the linear layer descriptors to BFLOAT16 if it is not. Feedback was provided regarding a style guide violation where the constant DENSE_LINEAR_INDEX should be renamed to kDenseLinearIndex to adhere to the k + PascalCase naming convention.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| constexpr uint64_t DENSE_LINEAR_INDEX = 3; | ||
| auto update_o_proj = [](atb_speed::qwen::QwenLayerParam& p) { | ||
| p.linearDescs[DENSE_LINEAR_INDEX] = | ||
| static_cast<int>(LinearTypeV2::BFLOAT16); | ||
| p.linearQuantType[DENSE_LINEAR_INDEX] = | ||
| static_cast<int>(LinearType::INVALID); | ||
| }; |
There was a problem hiding this comment.
According to the repository style guide, constants should be named using k + PascalCase (e.g., kDenseLinearIndex instead of DENSE_LINEAR_INDEX). Please update the constant name to adhere to the style guide.
| constexpr uint64_t DENSE_LINEAR_INDEX = 3; | |
| auto update_o_proj = [](atb_speed::qwen::QwenLayerParam& p) { | |
| p.linearDescs[DENSE_LINEAR_INDEX] = | |
| static_cast<int>(LinearTypeV2::BFLOAT16); | |
| p.linearQuantType[DENSE_LINEAR_INDEX] = | |
| static_cast<int>(LinearType::INVALID); | |
| }; | |
| constexpr uint64_t kDenseLinearIndex = 3; | |
| auto update_o_proj = [](atb_speed::qwen::QwenLayerParam& p) { | |
| p.linearDescs[kDenseLinearIndex] = | |
| static_cast<int>(LinearTypeV2::BFLOAT16); | |
| p.linearQuantType[kDenseLinearIndex] = | |
| static_cast<int>(LinearType::INVALID); | |
| }; |
References
- Constants must be named using 'k' + PascalCase (e.g., kContentLength, kMaxBatchSize). (link)
ba3ed3e to
7ea41ea
Compare
Problem
When o_proj weights fall back to bf16 in a W8A8 quantized model, the ATB LinearOperation fails with a dtype mismatch error:
CheckIniMatch Failed! Supported Combs:
[comb0]: inTensor0(int8,nd), inTensor1(int8,nd), inTensor2(int32,nd), inTensor3(float,nd), outTensor0(bf16,nd)
Solution
Reuse the non-quantized adaptation pattern for o_proj: