diff --git a/README.md b/README.md index 87d81b0..11ea753 100644 --- a/README.md +++ b/README.md @@ -151,26 +151,25 @@ pip install intel-openmp pip install intel_extension_for_pytorch -f https://software.intel.com/ipex-whl-stable ``` -To sample from the _SD2.1-v_ model with TorchScript+IPEX optimizations, run the following: +To sample from the _SD2.1-v_ model with TorchScript+IPEX optimizations, run the following. Remember to specify desired number of instances you want to run the program on ([more](https://github.com/intel/intel-extension-for-pytorch/blob/master/intel_extension_for_pytorch/cpu/launch.py#L48)). -# TODO HOW TO EXPLAIN -NINSTANCE ``` -MALLOC_CONF=oversize_threshold:1,background_thread:true,metadata_thp:auto,dirty_decay_ms:9000000000,muzzy_decay_ms:9000000000 python -m intel_extension_for_pytorch.cpu.launch --ninstance 1 --enable_jemalloc scripts/txt2img.py --prompt \"a corgi is playing guitar, oil on canvas\" --ckpt --config configs/stable-diffusion/ipex/v2-inference-v-fp32.yaml --H 768 --W 768 --precision full --device cpu --torchscript --ipex +MALLOC_CONF=oversize_threshold:1,background_thread:true,metadata_thp:auto,dirty_decay_ms:9000000000,muzzy_decay_ms:9000000000 python -m intel_extension_for_pytorch.cpu.launch --ninstance --enable_jemalloc scripts/txt2img.py --prompt \"a corgi is playing guitar, oil on canvas\" --ckpt --config configs/stable-diffusion/ipex/v2-inference-v-fp32.yaml --H 768 --W 768 --precision full --device cpu --torchscript --ipex ``` To sample from the base model with IPEX optimizations, use ``` -MALLOC_CONF=oversize_threshold:1,background_thread:true,metadata_thp:auto,dirty_decay_ms:9000000000,muzzy_decay_ms:9000000000 python -m intel_extension_for_pytorch.cpu.launch --ninstance 1 --enable_jemalloc scripts/txt2img.py --prompt \"a corgi is playing guitar, oil on canvas\" --ckpt --config configs/stable-diffusion/ipex/v2-inference-fp32.yaml --n_samples 1 --n_iter 4 --precision full --device cpu --torchscript --ipex +MALLOC_CONF=oversize_threshold:1,background_thread:true,metadata_thp:auto,dirty_decay_ms:9000000000,muzzy_decay_ms:9000000000 python -m intel_extension_for_pytorch.cpu.launch --ninstance --enable_jemalloc scripts/txt2img.py --prompt \"a corgi is playing guitar, oil on canvas\" --ckpt --config configs/stable-diffusion/ipex/v2-inference-fp32.yaml --n_samples 1 --n_iter 4 --precision full --device cpu --torchscript --ipex ``` If you're using a CPU that supports `bfloat16`, consider sample from the model with bfloat16 enabled for a performance boost, like so ```bash # SD2.1-v -MALLOC_CONF=oversize_threshold:1,background_thread:true,metadata_thp:auto,dirty_decay_ms:9000000000,muzzy_decay_ms:9000000000 python -m intel_extension_for_pytorch.cpu.launch --ninstance 1 --enable_jemalloc scripts/txt2img.py --prompt \"a corgi is playing guitar, oil on canvas\" --ckpt --config configs/stable-diffusion/ipex/v2-inference-v-bf16.yaml --H 768 --W 768 --precision full --device cpu --torchscript --ipex --bf16 +MALLOC_CONF=oversize_threshold:1,background_thread:true,metadata_thp:auto,dirty_decay_ms:9000000000,muzzy_decay_ms:9000000000 python -m intel_extension_for_pytorch.cpu.launch --ninstance --enable_jemalloc scripts/txt2img.py --prompt \"a corgi is playing guitar, oil on canvas\" --ckpt --config configs/stable-diffusion/ipex/v2-inference-v-bf16.yaml --H 768 --W 768 --precision full --device cpu --torchscript --ipex --bf16 # SD2.1-base -MALLOC_CONF=oversize_threshold:1,background_thread:true,metadata_thp:auto,dirty_decay_ms:9000000000,muzzy_decay_ms:9000000000 python -m intel_extension_for_pytorch.cpu.launch --ninstance 1 --enable_jemalloc scripts/txt2img.py --prompt \"a corgi is playing guitar, oil on canvas\" --ckpt --config configs/stable-diffusion/ipex/v2-inference-bf16.yaml --precision full --device cpu --torchscript --ipex --bf16 +MALLOC_CONF=oversize_threshold:1,background_thread:true,metadata_thp:auto,dirty_decay_ms:9000000000,muzzy_decay_ms:9000000000 python -m intel_extension_for_pytorch.cpu.launch --ninstance --enable_jemalloc scripts/txt2img.py --prompt \"a corgi is playing guitar, oil on canvas\" --ckpt --config configs/stable-diffusion/ipex/v2-inference-bf16.yaml --precision full --device cpu --torchscript --ipex --bf16 ``` ### Image Modification with Stable Diffusion diff --git a/configs/stable-diffusion/ipex/v2-inference-bf16.yaml b/configs/stable-diffusion/ipex/v2-inference-bf16.yaml index e36c3b3..66f0dbd 100644 --- a/configs/stable-diffusion/ipex/v2-inference-bf16.yaml +++ b/configs/stable-diffusion/ipex/v2-inference-bf16.yaml @@ -1,3 +1,6 @@ +# Copyright (C) 2022 Intel Corporation +# SPDX-License-Identifier: MIT + model: base_learning_rate: 1.0e-4 target: ldm.models.diffusion.ddpm.LatentDiffusion diff --git a/configs/stable-diffusion/ipex/v2-inference-fp32.yaml b/configs/stable-diffusion/ipex/v2-inference-fp32.yaml index ef63a09..7b66ac8 100644 --- a/configs/stable-diffusion/ipex/v2-inference-fp32.yaml +++ b/configs/stable-diffusion/ipex/v2-inference-fp32.yaml @@ -1,3 +1,6 @@ +# Copyright (C) 2022 Intel Corporation +# SPDX-License-Identifier: MIT + model: base_learning_rate: 1.0e-4 target: ldm.models.diffusion.ddpm.LatentDiffusion diff --git a/configs/stable-diffusion/ipex/v2-inference-v-bf16.yaml b/configs/stable-diffusion/ipex/v2-inference-v-bf16.yaml index 9c20593..2b4b0e6 100644 --- a/configs/stable-diffusion/ipex/v2-inference-v-bf16.yaml +++ b/configs/stable-diffusion/ipex/v2-inference-v-bf16.yaml @@ -1,3 +1,6 @@ +# Copyright (C) 2022 Intel Corporation +# SPDX-License-Identifier: MIT + model: base_learning_rate: 1.0e-4 target: ldm.models.diffusion.ddpm.LatentDiffusion diff --git a/configs/stable-diffusion/ipex/v2-inference-v-fp32.yaml b/configs/stable-diffusion/ipex/v2-inference-v-fp32.yaml index 10715f5..8ccd92e 100644 --- a/configs/stable-diffusion/ipex/v2-inference-v-fp32.yaml +++ b/configs/stable-diffusion/ipex/v2-inference-v-fp32.yaml @@ -1,3 +1,6 @@ +# Copyright (C) 2022 Intel Corporation +# SPDX-License-Identifier: MIT + model: base_learning_rate: 1.0e-4 target: ldm.models.diffusion.ddpm.LatentDiffusion diff --git a/ldm/models/diffusion/ddim.py b/ldm/models/diffusion/ddim.py index c6cfd57..e93f7fb 100644 --- a/ldm/models/diffusion/ddim.py +++ b/ldm/models/diffusion/ddim.py @@ -1,3 +1,6 @@ +# Copyright (C) 2022 Intel Corporation +# SPDX-License-Identifier: MIT + """SAMPLING ONLY.""" import torch diff --git a/ldm/models/diffusion/ddpm.py b/ldm/models/diffusion/ddpm.py index 6d2f5a7..b6248ea 100644 --- a/ldm/models/diffusion/ddpm.py +++ b/ldm/models/diffusion/ddpm.py @@ -1,3 +1,6 @@ +# Copyright (C) 2022 Intel Corporation +# SPDX-License-Identifier: MIT + """ wild mixture of https://github.com/lucidrains/denoising-diffusion-pytorch/blob/7706bdfc6f527f58d33f84b7b522e61e6e3164b3/denoising_diffusion_pytorch/denoising_diffusion_pytorch.py diff --git a/ldm/models/diffusion/dpm_solver/sampler.py b/ldm/models/diffusion/dpm_solver/sampler.py index 4270c61..108b336 100644 --- a/ldm/models/diffusion/dpm_solver/sampler.py +++ b/ldm/models/diffusion/dpm_solver/sampler.py @@ -1,3 +1,6 @@ +# Copyright (C) 2022 Intel Corporation +# SPDX-License-Identifier: MIT + """SAMPLING ONLY.""" import torch diff --git a/ldm/models/diffusion/plms.py b/ldm/models/diffusion/plms.py index 9d31b39..bef62b3 100644 --- a/ldm/models/diffusion/plms.py +++ b/ldm/models/diffusion/plms.py @@ -1,3 +1,6 @@ +# Copyright (C) 2022 Intel Corporation +# SPDX-License-Identifier: MIT + """SAMPLING ONLY.""" import torch diff --git a/ldm/modules/diffusionmodules/openaimodel.py b/ldm/modules/diffusionmodules/openaimodel.py index 764a34b..634e3f4 100644 --- a/ldm/modules/diffusionmodules/openaimodel.py +++ b/ldm/modules/diffusionmodules/openaimodel.py @@ -1,3 +1,6 @@ +# Copyright (C) 2022 Intel Corporation +# SPDX-License-Identifier: MIT + from abc import abstractmethod import math diff --git a/scripts/txt2img.py b/scripts/txt2img.py index 53e8701..1cae967 100644 --- a/scripts/txt2img.py +++ b/scripts/txt2img.py @@ -1,3 +1,6 @@ +# Copyright (C) 2022 Intel Corporation +# SPDX-License-Identifier: MIT + import argparse, os import cv2 import torch