Skip to content

feat: enable bf16 fallback for o_proj in Qwen3-VL W8A8 quantization#1809

Open
nie-linfeng wants to merge 1 commit into
xLLM-AI:mainfrom
nie-linfeng:o-proj-bf16-adaptation
Open

feat: enable bf16 fallback for o_proj in Qwen3-VL W8A8 quantization#1809
nie-linfeng wants to merge 1 commit into
xLLM-AI:mainfrom
nie-linfeng:o-proj-bf16-adaptation

Conversation

@nie-linfeng

Copy link
Copy Markdown
Contributor

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:

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +240 to +246
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);
};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

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.

Suggested change
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
  1. Constants must be named using 'k' + PascalCase (e.g., kContentLength, kMaxBatchSize). (link)

@nie-linfeng nie-linfeng force-pushed the o-proj-bf16-adaptation branch 2 times, most recently from ba3ed3e to 7ea41ea Compare June 25, 2026 12:56
@wly-115 wly-115 self-requested a review June 30, 2026 07:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants