xinhe commited on
Commit
e872564
·
verified ·
1 Parent(s): 2101a06

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +97 -0
README.md ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ base_model:
4
+ - Tongyi-MAI/Z-Image-Turbo
5
+ ---
6
+
7
+ ## Model Details
8
+ This model is an W4A16 model with group_size 128 and symmetric quantization of [Tongyi-MAI/Z-Image-Turbo](https://huggingface.co/Tongyi-MAI/Z-Image-Turbo) generated by [intel/auto-round](https://github.com/intel/auto-round). Please follow the license of the original model.
9
+
10
+
11
+ ## Infernece Example
12
+
13
+ ```bash
14
+ pip install git+https://github.com/xin3he/diffusers@auto_round # A special version for auto-round
15
+ pip install git+https://github.com/intel/auto-round.git@refs/pull/1640/head # A special version for tuning and loading
16
+ ```
17
+
18
+ ```python
19
+ import time
20
+
21
+ import torch
22
+ from diffusers import ZImagePipeline
23
+
24
+ model_path = "INCModel/Z-Image-Turbo-W4A16-AutoRound"
25
+
26
+ # 1. Load the pipeline
27
+ # Use bfloat16 for optimal performance on supported GPUs
28
+ pipe = ZImagePipeline.from_pretrained(
29
+ model_path,
30
+ torch_dtype=torch.bfloat16,
31
+ device_map="cuda", # set device_map="cuda" to leverage gptqmodel kernels
32
+ )
33
+ pipe.to("cuda")
34
+
35
+ # [Optional] Attention Backend
36
+ # Diffusers uses SDPA by default. Switch to Flash Attention for better efficiency if supported:
37
+ # pipe.transformer.set_attention_backend("flash") # Enable Flash-Attention-2
38
+ # pipe.transformer.set_attention_backend("_flash_3") # Enable Flash-Attention-3
39
+
40
+ # [Optional] Model Compilation
41
+ # Compiling the DiT model accelerates inference, but the first run will take longer to compile.
42
+ # pipe.transformer.compile()
43
+
44
+ # [Optional] CPU Offloading
45
+ # Enable CPU offloading for memory-constrained devices.
46
+ # pipe.enable_model_cpu_offload()
47
+
48
+ prompt = "Young Chinese woman in red Hanfu, intricate embroidery. Impeccable makeup, red floral forehead pattern. Elaborate high bun, golden phoenix headdress, red flowers, beads. Holds round folding fan with lady, trees, bird. Neon lightning-bolt lamp, bright yellow glow, above extended left palm. Soft-lit outdoor night background, silhouetted tiered pagoda (??????????), blurred colorful distant lights."
49
+
50
+ # 2. Generate Image
51
+ print("Starting generation...")
52
+ image = pipe(
53
+ prompt=prompt,
54
+ height=1024,
55
+ width=1024,
56
+ num_inference_steps=9, # This actually results in 8 DiT forwards
57
+ guidance_scale=0.0, # Guidance should be 0 for the Turbo models
58
+ generator=torch.Generator("cuda").manual_seed(42),
59
+ ).images[0]
60
+
61
+ image.save("example.png")
62
+ ```
63
+
64
+ ## Generate the Model
65
+
66
+ This pr is required https://github.com/intel/auto-round/pull/1640
67
+
68
+ Tuning version
69
+
70
+ ~~~bash
71
+ CUDA_VISIBLE_DEVICES=6,7 auto-round Tongyi-MAI/Z-Image-Turbo --num_inference_steps 1 --output_dir /workspace/models/Tongyi-MAI/Z-Image-W4A16-AutoRound --device_map 0,1 --low_gpu_mem_usage --enable_torch_compile
72
+ ~~~
73
+
74
+
75
+ ## Ethical Considerations and Limitations
76
+
77
+ The model can produce factually incorrect output, and should not be relied on to produce factually accurate information. Because of the limitations of the pretrained model and the finetuning datasets, it is possible that this model could generate lewd, biased or otherwise offensive outputs.
78
+
79
+ Therefore, before deploying any applications of the model, developers should perform safety testing.
80
+
81
+ ## Caveats and Recommendations
82
+
83
+ Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model.
84
+
85
+ Here are a couple of useful links to learn more about Intel's AI software:
86
+
87
+ - [Intel Neural Compressor](https://github.com/intel/neural-compressor)
88
+
89
+ ## Disclaimer
90
+
91
+ The license on this model does not constitute legal advice. We are not responsible for the actions of third parties who use this model. Please consult an attorney before using this model for commercial purposes.
92
+
93
+ ## Cite
94
+
95
+ @article{cheng2023optimize, title={Optimize weight rounding via signed gradient descent for the quantization of llms}, author={Cheng, Wenhua and Zhang, Weiwei and Shen, Haihao and Cai, Yiyang and He, Xin and Lv, Kaokao and Liu, Yi}, journal={arXiv preprint arXiv:2309.05516}, year={2023} }
96
+
97
+ [arxiv](https://arxiv.org/abs/2309.05516) [github](https://github.com/intel/auto-round)