-
-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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][Quantization]Fix support for non quantized visual layers in otherwise quantized mllama model, including missing scaling factors #9800
Conversation
👋 Hi! Thank you for contributing to the vLLM project. Once the PR is approved and ready to go, your PR reviewer(s) can run CI to test the changes comprehensively before merging. To run CI, PR reviewers can do one of these:
🚀 |
…lama model, including missing scaling factors Signed-off-by: Gregory Shtrasberg <[email protected]>
5ee398d
to
2454f4a
Compare
layer.weight_scale.data[layer.weight_scale.data == torch.finfo( | ||
torch.float32).min] = 1 |
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.
Could you pull out torch.finfo(torch.float32).min
into a constant in this file so we can use a single reference when also using it in create_weights()
? i.e. UNINITIALIZED_SCALE = torch.finfo(torch.float32).min
What is the case that this will be happening? This seems like it may cover up failed weight loading, where we might want to raise an exception.
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.
Could you pull out torch.finfo(torch.float32).min into a constant in this file
Will do
This is for the case when a otherwise quantize model has unquantized layers. These layers will get converted to fp8 with the scale of 1.0, but this scale will not get loaded, as it is not in the model
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 see, in that case then I think this is an incorrect fix. We have infrastructure for referencing the module name against the ignore list in the quantization config. We should fix the issue if they name is not matching or detected from the ignore list here:
vllm/vllm/model_executor/layers/quantization/fp8.py
Lines 85 to 88 in 622b7ab
if isinstance(layer, LinearBase): | |
if is_layer_skipped(prefix, self.ignored_layers): | |
return UnquantizedLinearMethod() | |
return Fp8LinearMethod(self) |
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.
That's good to know, thanks. In this case we only need the kv remap and 3d tensor changes. I will remove this one
vllm/model_executor/models/mllama.py
Outdated
from vllm.model_executor.model_loader.weight_utils import ( | ||
maybe_remap_kv_scale_name) |
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.
Why not add this to the top import list?
…mm to 3D; Use constant for default fp8 scale Signed-off-by: Gregory Shtrasberg <[email protected]>
1cabfe2
to
a23a23c
Compare
…d layers in the config Signed-off-by: Gregory Shtrasberg <[email protected]>
This pull request has merge conflicts that must be resolved before it can be |
Was fixed in #9812 |
This addresses an issue from #9217 fixing support for partially quantized models, such as https://huggingface.co/amd/Llama-3.2-11B-Vision-Instruct-FP8-KV
Adding missing scaling factors that don't exist in the model. Making 3D tensor of MLP input compatible with _scaled_mm
PR Checklist (Click to Expand)
Thank you for your contribution to vLLM! Before submitting the pull request, please ensure the PR meets the following criteria. This helps vLLM maintain the code quality and improve the efficiency of the review process.
PR Title and Classification
Only specific types of PRs will be reviewed. The PR title is prefixed appropriately to indicate the type of change. Please use one of the following:
[Bugfix]
for bug fixes.[CI/Build]
for build or continuous integration improvements.[Doc]
for documentation fixes and improvements.[Model]
for adding a new model or improving an existing model. Model name should appear in the title.[Frontend]
For changes on the vLLM frontend (e.g., OpenAI API server,LLM
class, etc.)[Kernel]
for changes affecting CUDA kernels or other compute kernels.[Core]
for changes in the core vLLM logic (e.g.,LLMEngine
,AsyncLLMEngine
,Scheduler
, etc.)[Hardware][Vendor]
for hardware-specific changes. Vendor name should appear in the prefix (e.g.,[Hardware][AMD]
).[Misc]
for PRs that do not fit the above categories. Please use this sparingly.Note: If the PR spans more than one category, please include all relevant prefixes.
Code Quality
The PR need to meet the following code quality standards:
format.sh
to format your code.docs/source/
if the PR modifies the user-facing behaviors of vLLM. It helps vLLM user understand and utilize the new features or changes.Adding or changing kernels
Each custom kernel needs a schema and one or more implementations to be registered with PyTorch.
Tensors
require meta-functions. Meta-functions should be implemented and registered in python so that dynamic dims can be handled automatically. See above documents for a description of meta-functions.torch.libary.opcheck()
to test the function registration and meta-function for any registered ops. Seetests/kernels
for examples.Notes for Large Changes
Please keep the changes as concise as possible. For major architectural changes (>500 LOC excluding kernel/data/config/test), we would expect a GitHub issue (RFC) discussing the technical design and justification. Otherwise, we will tag it with
rfc-required
and might not go through the PR.What to Expect for the Reviews
The goal of the vLLM team is to be a transparent reviewing machine. We would like to make the review process transparent and efficient and make sure no contributor feel confused or frustrated. However, the vLLM team is small, so we need to prioritize some PRs over others. Here is what you can expect from the review process:
action-required
label on the PR if there are changes required. The contributor should address the comments and ping the reviewer to re-review the PR.Thank You
Finally, thank you for taking the time to read these guidelines and for your interest in contributing to vLLM. Your contributions make vLLM a great tool for everyone!