-
Notifications
You must be signed in to change notification settings - Fork 1.8k
[FIX] fix bugs caused by None attention_bias during Qwen3 model convert engine #6344
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
📝 Walkthrough""" WalkthroughThe changes update the handling of the Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~7 minutes Possibly related issues
Suggested reviewers
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. 📜 Recent review detailsConfiguration used: .coderabbit.yaml 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
✨ Finishing Touches
🧪 Generate unit tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
/bot run |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Nitpick comments (1)
tensorrt_llm/models/qwen/convert.py (1)
541-557
: Good fix for handling None biases, but clean up whitespace.The conditional logic correctly addresses the issue where Qwen3 models may have None attention biases. The implementation properly:
- Only asserts divisibility when biases exist (lines 541-543)
- Only performs bias concatenation when all biases are present (lines 551-555)
- Sets
qkv_b
to None when any bias is missing (line 557)Fix the trailing whitespace on line 548:
- +
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
tensorrt_llm/models/qwen/convert.py
(1 hunks)
🧰 Additional context used
🪛 Ruff (0.12.2)
tensorrt_llm/models/qwen/convert.py
539-539: Trailing whitespace
(W291)
539-540: SyntaxError: Expected an expression
540-540: Blank line contains whitespace
(W293)
548-548: Blank line contains whitespace
(W293)
66ada37
to
d157f8f
Compare
/bot run |
Thank you for your comment. However, I found that even after incorporating your modifications, the engine conversion still fails in v0.15.0 due to the issue I mentioned earlier—where q_bias, k_bias, and v_bias are None. Since the code lacked the necessary checks, it resulted in syntax errors. After applying my additional fixes, the engine conversion process now completes successfully. Therefore, my PRs mentioned earlier are not about adding support for converting Qwen3 engines but rather about fixing bugs that occur when converting Qwen3 models in older versions of TensorRT-LLM (e.g., v0.15.0). |
My modifications include your PR fix_dim: #5913, and I've provided an explanation in the PR comments regarding this inclusion. The reason I incorporated your PR's changes is that my modifications must be built upon both of your PRs: Qwen3 Dense Support: #5650 and fix_dim: #5913. I noticed that your fix_dim: #5913 hasn't been merged yet, and I was concerned that if my PR were merged while yours remained unmerged, converting Qwen3 in v0.15.0 would still fail. Therefore, I proactively included the content from your PR. Would you like me to separate your PR's changes from mine? If needed, I can resubmit my modifications to exclude your PR. |
@fyf2016 |
/bot run |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
PR_Github #13120 [ run ] triggered by Bot |
PR_Github #13120 [ run ] completed with state |
/bot run |
@fyf2016 Please run |
…rsion Signed-off-by: fanyunfan <[email protected]>
/bot run |
1 similar comment
/bot run |
PR_Github #13153 [ run ] triggered by Bot |
PR_Github #13153 [ run ] completed with state |
@fyf2016 Please don't update the code frequently if there is not code conflict. If you don't update, we can reuse the status of last CI and only run the fail jobs on next CI. |
/bot run |
Thank you for your patient reminder, I understand~ |
PR_Github #13183 [ run ] triggered by Bot |
PR_Github #13183 [ run ] completed with state |
/bot run |
PR_Github #13282 [ run ] triggered by Bot |
PR_Github #13282 [ run ] completed with state |
@gkswns0531 Hi brother~, our PR(The fix_dim section incorporates your PR #5913) has been successfully merged into the master branch~ Thank you for your contribution to fixing the dim issue: fix_dim: #5913 . It has truly helped me and others who encountered the same problem. ![]() Additionally, a special thanks to the community staff member @byshiue for your patient guidance and support, especially when I was unfamiliar with the process. ![]() |
…rt engine (NVIDIA#6344) Signed-off-by: fanyunfan <[email protected]> Co-authored-by: fanyunfan <[email protected]> Signed-off-by: Lanyu Liao <[email protected]>
…rt engine (NVIDIA#6344) Signed-off-by: fanyunfan <[email protected]> Co-authored-by: fanyunfan <[email protected]>
…rt engine (NVIDIA#6344) Signed-off-by: fanyunfan <[email protected]> Co-authored-by: fanyunfan <[email protected]>
Problem
Qwen3 (dense) models have no attn bias,and in the convert_hf_qwen method in TensorRT-LLM/tensorrt_llm/models/qwen/convert.py, the calculation of qkv_bias does not account for the case where attn_bias is None.
A None object has no shape attribute and cannot undergo split or concat operations, leading to an error in older TensorRT-LLM versions (e.g., v0.15.0).
The following PR fixes how to ensure compatibility with the Qwen3-to-engine conversion process in older versions of TensorRT-LLM (e.g., v0.15.0).
Current Implementation
Solution
Add a check for attn_bias being None before performing related calculations, and apply conditional logic to the final result qkv_b. If any of bq, bk, or bv is None, set qkv_b to None as well.
Related Issues:
#6295
Additional Notes:
On top of the main branch, after fixing the aforementioned qkv_bias issue, an additional fix for the head_dim problem in TensorRT-LLM/tensorrt_llm/models/qwen/config.py is required to enable a functional workflow for converting Qwen3 models into engines.
The fix for this issue can be found in another contributor's PR: #5913.
To ensure the successful conversion of Qwen3 models, this PR also incorporates the aforementioned head_dim fix. This is explicitly stated here for clarity.
Summary by CodeRabbit
Summary by CodeRabbit