Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Open
andrewor14 wants to merge2 commits intounslothai:main
base:main
Choose a base branch
Loading
fromandrewor14:true-on-the-fly-fp8

Conversation

@andrewor14
Copy link
Contributor

@andrewor14andrewor14 commentedDec 11, 2025
edited
Loading

Summary: Existing support forload_in_fp8=True performs 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:

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

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello@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 aload_in_fp8 parameter and integrating the new on-the-fly quantization mechanism.

Highlights

  • On-the-fly FP8 Quantization: Enables direct FP8 quantization during model loading for vLLM versions 0.12.0 and newer, eliminating the need for prior offline quantization.
  • Streamlined Model Loading: Simplifies the process of loading FP8 quantized models by integrating the quantization step directly into the LLM constructor.
  • Parameter Updates: Introducesload_in_fp8 parameter tofrom_pretrained methods inllama.py andvision.py and updatesloader_utils.py to handle the new quantization flow.
Using Gemini Code Assist

The 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/gemini <command> or@gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

FeatureCommandDescription
Code Review/gemini reviewPerforms a code review for the current pull request in its current state.
Pull Request Summary/gemini summaryProvides a summary of the current pull request in its current state.
Comment@gemini-code-assistResponds in comments when explicitly tagged, both in pull request comments and review comments.
Help/gemini helpDisplays a list of available commands.

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.gemini/ folder in the base of the repository. Detailed instructions can be foundhere.

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

  1. Review thePrivacy Notices,Generative AI Prohibited Use Policy,Terms of Service, and learn how to configure Gemini Code Assist in GitHubhere. Gemini can make mistakes, so double check it anduse code with caution.

andrewor14 added a commit to andrewor14/unsloth-zoo that referenced this pull requestDec 11, 2025
Copy link
Contributor

@gemini-code-assistgemini-code-assistbot left a 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:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

medium

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.

Suggested change
ifload_in_fp8!=False:
ifload_in_fp8:

Copy link
Collaborator

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 :)

Copy link
ContributorAuthor

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:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

medium

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.

Suggested change
ifload_in_fp8!=False:
ifload_in_fp8:

)

fp8_mode=None
ifload_in_fp8!=False:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

medium

This checkif load_in_fp8 != False: can be simplified toif load_in_fp8:. This is the more idiomatic and preferred way to check for truthiness in Python, improving code readability.

Suggested change
ifload_in_fp8!=False:
ifload_in_fp8:

**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
Copy link

@chatgpt-codex-connectorchatgpt-codex-connectorbot left a 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".

Comment on lines 241 to 246
load_in_4bit,
load_in_8bit,
load_in_16bit,
use_exact_model_name,
)
model_name=_offline_quantize_to_fp8(model_name,fp8_mode)
else:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

P1 Badge 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 👍 / 👎.

@danielhanchen
Copy link
Contributor

@andrewor14 Oh thanks - would this be backwards compatible?

@andrewor14
Copy link
ContributorAuthor

Oh thanks - would this be backwards compatible?

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

danielhanchen reacted with hooray emoji

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@Datta0Datta0Datta0 left review comments

@chatgpt-codex-connectorchatgpt-codex-connector[bot]chatgpt-codex-connector[bot] left review comments

+1 more reviewer

@gemini-code-assistgemini-code-assist[bot]gemini-code-assist[bot] left review comments

Reviewers whose approvals may not affect merge requirements

At least 1 approving review is required to merge this pull request.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@andrewor14@danielhanchen@Datta0

[8]ページ先頭

©2009-2025 Movatter.jp