-
Notifications
You must be signed in to change notification settings - Fork 60
Add diffusion README #923
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
Add diffusion README #923
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
ec1ae2b
add diffusion README
mengniwang95 ec61206
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] a5ce1a1
Update README.md
mengniwang95 5760930
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] a49c09f
Merge branch 'main' into mengni/diffusion_readme
mengniwang95 25611f2
update readme
mengniwang95 fe1ca90
Merge branch 'main' into mengni/diffusion_readme
mengniwang95 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 |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| # AutoRound for Diffusion Models (Experimental) | ||
|
|
||
| This feature is experimental and may be subject to changes, including potential bug fixes, API modifications, or adjustments to default parameters. | ||
|
|
||
| ## Quantization | ||
|
|
||
| ### API Usage (CPU/GPU) Recommended | ||
|
|
||
| By default, AutoRoundDiffusion only quantizes the transformer module of diffusion models and uses `COCO2014 captions` for calibration. | ||
|
|
||
| ```python | ||
| import torch | ||
| from auto_round import AutoRound | ||
| from diffusers import AutoPipelineForText2Image | ||
|
|
||
| # Load the model | ||
| model_name = "black-forest-labs/FLUX.1-dev" | ||
| pipe = AutoPipelineForText2Image.from_pretrained(model_name, torch_dtype=torch.bfloat16) | ||
|
|
||
| # Quantize the model | ||
| autoround = AutoRound( | ||
| pipe, | ||
| scheme="MXFP8", | ||
| dataset="coco2014", | ||
| num_inference_steps=10, | ||
| guidance_scale=7.5, | ||
| generator_seed=None, | ||
| batch_size=1, | ||
| ) | ||
| autoround.quantize() | ||
|
|
||
| # Save the quantized model | ||
| output_dir = "./tmp_autoround" | ||
| # Currently loading the quantized diffusion model is not supported, so use fake format | ||
| autoround.save_quantized(output_dir, format="fake", inplace=True) | ||
| ``` | ||
|
|
||
| - `dataset`: the dataset for quantization training. Currently only support coco2014 and user customized .tsv file. | ||
|
|
||
| - `num_inference_steps`: The reference number of denoising steps. | ||
|
|
||
| - `guidance_scale`: Control how much the image generation process follows the text prompt. The more it is, the more closely it follows the prompt. | ||
|
|
||
| - `generator_seed`: A seed that controls the initial noise from which an image is generated. | ||
|
|
||
| for more hyperparameters introduction, please refer [Homepage Detailed Hyperparameters](../../README.md#api-usage-gaudi2cpugpu) | ||
|
|
||
| ### CLI Usage | ||
|
|
||
| A user guide detailing the full list of supported arguments is provided by calling ```auto-round -h``` on the | ||
| terminal. | ||
|
|
||
| ```bash | ||
| auto-round \ | ||
| --model black-forest-labs/FLUX.1-dev \ | ||
| --scheme MXFP8 \ | ||
| --format fake \ | ||
| --batch_size 1 \ | ||
| --output_dir ./tmp_autoround | ||
| ``` | ||
|
|
||
| ### Diffusion Support Matrix | ||
|
|
||
| For diffusion models, currently we only validate quantizaion on the FLUX.1-dev, which involves quantizing the transformer component of the pipeline. | ||
|
|
||
| | Model | calibration dataset | | ||
| |--------------|--------------| | ||
| | black-forest-labs/FLUX.1-dev | COCO2014 | | ||
|
|
||
|
|
||
|
|
||
| <details> | ||
| <summary style="font-size:17px;">Calibration Dataset</summary> | ||
|
|
||
| For diffusion models, we used [**coco2014**]("https://github.com/mlcommons/inference/raw/refs/heads/master/text_to_image/coco2014/captions/captions_source.tsv") calibration dataset as our default. | ||
|
|
||
| If users want to use their own dataset, please build the dataset file in ".tsv" format following below structure and use it through argument --dataset (tsv file): | ||
| ``` | ||
| id caption | ||
| 0 YOUR_PROMPT | ||
| 1 YOUR_PROMPT | ||
| ... ... | ||
| ``` | ||
| - `id`: The id used to map generated images and prompts. | ||
| - `caption`: The text prompt used to generate the images. | ||
|
|
||
|
|
||
| </details> | ||
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 |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| Step-by-Step | ||
| ============ | ||
|
|
||
| This document presents step-by-step instructions for auto-round llm quantization. For vlms quantization, please refer to [vlms user guide](../auto_round/mllm/README.md) | ||
| This document presents step-by-step instructions for auto-round llm quantization. You can refer to [vlms user guide](../auto_round/compressors/mllm/README.md) for vlms quantization and [diffusions user guide](../auto_round/compressors/diffusion/README.md) for diffusions quantization. | ||
|
Contributor
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. @n1ck-guo please refine the mllm doc following the comments in this pr |
||
|
|
||
| * [1 Prerequisite](#1-prerequisite) | ||
| * [2 Prepare Calibration Dataset](#2-prepare-calibration-dataset) | ||
|
|
||
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.
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.
link this file to step_by_step.md
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