Views
No views yet

| Method | FID (↓) | ClipScore | ImageReward |
|---|---|---|---|
| FP16 | 17.15 | 0.2722 | 0.8631 |
| MixDQ-W8A8 | 17.03 | 0.2703 | 0.8415 |
| MixDQ-W5A8 | 17.23 | 0.2697 | 0.8307 |
1 # The Python versions required to run mixdq: 3.8, 3.9, 3.10
2 pip install -i https://pypi.org/simple/ mixdq-extension1 pipe = DiffusionPipeline.from_pretrained(
2 "stabilityai/sdxl-turbo", custom_pipeline="nics-efc/MixDQ",
3 torch_dtype=torch.float16, variant="fp16"
4 )
5
6 # quant the UNet
7 pipe.quantize_unet(
8 w_bit = 8,
9 a_bit = 8,
10 bos=True,
11 )
12
13 # The set_cuda_graph func is optional and used for acceleration
14 pipe.set_cuda_graph(
15 run_pipeline = True,
16 )
17
18 # test the memory and the lantency of the pipeline or the UNet
19 pipe.run_for_test(
20 device="cuda",
21 output_type="pil",
22 run_pipeline=True,
23 path="pipeline_test.png",
24 profile=True
25 )
26 '''
27 After execution is finished, there will be a report under log/sdxl folder in formats of json.
28 This report can be opened by tensorboard for users to examine profiling results:
29 tensorboard --logdir=./log
30 '''
31
32 # run the pipeline
33 pipe = pipe.to("cuda")
34 prompts = "A black Honda motorcycle parked in front of a garage."
35 image = pipe(prompts, num_inference_steps=1, guidance_scale=0.0).images[0]
36 image.save('mixdq_pipeline.png')| UNet Latency (ms) | No CUDA Graph | With CUDA Graph |
|---|---|---|
| FP16 version | 44.6 | 36.1 |
| Quantized version | 59.1 | 24.9 |
| Speedup | 0.75 | 1.45 |