Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork4.1k
FP8: Load model on-the-fly in vLLM#3717
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Conversation
Summary of ChangesHello@andrewor14, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request refactors the FP8 quantization logic within the Unsloth framework to leverage new capabilities in vLLM (version 0.12.0 and above). Instead of performing an offline quantization step, models can now be quantized on-the-fly when loaded, simplifying the workflow and improving efficiency. The changes involve updating model loading functions to accept a Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on ourdocumentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on@gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign uphere. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with theGemini Code Assist IDE Extension. Footnotes
|
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.
Code Review
This pull request refactors the FP8 model loading to leverage vLLM's on-the-fly quantization for versions 0.12.0 and newer. This is a solid improvement, as it eliminates the need for offline quantization and the creation of a temporary model. The implementation acrossllama.py,loader.py,loader_utils.py, andvision.py is well-executed, correctly checking the vLLM version to conditionally skip the offline process. My feedback consists of a minor stylistic suggestion to improve the readability of boolean checks, making them more idiomatic to Python.
| ) | ||
| fp8_mode=None | ||
| ifload_in_fp8!=False: |
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.
For boolean checks, it's more idiomatic in Python to use the truthiness of the value directly rather than comparing withFalse. Theload_in_fp8 parameter can beTrue,False, or a string like'block'. BothTrue and non-empty strings are truthy, whileFalse is falsy. Usingif load_in_fp8: is more concise and readable, and achieves the same result.
| ifload_in_fp8!=False: | |
| ifload_in_fp8: |
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 agree with gemini here :)
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.
sure I can change it, I just had it this way because I saw that's how Daniel wrote it in a few existing places
| lower_model_name=model_name.lower() | ||
| assertload_in_fp8in (True,False,"block") | ||
| ifload_in_fp8!=False: |
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.
Similar to my other comments, this check can be made more Pythonic. Instead ofif load_in_fp8 != False:, you can useif load_in_fp8:. This leverages Python's truthiness evaluation and is generally considered better style for readability and conciseness.
| ifload_in_fp8!=False: | |
| ifload_in_fp8: |
| ) | ||
| fp8_mode=None | ||
| ifload_in_fp8!=False: |
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.
**Summary:** Existing support for `load_in_fp8=True` performsan offline quantization when loading the initial model.This is no longer necessary as of vllm==0.12.0 (aftervllm-project/vllm#23014), where wecan quantize the model on-the-fly when we load it:```llm = LLM( ... hf_overrides={ "quantization_config_dict_str": json.dumps(torchao_config), },)```**Note:** Needsunslothai/unsloth-zoo#380**Test Plan:**https://gist.github.com/andrewor14/5b85119fae46845d07b608d420907423
32cb1d7 tof7ee75eCompareThere 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.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When yousign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| load_in_4bit, | ||
| load_in_8bit, | ||
| load_in_16bit, | ||
| use_exact_model_name, | ||
| ) | ||
| model_name=_offline_quantize_to_fp8(model_name,fp8_mode) | ||
| else: |
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.
Enforce FP8/4bit mutual exclusion for vLLM >=0.12
Whenload_in_fp8 is true,get_model_name now returns the original name as soon as vLLM ≥ 0.12.0 (loader_utils.py lines 110-118), so thenew_model_name is None branch here is never taken and_get_fp8_mode_and_check_settings no longer runs. With the defaultload_in_4bit=True, the code now proceeds to fast inference with bothload_in_fp8 anduse_bitsandbytes=load_in_4bit set, even though_get_fp8_mode_and_check_settings used to reject FP8 together with 4/8/16-bit loads. This yields conflicting quantization paths (fp8 on-the-fly plus bitsandbytes 4bit) and is likely to fail at runtime for users who simply enableload_in_fp8 without also disabling 4bit.
Useful? React with 👍 / 👎.
for more information, seehttps://pre-commit.ci
danielhanchen commentedDec 12, 2025
@andrewor14 Oh thanks - would this be backwards compatible? |
andrewor14 commentedDec 12, 2025
Yeah, this only affects vllm >= 0.12.0. Behavior is the same as before for older versions. Just tested on 0.12.0 and 0.11.1 |
Uh oh!
There was an error while loading.Please reload this page.
Summary: Existing support for
load_in_fp8=Trueperforms an offline quantization when loading the initial model. This is no longer necessary as of vllm==0.12.0 (aftervllm-project/vllm#23014), where we can quantize the model on-the-fly when we load it:Note: Needsunslothai/unsloth-zoo#380
Test Plan:
https://gist.github.com/andrewor14/5b85119fae46845d07b608d420907423