Fix: Align Qwen3 dtype handling with Qwen2 for TPU#1904
Open
xianglon-commits wants to merge 3 commits intovllm-project:mainfrom
Open
Fix: Align Qwen3 dtype handling with Qwen2 for TPU#1904xianglon-commits wants to merge 3 commits intovllm-project:mainfrom
xianglon-commits wants to merge 3 commits intovllm-project:mainfrom
Conversation
Aligned Qwen3 model definition with Qwen2 fixes by renaming __init__ parameter 'dtype' to 'param_dtype' to ensure correct bfloat16 handling on TPU, as suggested.
Collaborator
|
would this be related to this pr? #1771 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR addresses a
ValueErrorcaused by a dtype mismatch (bfloat16 vs float32) within the TPU attention kernels when running the Qwen3 model. This issue was encountered when using Tunix with the vLLM-JAX backend on thelance-dsbranch.Expected
kv_cache.dtype=dtype(bfloat16)to be equal tok.dtype=dtype(bfloat16)andv.dtype=dtype(bfloat16), but foundv.dtype=dtype('float32').Following the pattern used to fix similar issues in
qwen2.py(as suggested by the Tunix team, see https://screenshot.googleplex.com/8AwrZ44yv57Bt95), this change renames thedtypeparameter toparam_dtypewithin the__init__methods of layers intpu_inference/models/jax/qwen3.py.This change aims to prevent potential naming conflicts and ensure the intended
bfloat16data type is consistently propagated and used for model parameters on TPU, resolving the mixed-precision error.