xinhe commited on
Commit
9e315d4
·
verified ·
1 Parent(s): d8735ee

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +101 -0
README.md ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ base_model:
4
+ - Tongyi-MAI/Z-Image
5
+ tags:
6
+ - auto-round
7
+ ---
8
+
9
+ ## Model Details
10
+ This model is an W4A16 model with group_size 128 and symmetric quantization of [Tongyi-MAI/Z-Image](https://huggingface.co/Tongyi-MAI/Z-Image) generated by [intel/auto-round](https://github.com/intel/auto-round). Please follow the license of the original model.
11
+
12
+
13
+ ## Infernece Example
14
+
15
+ ```bash
16
+ pip install git+https://github.com/xin3he/diffusers@auto_round # A special version for auto-round
17
+ pip install git+https://github.com/intel/auto-round.git@refs/pull/1640/head # A special version for tuning and loading
18
+ ```
19
+
20
+ ```python
21
+ import time
22
+
23
+ import torch
24
+ from diffusers import ZImagePipeline
25
+
26
+ model_path = "INCModel/Z-Image-W4A16-AutoRound"
27
+
28
+ # 1. Load the pipeline
29
+ # Use bfloat16 for optimal performance on supported GPUs
30
+ pipe = ZImagePipeline.from_pretrained(
31
+ model_path,
32
+ torch_dtype=torch.bfloat16,
33
+ device_map="cuda", # set device_map="cuda" to leverage gptqmodel kernels
34
+ )
35
+ pipe.to("cuda")
36
+
37
+ # [Optional] Attention Backend
38
+ # Diffusers uses SDPA by default. Switch to Flash Attention for better efficiency if supported:
39
+ # pipe.transformer.set_attention_backend("flash") # Enable Flash-Attention-2
40
+ # pipe.transformer.set_attention_backend("_flash_3") # Enable Flash-Attention-3
41
+
42
+ # [Optional] Model Compilation
43
+ # Compiling the DiT model accelerates inference, but the first run will take longer to compile.
44
+ # pipe.transformer.compile()
45
+
46
+ # [Optional] CPU Offloading
47
+ # Enable CPU offloading for memory-constrained devices.
48
+ # pipe.enable_model_cpu_offload()
49
+
50
+ 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."
51
+
52
+ # 2. Generate Image
53
+ print("Starting generation...")
54
+ image = pipe(
55
+ prompt=prompt,
56
+ negative_prompt="",
57
+ height=1280,
58
+ width=720,
59
+ cfg_normalization=False,
60
+ num_inference_steps=50,
61
+ guidance_scale=4,
62
+ generator=torch.Generator("cuda").manual_seed(42),
63
+ ).images[0]
64
+
65
+ image.save("example.png")
66
+ ```
67
+
68
+ ## Generate the Model
69
+
70
+ This pr is required https://github.com/intel/auto-round/pull/1640
71
+
72
+ Tuning version
73
+
74
+ ~~~bash
75
+ CUDA_VISIBLE_DEVICES=6,7 auto-round Tongyi-MAI/Z-Image --num_inference_steps 2 --output_dir /workspace/models/Tongyi-MAI/Z-Image-W4A16-AutoRound --device_map 0,1 --low_gpu_mem_usage --enable_torch_compile
76
+ ~~~
77
+
78
+
79
+ ## Ethical Considerations and Limitations
80
+
81
+ 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.
82
+
83
+ Therefore, before deploying any applications of the model, developers should perform safety testing.
84
+
85
+ ## Caveats and Recommendations
86
+
87
+ Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model.
88
+
89
+ Here are a couple of useful links to learn more about Intel's AI software:
90
+
91
+ - [Intel Neural Compressor](https://github.com/intel/neural-compressor)
92
+
93
+ ## Disclaimer
94
+
95
+ 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.
96
+
97
+ ## Cite
98
+
99
+ @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} }
100
+
101
+ [arxiv](https://arxiv.org/abs/2309.05516) [github](https://github.com/intel/auto-round)