WaveCut commited on
Commit
3088801
·
verified ·
1 Parent(s): 0b6ebf9

Add model card and comparison assets

Browse files
.gitattributes CHANGED
@@ -34,3 +34,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
  tokenizer/tokenizer.json filter=lfs diff=lfs merge=lfs -text
 
 
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
  tokenizer/tokenizer.json filter=lfs diff=lfs merge=lfs -text
37
+ assets/flux2-sdnq-uint4-static-comparison.webp filter=lfs diff=lfs merge=lfs -text
LICENSE.md ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FLUX Non-Commercial License v2.1
2
+
3
+ Black Forest Labs Inc. (“we” or “our” or “Company”) is pleased to make the weights, parameters, and inference code for the FLUX Model (as defined below) freely available for your non-commercial and non-production use as set forth in this FLUX Non-Commercial License (“License”). “FLUX Model” includes, individually and collectively, the models denoted as FLUX.x [dev], where “.x” denotes the FLUX Model version number, and models made available under the License, as indicated by a license notice that is included in or attached to the work, and their elements which includes algorithms, software, checkpoints, parameters, source code (inference code, evaluation code, and if applicable, fine-tuning code) and any other materials associated with the FLUX AI models made available by Company under this License, including if any, the technical documentation, manuals, and instructions for the use and operation thereof. Note that we may also make available certain elements of what is included in the definition of “FLUX Model” under a separate license, such as the inference code, and nothing in this License will be deemed to restrict or limit any other licenses granted by us in such elements.
4
+
5
+ By downloading, accessing, using, Distributing (as defined below), or creating a Derivative (as defined below) of the FLUX Model, you agree to the terms of this License. If you do not agree to this License, then you do not have any rights to access, use, Distribute or create a Derivative of the FLUX Model and you must immediately cease using the FLUX Model. If you are agreeing to be bound by the terms of this License on behalf of your employer or other entity, you represent and warrant to us that you have full legal authority to bind your employer or such entity to this License. If you do not have the requisite authority, you may not accept the License or access the FLUX Model on behalf of your employer or other entity.
6
+
7
+ 1. Definitions.
8
+ - a. “Derivative” means any (i) modified version of the FLUX Model (including but not limited to any customized or fine-tuned version thereof), (ii) work based on the FLUX Model, or (iii) any other derivative work thereof. For the avoidance of doubt, Outputs are not considered Derivatives under this License.
9
+ - b. “Distribution” or “Distribute” or “Distributing” means providing or making available, by any means, a copy of the FLUX Model and/or the Derivatives as the case may be.
10
+ - c. “Non-Commercial Purpose” means any of the following uses, but only so far as you do not receive any direct or indirect payment arising from the use of the FLUX Model, Derivatives, or Content Filters (as defined below): (i) personal use for research, experimentation, and testing for the benefit of public knowledge, personal study, private entertainment, hobby projects, or otherwise not directly or indirectly connected to any commercial activities, business operations, or employment responsibilities; (ii) use by commercial or for-profit entities for testing, evaluation, or non-commercial research and development in a non-production environment; and (iii) use by any charitable organization for charitable purposes, or for testing or evaluation. For clarity, use (a) for revenue-generating activity, (b) in direct interactions with or that has impact on end users, or (c) to train, fine tune, or distill other models for commercial use, in each case, is not a Non-Commercial Purpose.
11
+ - d. “Outputs” means any content generated by the operation of the FLUX Model or Derivatives from an input (such as an image input) or prompt (i.e., text instructions) provided by users. For the avoidance of doubt, Outputs do not include any components of the FLUX Model, such as any fine-tuned versions of the FLUX Model, the weights, or parameters.
12
+ - e. “you” or “your” means the individual or entity entering into this License with Company.
13
+
14
+ 2. License Grant.
15
+ - a. License. Subject to your compliance with this License, Company grants you a non-exclusive, worldwide, non-transferable, non-sublicensable, revocable, royalty free, and limited license to access, use, create Derivatives of, and Distribute the FLUX Model and Derivatives solely for your Non-Commercial Purposes. The foregoing license is personal to you, and you may not assign or sublicense this License or any other rights or obligations under this License without Company’s prior written consent; any such assignment or sublicense will be void and will automatically and immediately terminate this License. Any restrictions set forth herein regarding the FLUX Model also apply to any Derivative you create or that are created on your behalf.
16
+ - b. Non-Commercial Use Only. You may only access, use, Distribute, or create Derivatives of the FLUX Model or Derivatives for Non-Commercial Purposes. If you want to use a FLUX Model or a Derivative for any purpose that is not expressly authorized under this License, such as for a commercial activity, you must request a license from Company, which Company may grant to you in Company’s sole discretion and which additional use may be subject to a fee, royalty or other revenue share. Please see https://bfl.ai/licensing if you would like a commercial license.
17
+ - c. Reserved Rights. The grant of rights expressly set forth in this License are the complete grant of rights to use the FLUX Model, and no other licenses are granted, whether by waiver, estoppel, implication, equity, or otherwise. Company and its licensors reserve all rights not expressly granted by this License.
18
+ - d. Outputs. We claim no ownership rights in and to the Outputs. You are solely responsible for the Outputs you generate and their subsequent uses in accordance with this License. You may use Output for any purpose (including for commercial purposes), except as expressly prohibited herein. You may not use the Output to train, fine-tune, or distill a model that is competitive with a FLUX Model.
19
+ - e. You may access, use, Distribute, or create Output of the FLUX Model or Derivatives if you: (i) (A) implement and maintain content filtering measures (“Content Filters”) for your use of the FLUX Model or Derivatives to prevent the creation, display, transmission, generation, or dissemination of unlawful or infringing content, which may include Content Filters that we may make available for use with the FLUX Model (“Provided Content Filters”), or (B) ensure Output undergoes review for unlawful or infringing content before public or non-public distribution, display, transmission or dissemination; and (ii) ensure Output includes disclosure (or other indication) that the Output was generated or modified using artificial intelligence technologies to the extent required under applicable law.
20
+
21
+ 3. Distribution. Subject to this License, you may Distribute copies of the FLUX Model and/or Derivatives made by you, under the following conditions:
22
+ - a. you must make available a copy of this License to third-party recipients of the FLUX Mode and/or Derivatives you Distribute, and specify that any rights to use the FLUX Model and/or Derivatives shall be directly granted by Company to said third-party recipients pursuant to this License;
23
+ - b. you must prominently display the following notice alongside the Distribution of the FLUX Model or Derivative (such as via a “Notice” text file distributed as part of such FLUX Model or Derivative) (the “Attribution Notice”):
24
+
25
+ > This FLUX Model is licensed by Black Forest Labs Inc. under the FLUX Non-Commercial License. Copyright Black Forest Labs Inc. IN NO EVENT SHALL BLACK FOREST LABS INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH USE OF THIS MODEL.
26
+
27
+ - c. in the case of Distribution of Derivatives made by you: (i) you must also include in the Attribution Notice a statement that you have modified the applicable FLUX Model; (ii) any terms and conditions you impose on any third-party recipients relating to Derivatives made by or for you shall neither limit such third-party recipients’ use of the FLUX Model or any Derivatives made by or for Company in accordance with this License nor conflict with any of its terms and conditions and must include disclaimer of warranties and limitation of liability provisions that are at least as protective of Company as those set forth herein; and (iii) you must not misrepresent or imply, through any means, that the Derivatives made by or for you and/or any modified version of the FLUX Model you Distribute under your name and responsibility is an official product of the Company or has been endorsed, approved or validated by the Company, unless you are authorized by Company to do so in writing.
28
+
29
+ 4. Restrictions. You will not, and will not permit, assist or cause any third party to
30
+ - a. use, modify, copy, reproduce, create Derivatives of, or Distribute the FLUX Model (or any Derivative thereof, or any data produced by the FLUX Model), in whole or in part, (i) for any commercial or production purposes, (ii) military purposes, (iii) purposes of surveillance, including any research or development relating to surveillance, (iv) biometric processing, (v) in any manner that infringes, misappropriates, or otherwise violates (or is likely to infringe, misappropriate, or otherwise violate) any third party’s legal rights, including rights of publicity or “digital replica” rights, (vi) in any unlawful, fraudulent, defamatory, or abusive activity, (vii) to generate unlawful content, including child sexual abuse material, or non-consensual intimate images; or (viii) in any manner that violates any applicable law and any privacy or security laws, rules, regulations, directives, or governmental requirements (including the General Data Privacy Regulation (Regulation (EU) 2016/679), the California Consumer Privacy Act, any and all laws governing the processing of biometric information, and the EU Artificial Intelligence Act (Regulation (EU) 2024/1689), as well as all amendments and successor laws to any of the foregoing);
31
+ - b. alter or remove copyright and other proprietary notices which appear on or in any portion of the FLUX Model;
32
+ - c. utilize any equipment, device, software, or other means to circumvent or remove any security or protection used by Company in connection with the FLUX Model, or to circumvent or remove any usage restrictions, or to enable functionality disabled by FLUX Model;
33
+ - d. offer or impose any terms on the FLUX Model that alter, restrict, or are inconsistent with the terms of this License;
34
+ - e. violate any applicable U.S. and non-U.S. export control and trade sanctions laws (“Export Laws”) in connection with your use or Distribution of any FLUX Model;
35
+ - f. directly or indirectly Distribute, export, or otherwise transfer FLUX Model (i) to any individual, entity, or country prohibited by Export Laws; (ii) to anyone on U.S. or non-U.S. government restricted parties lists; (iii) for any purpose prohibited by Export Laws, including nuclear, chemical or biological weapons, or missile technology applications; (iv) use or download FLUX Model if you or they are (a) located in a comprehensively sanctioned jurisdiction, (b) currently listed on any U.S. or non-U.S. restricted parties list, or (c) for any purpose prohibited by Export Laws; and (v) will not disguise your location through IP proxying or other methods.
36
+
37
+ 5. DISCLAIMERS. THE FLUX MODEL AND PROVIDED CONTENT FILTERS ARE PROVIDED “AS IS” AND “WITH ALL FAULTS” WITH NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED. COMPANY EXPRESSLY DISCLAIMS ALL REPRESENTATIONS AND WARRANTIES, EXPRESS OR IMPLIED, WHETHER BY STATUTE, CUSTOM, USAGE OR OTHERWISE AS TO ANY MATTERS RELATED TO THE FLUX MODEL AND PROVIDED CONTENT FILTERS, INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE, SATISFACTORY QUALITY, OR NON-INFRINGEMENT. COMPANY MAKES NO WARRANTIES OR REPRESENTATIONS THAT THE FLUX MODEL AND PROVIDED CONTENT FILTERS WILL BE ERROR FREE OR FREE OF VIRUSES OR OTHER HARMFUL COMPONENTS, OR PRODUCE ANY PARTICULAR RESULTS.
38
+
39
+ 6. LIMITATION OF LIABILITY. TO THE FULLEST EXTENT PERMITTED BY LAW, IN NO EVENT WILL COMPANY BE LIABLE TO YOU OR YOUR EMPLOYEES, AFFILIATES, USERS, OFFICERS OR DIRECTORS (A) UNDER ANY THEORY OF LIABILITY, WHETHER BASED IN CONTRACT, TORT, NEGLIGENCE, STRICT LIABILITY, WARRANTY, OR OTHERWISE UNDER THIS LICENSE, OR (B) FOR ANY INDIRECT, CONSEQUENTIAL, EXEMPLARY, INCIDENTAL, PUNITIVE OR SPECIAL DAMAGES OR LOST PROFITS, EVEN IF COMPANY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. THE FLUX MODEL, ITS CONSTITUENT COMPONENTS, PROVIDED CONTENT FILTERS, AND ANY OUTPUT (COLLECTIVELY, “MODEL MATERIALS”) ARE NOT DESIGNED OR INTENDED FOR USE IN ANY APPLICATION OR SITUATION WHERE FAILURE OR FAULT OF THE MODEL MATERIALS COULD REASONABLY BE ANTICIPATED TO LEAD TO SERIOUS INJURY OF ANY PERSON, INCLUDING POTENTIAL DISCRIMINATION OR VIOLATION OF AN INDIVIDUAL’S PRIVACY RIGHTS, OR TO SEVERE PHYSICAL, PROPERTY, OR ENVIRONMENTAL DAMAGE (EACH, A “HIGH-RISK USE”). IF YOU ELECT TO USE ANY OF THE MODEL MATERIALS FOR A HIGH-RISK USE, YOU DO SO AT YOUR OWN RISK. YOU AGREE TO DESIGN AND IMPLEMENT APPROPRIATE DECISION-MAKING AND RISK-MITIGATION PROCEDURES AND POLICIES IN CONNECTION WITH A HIGH-RISK USE SUCH THAT EVEN IF THERE IS A FAILURE OR FAULT IN ANY OF THE MODEL MATERIALS, THE SAFETY OF PERSONS OR PROPERTY AFFECTED BY THE ACTIVITY STAYS AT A LEVEL THAT IS REASONABLE, APPROPRIATE, AND LAWFUL FOR THE FIELD OF THE HIGH-RISK USE.
40
+
41
+ 7. INDEMNIFICATION. You will indemnify, defend and hold harmless Company and our subsidiaries and affiliates, and each of our respective shareholders, directors, officers, employees, agents, successors, and assigns (collectively, the “Company Parties”) from and against any losses, liabilities, damages, fines, penalties, and expenses (including reasonable attorneys’ fees) incurred by any Company Party in connection with any claim, demand, allegation, lawsuit, proceeding, or investigation (collectively, “Claims”) arising out of or related to (a) your access to or use of the FLUX Model (including in connection with any Output, results or data generated from such access or use, or from your access or use of any Content Filters), including any High-Risk Use; (b) your Content Filters, including your failure to implement any Content Filters where required by this License such as in Section 2(e); (c) your violation of this License; or (d) your violation, misappropriation or infringement of any rights of another (including intellectual property or other proprietary rights and privacy rights). You will promptly notify the Company Parties of any such Claims, and cooperate with Company Parties in defending such Claims. You will also grant the Company Parties sole control of the defense or settlement, at Company’s sole option, of any Claims. This indemnity is in addition to, and not in lieu of, any other indemnities or remedies set forth in a written agreement between you and Company or the other Company Parties.
42
+
43
+ 8. Termination; Survival.
44
+ a. This License will automatically terminate upon any breach by you of the terms of this License.
45
+ b. We may terminate this License, in whole or in part, at any time upon notice (including electronic) to you.
46
+ c. If you initiate any legal action or proceedings against Company or any other entity (including a cross-claim or counterclaim in a lawsuit), alleging that the FLUX Model, any Derivative, or Provided Content Filters, or any part thereof, infringe upon intellectual property or other rights owned or licensable by you, then any licenses granted to you under this License will immediately terminate as of the date such legal action or claim is filed or initiated.
47
+ d. Upon termination of this License, you must cease all use, access or Distribution of the FLUX Model, any Derivatives, and any Provided Content Filters. The following sections survive termination of this License: 2(c), 2(d), 4-11.
48
+
49
+ 9. Third Party Materials. The FLUX Model and Provided Content Filters may contain third-party software or other components (including free and open source software) (all of the foregoing, “Third Party Materials”), which are subject to the license terms of the respective third-party licensors. Your dealings or correspondence with third parties and your use of or interaction with any Third Party Materials are solely between you and the third party. Company does not control or endorse, and makes no representations or warranties regarding, any Third Party Materials, and your access to and use of such Third Party Materials are at your own risk.
50
+
51
+ 10. Trademarks. You have not been granted any trademark license as part of this License and may not use any name, logo or trademark associated with Company without the prior written permission of Company, except to the extent necessary to make the reference required in the Attribution Notice as specified above or as is reasonably necessary in describing the FLUX Model and its creators.
52
+
53
+ 11. General. This License will be governed and construed under the laws of the State of Delaware without regard to conflicts of law provisions. If any provision or part of a provision of this License is unlawful, void or unenforceable, that provision or part of the provision is deemed severed from this License, and will not affect the validity and enforceability of any remaining provisions. The failure of Company to exercise or enforce any right or provision of this License will not operate as a waiver of such right or provision. This License does not confer any third-party beneficiary rights upon any other person or entity. This License, together with the documentation, contains the entire understanding between you and Company regarding the subject matter of this License, and supersedes all other written or oral agreements and understandings between you and Company regarding such subject matter.
README.md ADDED
@@ -0,0 +1,278 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ license: other
5
+ license_name: flux-non-commercial-license
6
+ license_link: LICENSE.md
7
+ base_model:
8
+ - black-forest-labs/FLUX.2-klein-9B
9
+ base_model_relation: quantized
10
+ library_name: diffusers
11
+ pipeline_tag: text-to-image
12
+ tags:
13
+ - image-generation
14
+ - image-editing
15
+ - flux
16
+ - flux2
17
+ - Flux2KleinPipeline
18
+ - sdnq
19
+ - 4-bit
20
+ - uint4
21
+ - quantized
22
+ - diffusers
23
+ ---
24
+
25
+ # FLUX.2 Klein 9B SDNQ UINT4 Static
26
+
27
+ Static UINT4 SDNQ quantization of
28
+ [black-forest-labs/FLUX.2-klein-9B](https://huggingface.co/black-forest-labs/FLUX.2-klein-9B).
29
+
30
+ This checkpoint was selected as a practical deployment-oriented variant because
31
+ it was the fastest option in the A40 benchmark and used substantially less VRAM
32
+ than the original BF16 pipeline, while visual quality differences were minor in
33
+ the prompt-following stress comparison.
34
+
35
+ ![Full resolution comparison canvas](assets/flux2-sdnq-uint4-static-comparison.webp)
36
+
37
+ The image above is a compressed WebP version of a 1:1 comparison canvas. It
38
+ contains the original FLUX.2 Klein 9B, the previous SDNQ baseline, this
39
+ `uint4-static` checkpoint, and a quality-oriented dynamic SVD candidate across
40
+ text-heavy prompts including an additional Russian-only chalkboard prompt.
41
+
42
+ ## Why This Variant
43
+
44
+ We compared broad SDNQ 4-bit recipes across speed, VRAM, and visual quality.
45
+ This `uint4-static` recipe was chosen because it gives the best deployment
46
+ tradeoff:
47
+
48
+ - Lowest latency among the final candidates in the corrected single-process
49
+ top-5 rebenchmark.
50
+ - Low runtime VRAM in a 1024x1024, 4-step image-generation pipeline.
51
+ - Much smaller full-pipeline checkpoint footprint than the original BF16
52
+ FLUX.2 Klein 9B checkpoint in the measured setup.
53
+ - Visual differences versus the baseline and the original model were small in
54
+ the stress set, including long text, signs, labels, small details, and a
55
+ Russian chalkboard prompt.
56
+
57
+ ## Benchmark Setup
58
+
59
+ All numbers below are from a single NVIDIA A40 test host and were measured with
60
+ a consistent `Flux2KleinPipeline` inference harness.
61
+
62
+ - GPU: NVIDIA A40 46 GB
63
+ - Resolution: 1024x1024
64
+ - Steps: 4
65
+ - Guidance scale: 0.0
66
+ - Torch dtype: bfloat16
67
+ - Quantized matmul: enabled for SDNQ inference comparisons
68
+ - Batch/concurrency: single process for the corrected VRAM numbers
69
+
70
+ These are deployment-oriented measurements for one hardware/software setup, not
71
+ universal minimum requirements.
72
+
73
+ ## Corrected Top-5 Rebenchmark
74
+
75
+ The first speed screen was run in parallel with two processes per A40, which
76
+ made `nvidia-smi memory.used` peaks look too high. The table below uses the
77
+ corrected single-process rebenchmark.
78
+
79
+ | Variant | Warm avg | GPU peak | CUDA allocated |
80
+ | --- | ---: | ---: | ---: |
81
+ | `uint4-static` | 3.826 s | 14.8 GB | 14.1 GB |
82
+ | `int4-dynamic-th0p1-svd-r16-s32-g128` | 4.020 s | 14.3 GB | 13.5 GB |
83
+ | `uint4-static-svd-r32-s32` | 4.070 s | 14.7 GB | 13.9 GB |
84
+ | `float4_e4m0fnu-dynamic-th0p1-svd-r16-s32` | 4.116 s | 16.0 GB | 15.3 GB |
85
+ | `float4_e4m0fnu-dynamic-th0p01-svd-r128-s32` | 4.185 s | 17.2 GB | 16.5 GB |
86
+
87
+ ## Text And Detail Stress Comparison
88
+
89
+ This stress set contains 9 prompts with signs, chalkboards, posters, labels,
90
+ timetables, small props, and a Russian-only chalkboard prompt. Each row was run
91
+ twice; the table reports the warm run average.
92
+
93
+ | Model | Warm avg | GPU peak | CUDA allocated | Prompt count |
94
+ | --- | ---: | ---: | ---: | ---: |
95
+ | Original `FLUX.2-klein-9B` BF16 pipeline | 4.244 s | 36.3 GB | 35.6 GB | 9 |
96
+ | Previous SDNQ baseline | 4.079 s | 15.2 GB | 14.5 GB | 9 |
97
+ | This `uint4-static` checkpoint | 3.866 s | 14.8 GB | 14.1 GB | 9 |
98
+ | Dynamic SVD r128 quality candidate | 4.182 s | 17.2 GB | 16.5 GB | 9 |
99
+
100
+ The full-resolution HTML table and original JPEG canvas were used for visual
101
+ review. The model-card image is a WebP copy optimized from that canvas:
102
+
103
+ | WebP quality | Size | RGB PSNR | Luma SSIM-like score |
104
+ | ---: | ---: | ---: | ---: |
105
+ | 85 | 5.72 MB | 46.93 dB | 0.999977 |
106
+
107
+ The source JPEG canvas was about 13 MB, so the card image is much smaller while
108
+ remaining visually very close to the original artifact.
109
+
110
+ ## Model Size
111
+
112
+ Approximate full-pipeline folder sizes in the measured setup:
113
+
114
+ | Checkpoint | Folder size |
115
+ | --- | ---: |
116
+ | Original `black-forest-labs/FLUX.2-klein-9B` | 52.9 GB |
117
+ | Previous SDNQ baseline | 12.6 GB |
118
+ | This `uint4-static` checkpoint | 12.2 GB |
119
+ | Dynamic SVD r128 candidate | 14.7 GB |
120
+
121
+ ## Usage
122
+
123
+ Install current Diffusers and SDNQ:
124
+
125
+ ```bash
126
+ pip install git+https://github.com/huggingface/diffusers.git
127
+ pip install sdnq
128
+ ```
129
+
130
+ Run with `Flux2KleinPipeline`:
131
+
132
+ ```python
133
+ import torch
134
+ from diffusers import Flux2KleinPipeline
135
+ from sdnq import SDNQConfig # registers SDNQ support in diffusers/transformers
136
+ from sdnq.common import use_torch_compile as triton_is_available
137
+ from sdnq.loader import apply_sdnq_options_to_model
138
+
139
+ repo_id = "WaveCut/FLUX.2-klein-9B-SDNQ-uint4-static"
140
+ device = "cuda"
141
+
142
+ pipe = Flux2KleinPipeline.from_pretrained(
143
+ repo_id,
144
+ torch_dtype=torch.bfloat16,
145
+ )
146
+
147
+ if triton_is_available and torch.cuda.is_available():
148
+ pipe.transformer = apply_sdnq_options_to_model(
149
+ pipe.transformer,
150
+ use_quantized_matmul=True,
151
+ )
152
+ pipe.text_encoder = apply_sdnq_options_to_model(
153
+ pipe.text_encoder,
154
+ use_quantized_matmul=True,
155
+ )
156
+
157
+ pipe.to(device)
158
+
159
+ prompt = "A clean editorial poster with large readable text: OPEN SOURCE IMAGE MODEL"
160
+ image = pipe(
161
+ prompt=prompt,
162
+ height=1024,
163
+ width=1024,
164
+ num_inference_steps=4,
165
+ guidance_scale=0.0,
166
+ generator=torch.Generator(device=device).manual_seed(0),
167
+ ).images[0]
168
+
169
+ image.save("flux2-klein-sdnq-uint4-static.png")
170
+ ```
171
+
172
+ The same pipeline also supports image editing:
173
+
174
+ ```python
175
+ from diffusers.utils import load_image
176
+
177
+ input_image = load_image("input.png")
178
+ image = pipe(
179
+ image=input_image,
180
+ prompt="Turn the handwritten sign into a clean printed sign while preserving the scene",
181
+ height=1024,
182
+ width=1024,
183
+ num_inference_steps=4,
184
+ guidance_scale=0.0,
185
+ generator=torch.Generator(device=device).manual_seed(1),
186
+ ).images[0]
187
+ image.save("flux2-klein-sdnq-uint4-static-edit.png")
188
+ ```
189
+
190
+ If your GPU has less VRAM, replace `pipe.to(device)` with
191
+ `pipe.enable_model_cpu_offload()`.
192
+
193
+ ## Quantization Recipe
194
+
195
+ This checkpoint was produced with SDNQ post-load quantization over the
196
+ `transformer` and `text_encoder` components of FLUX.2 Klein 9B.
197
+
198
+ Recipe:
199
+
200
+ ```python
201
+ variant = {
202
+ "weights_dtype": "uint4",
203
+ "use_dynamic_quantization": False,
204
+ "dynamic_loss_threshold": None,
205
+ "use_svd": False,
206
+ "svd_rank": 32, # unused because use_svd is False
207
+ "svd_steps": 8, # unused because use_svd is False
208
+ "group_size": 0,
209
+ "dequantize_fp32": False,
210
+ "quantized_matmul_dtype": None,
211
+ "use_quantized_matmul": False,
212
+ "use_stochastic_rounding": False,
213
+ }
214
+ ```
215
+
216
+ Minimal quantization sketch:
217
+
218
+ ```python
219
+ import torch
220
+ from diffusers import Flux2KleinPipeline
221
+ from sdnq import sdnq_post_load_quant
222
+ from sdnq.loader import save_sdnq_model
223
+
224
+ base_model = "black-forest-labs/FLUX.2-klein-9B"
225
+ pipe = Flux2KleinPipeline.from_pretrained(
226
+ base_model,
227
+ torch_dtype=torch.bfloat16,
228
+ )
229
+
230
+ common_kwargs = dict(
231
+ weights_dtype="uint4",
232
+ torch_dtype=torch.bfloat16,
233
+ group_size=0,
234
+ svd_rank=32,
235
+ svd_steps=8,
236
+ dynamic_loss_threshold=None,
237
+ use_svd=False,
238
+ quant_conv=False,
239
+ quant_embedding=False,
240
+ use_quantized_matmul=False,
241
+ use_quantized_matmul_conv=False,
242
+ use_dynamic_quantization=False,
243
+ use_stochastic_rounding=False,
244
+ dequantize_fp32=False,
245
+ non_blocking=True,
246
+ add_skip_keys=True,
247
+ quantization_device="cuda",
248
+ return_device="cuda",
249
+ )
250
+
251
+ pipe.transformer = sdnq_post_load_quant(pipe.transformer, **common_kwargs)
252
+ pipe.text_encoder = sdnq_post_load_quant(pipe.text_encoder, **common_kwargs)
253
+
254
+ save_sdnq_model(
255
+ pipe,
256
+ "FLUX.2-klein-9B-SDNQ-uint4-static",
257
+ max_shard_size="5GB",
258
+ is_pipeline=True,
259
+ )
260
+ ```
261
+
262
+ ## Limitations
263
+
264
+ - This is a quantized derivative of FLUX.2 Klein 9B; it inherits the base
265
+ model's limitations and acceptable-use requirements.
266
+ - Text rendering can still be inaccurate, especially for long strings or small
267
+ background text.
268
+ - The quality comparison here is visual prompt-following review, not a
269
+ large-scale human preference or FID benchmark.
270
+ - Benchmarks were run on an A40 test host and should be validated again for
271
+ your exact serving stack.
272
+
273
+ ## License
274
+
275
+ This model is a quantized derivative of
276
+ [black-forest-labs/FLUX.2-klein-9B](https://huggingface.co/black-forest-labs/FLUX.2-klein-9B)
277
+ and follows the FLUX Non-Commercial License. Please review `LICENSE.md` and the
278
+ Black Forest Labs acceptable-use policy before use.
assets/final-top5-summary.csv ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ variant,prompt_count,runs,first_seconds,warm_avg_seconds,warm_min_seconds,warm_max_seconds,gpu_peak_mb,cuda_max_allocated_mb,gpu_load_peak_mb,maxrss_mb
2
+ baseline,5,2,41.33406836446375,4.076407670043409,4.061277890577912,4.090787582099438,15191.0,14463.91796875,11759.0,19721.9765625
3
+ uint4-static,5,2,23.01403909549117,3.8258063884245024,3.8207358438521624,3.8303871555253863,14807.0,14074.35546875,11045.0,18909.65234375
4
+ int4-dynamic-th0p1-svd-r16-s32-g128,5,2,26.136765606701374,4.019561266009179,4.0076204324141145,4.050093832425773,14267.0,13540.10546875,11357.0,17898.3671875
5
+ uint4-static-svd-r32-s32,5,2,24.725356460548937,4.069596313561003,4.057041662745178,4.09303140360862,14677.0,13939.85546875,11391.0,18759.23828125
6
+ float4_e4m0fnu-dynamic-th0p1-svd-r16-s32,5,2,36.09520728699863,4.116074575732152,4.103897335939109,4.134285475127399,16021.0,15291.35546875,12051.0,21359.40234375
7
+ float4_e4m0fnu-dynamic-th0p01-svd-r128-s32,5,2,35.37363956775516,4.184757313070198,4.173255986534059,4.212017542682588,17191.0,16455.10546875,14281.0,23934.69140625
assets/flux2-sdnq-uint4-static-comparison.webp ADDED

Git LFS Details

  • SHA256: d84411e197a8bd3f644f1a8b20574f22e4b9774d37ed7506adeda610d4e3f231
  • Pointer size: 132 Bytes
  • Size of remote file: 6 MB
assets/quality-stress-summary.csv ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ cuda_max_allocated_mb,first_seconds,gpu_load_peak_mb,gpu_peak_mb,maxrss_mb,prompt_count,runs,variant,warm_avg_seconds,warm_max_seconds,warm_min_seconds
2
+ 35556.35546875,4.715450732037425,33383.0,36293.0,10367.96875,9,2,original-flux2-klein-9b,4.244085428925852,4.37537744641304,4.189825661480427
3
+ 14463.91796875,41.665682481601834,30935.0,15191.0,20625.06640625,9,2,baseline,4.079271021402544,4.11067720502615,4.060629941523075
4
+ 14074.35546875,22.93841202184558,11897.0,14809.0,20719.39453125,9,2,uint4-static,3.8660740761293306,4.078776756301522,3.826545525342226
5
+ 16455.10546875,35.107925665564835,14155.0,17193.0,25905.3203125,9,2,float4_e4m0fnu-dynamic-th0p01-svd-r128-s32,4.181900700243811,4.191505083814263,4.1687538689002395
assets/webp-compression-sweep.csv ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ quality,bytes,size_mb,psnr_rgb,ssim_luma_global,path
2
+ 60,2907602,2.7729053497314453,42.78653817938348,0.9999347077990188,results/model-card-assets/flux2-sdnq-uint4-static-comparison-q60.webp
3
+ 70,3260514,3.109468460083008,43.691074601453025,0.9999478724634654,results/model-card-assets/flux2-sdnq-uint4-static-comparison-q70.webp
4
+ 75,3503270,3.3409786224365234,44.19895846379671,0.9999546481667871,results/model-card-assets/flux2-sdnq-uint4-static-comparison-q75.webp
5
+ 80,4755716,4.535404205322266,45.47553636376561,0.9999669784137255,results/model-card-assets/flux2-sdnq-uint4-static-comparison-q80.webp
6
+ 82,5223292,4.981319427490234,46.08683415497053,0.9999711708543075,results/model-card-assets/flux2-sdnq-uint4-static-comparison-q82.webp
7
+ 85,5998938,5.721033096313477,46.925268863342005,0.999976667295406,results/model-card-assets/flux2-sdnq-uint4-static-comparison-q85.webp
8
+ 88,7324046,6.98475456237793,48.06721911479202,0.999982005064194,results/model-card-assets/flux2-sdnq-uint4-static-comparison-q88.webp
9
+ 90,8235904,7.8543701171875,48.95557436761949,0.9999847232253969,results/model-card-assets/flux2-sdnq-uint4-static-comparison-q90.webp
10
+ 92,9491614,9.051908493041992,49.57852939898273,0.9999869181369917,results/model-card-assets/flux2-sdnq-uint4-static-comparison-q92.webp
11
+ 95,12017382,11.460668563842773,51.127060893163474,0.9999896532336908,results/model-card-assets/flux2-sdnq-uint4-static-comparison-q95.webp