stable-fast icon indicating copy to clipboard operation
stable-fast copied to clipboard

Enable cuda graph error in `StableDiffusionControlNetReferencePipeline`

Open GoGiants1 opened this issue 1 year ago • 6 comments

Hi! Thanks for your amazing work. I tested several pipelines and the speed of this framework is truly impressive🔥

However, I have encountered an issue when using the stable-fast setting with the enable_cuda_graph=True option and the StableDiffusionControlNetReferencePipeline. It appears that the pipeline encounters a problem and causes a restart of the hardware(the entire instance in HuggingFace and the Colab session). Interestingly, when the enable_cuda_graph option is set to False, everything seems to function correctly. When I tested on the A10G (vram 24gb) and T4 (vram 16gb) instances, the results were the same in all cases.

Upon further investigation, I suspect that the hacked_*** functions may be the root cause of this error.

For your reference, I have provided a link to a reproducible code: Colab Notebook

Thank you!

GoGiants1 avatar Dec 21 '23 04:12 GoGiants1

+) When enable_cuda_graph = False, generated image is worse than not compile output.

Reference Image
reference_image
Compiled pipe's output
e5ffec46-4e5d-49d9-8c82-8e82521493c2_3
Not compiled pipe's output
dcd5258b-ca29-47d3-a963-3941cc9073a6_0

GoGiants1 avatar Dec 21 '23 11:12 GoGiants1

@GoGiants1 If you face quality problems with stable-fast, you can tweak the config. For example, you can set prefer_lowp_gemm = False and enable_fused_linear_geglu = False.

chengzeyi avatar Dec 22 '23 03:12 chengzeyi

@GoGiants1

I have inspected the code of StableDiffusionControlNetReferencePipeline and found that what you said is right. those hacked_** methods is not compatible with CUDA Graph, so please disable it.

chengzeyi avatar Dec 24 '23 02:12 chengzeyi

@chengzeyi Ok. I would disable cuda graph option in reference pipe.

And prefer_lowp_gemm = False and enable_fused_linear_geglu = False options couldn't resolve quality degradation issue 😢 ..

Thank you for your answers!

GoGiants1 avatar Dec 26 '23 07:12 GoGiants1

@GoGiants1 Sorry to bother you. I wonder how you use the reference image to replace the background so wonderful. I have tried the StableDiffusionControlNetReferencePipeline but I found that the foreground object have been changed (sometimes with some strange appendages and cannot maintain the original text well). Could you share any tips or tricks with me?

AmberCheng avatar Dec 29 '23 09:12 AmberCheng

@chengzeyi Ok. I would disable cuda graph option in reference pipe.

And prefer_lowp_gemm = False and enable_fused_linear_geglu = False options couldn't resolve quality degradation issue 😢 ..

Thank you for your answers!

It's really weird, maybe this is very rare case and most photos won't have this problem?

chengzeyi avatar Jan 15 '24 04:01 chengzeyi