-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
[Bugfix] fix rope error when load models with different dtypes #4835
[Bugfix] fix rope error when load models with different dtypes #4835
Conversation
@@ -474,7 +474,7 @@ def get_rope( | |||
else: | |||
rope_scaling_args = None | |||
key = (head_size, rotary_dim, max_position, base, is_neox_style, | |||
rope_scaling_args) | |||
rope_scaling_args, torch.get_default_dtype()) |
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.
can we pass the dtype as an argument instead?
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.
done.
@@ -463,7 +468,10 @@ def get_rope( | |||
base: int, | |||
is_neox_style: bool = True, | |||
rope_scaling: Optional[Dict[str, Any]] = None, | |||
dtype: Optional[torch.dtype] = None, |
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.
QQ: is it difficult to always require to pass the dtype instead?
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.
I notice that linear module in vllm set param_dtype
as an optional argument, so I think it may be better to keep the same.
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.
import torch
from vllm import LLM
model_fp16 = LLM("Qwen/Qwen1.5-0.5B", dtype=torch.half, gpu_memory_utilization=0.4)
model_bf16 = LLM("Qwen/Qwen1.5-0.5B", dtype=torch.bfloat16, gpu_memory_utilization=0.4)
Can you add this as a regression test? And then it lgtm
I add a rope module cache test instead of model test, is that ok? |
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.
Yeah test lgtm!
Currently, if we load models with different dtypes in the same process, we would get an error like
To reproduce:
The bug is caused by the rope cache, different dtypes share the same rope module. This PR add dtype to cache key to fix this bug.