-
Notifications
You must be signed in to change notification settings - Fork 6.2k
[Single File] Add GGUF support #9964
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
51 commits
Select commit
Hold shift + click to select a range
b5eeaa4
update
DN6 71897b1
update
DN6 89ea1ee
update
DN6 f0bcd94
update
DN6 60d1385
update
DN6 22ed0b0
update
DN6 2e6d340
update
DN6 b5f927c
update
DN6 b9666c7
Merge branch 'main' into gguf-support
DN6 6dc5d22
update
DN6 428e44b
update
DN6 d7f09f2
update
DN6 1649936
update
DN6 28d3a64
update
DN6 c34a451
update
DN6 84493db
update
DN6 50bd784
update
DN6 8f604b3
Merge branch 'main' into gguf-support
DN6 afd5d7d
update
DN6 e1b964a
Merge branch 'main' into gguf-support
sayakpaul 0ed31bc
update
DN6 af381ad
update
DN6 52a1bcb
update
DN6 66ae46e
Merge branch 'gguf-support' of https://github.com/huggingface/diffuse…
DN6 67f1700
update
DN6 8abfa55
update
DN6 d4b88d7
update
DN6 30f13ed
update
DN6 9310035
update
DN6 e9303a0
update
DN6 e56c266
update
DN6 1209c3a
Update src/diffusers/quantizers/gguf/utils.py
DN6 db9b6f3
update
DN6 4c0360a
Merge branch 'gguf-support' of https://github.com/huggingface/diffuse…
DN6 aa7659b
Merge branch 'main' into gguf-support
DN6 78c7861
update
DN6 33eb431
update
DN6 9651ddc
update
DN6 746fd2f
update
DN6 e027d46
update
DN6 9db2396
update
DN6 7ee89f4
update
DN6 edf3e54
update
DN6 d3eb54f
update
DN6 82606cb
Merge branch 'main' into gguf-support
sayakpaul 4f34f14
Update docs/source/en/quantization/gguf.md
DN6 090efdb
update
DN6 391b5a9
Merge branch 'main' into gguf-support
DN6 e67c25a
update
DN6 e710bde
update
DN6 f59e07a
update
DN6 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,10 +13,19 @@ specific language governing permissions and limitations under the License. | |
|
||
# GGUF | ||
|
||
The GGUF file format is typically used to store models for inference with [GGML]() and supports a variety of block wise quantization options. Diffusers supports loading checkpoints prequantized and saved in the GGUF format via `from_single_file` loading with Model classes. Support for loading GGUF checkpoint via Pipelines is currently not supported. The dequantizatation functions used for dynamic dequantizatation are based on the great work done by [city96](https://github.com/city96/ComfyUI-GGUF) | ||
The GGUF file format is typically used to store models for inference with [GGML](https://github.com/ggerganov/ggml) and supports a variety of block wise quantization options. Diffusers supports loading checkpoints prequantized and saved in the GGUF format via `from_single_file` loading with Model classes. Loading GGUF checkpoints via Pipelines is currently not supported. | ||
|
||
The following example will load the [FLUX.1 DEV](https://huggingface.co/black-forest-labs/FLUX.1-dev) transformer model using the GGUF Q2_K quantization variant. | ||
|
||
Before starting please install gguf in your environment | ||
|
||
```shell | ||
pip install -U gguf | ||
``` | ||
|
||
Since GGUF is a single file format, we will be using `from_single_file` to load the model and pass in the `GGUFQuantizationConfig` when loading the model. | ||
|
||
When using GGUF checkpoints, the quantized weights remain in a low memory `dtype`, typically `torch.unint8` and are dynamically dequantized and cast to the configured `compute_dtype` when running a forward pass through each module in the model. The `GGUFQuantizationConfig` allows you to set the `compute_dtype` for the forward pass of each module. The functions used for dynamic dequantizatation are based on the great work done by [city96](https://github.com/city96/ComfyUI-GGUF) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A lot of the pytorch dequantization code is based on the numpy code from llama.cpp written by @compilade - I believe he should be credited here as well :) |
||
|
||
```python | ||
import torch | ||
|
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
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
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.