diff --git a/README.md b/README.md index 11ea753..0cc7471 100644 --- a/README.md +++ b/README.md @@ -154,22 +154,22 @@ pip install intel_extension_for_pytorch -f https://software.intel.com/ipex-whl-s 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)). ``` -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 +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/intel/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 --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/intel/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 --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/intel/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 --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/intel/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/intel/v2-inference-bf16.yaml similarity index 100% rename from configs/stable-diffusion/ipex/v2-inference-bf16.yaml rename to configs/stable-diffusion/intel/v2-inference-bf16.yaml diff --git a/configs/stable-diffusion/ipex/v2-inference-fp32.yaml b/configs/stable-diffusion/intel/v2-inference-fp32.yaml similarity index 100% rename from configs/stable-diffusion/ipex/v2-inference-fp32.yaml rename to configs/stable-diffusion/intel/v2-inference-fp32.yaml diff --git a/configs/stable-diffusion/ipex/v2-inference-v-bf16.yaml b/configs/stable-diffusion/intel/v2-inference-v-bf16.yaml similarity index 100% rename from configs/stable-diffusion/ipex/v2-inference-v-bf16.yaml rename to configs/stable-diffusion/intel/v2-inference-v-bf16.yaml diff --git a/configs/stable-diffusion/ipex/v2-inference-v-fp32.yaml b/configs/stable-diffusion/intel/v2-inference-v-fp32.yaml similarity index 100% rename from configs/stable-diffusion/ipex/v2-inference-v-fp32.yaml rename to configs/stable-diffusion/intel/v2-inference-v-fp32.yaml diff --git a/ldm/models/diffusion/ddim.py b/ldm/models/diffusion/ddim.py index e93f7fb..c6cfd57 100644 --- a/ldm/models/diffusion/ddim.py +++ b/ldm/models/diffusion/ddim.py @@ -1,6 +1,3 @@ -# 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 b6248ea..6d2f5a7 100644 --- a/ldm/models/diffusion/ddpm.py +++ b/ldm/models/diffusion/ddpm.py @@ -1,6 +1,3 @@ -# 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 108b336..4270c61 100644 --- a/ldm/models/diffusion/dpm_solver/sampler.py +++ b/ldm/models/diffusion/dpm_solver/sampler.py @@ -1,6 +1,3 @@ -# 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 bef62b3..9d31b39 100644 --- a/ldm/models/diffusion/plms.py +++ b/ldm/models/diffusion/plms.py @@ -1,6 +1,3 @@ -# 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 634e3f4..764a34b 100644 --- a/ldm/modules/diffusionmodules/openaimodel.py +++ b/ldm/modules/diffusionmodules/openaimodel.py @@ -1,6 +1,3 @@ -# 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 1cae967..9d955e3 100644 --- a/scripts/txt2img.py +++ b/scripts/txt2img.py @@ -1,6 +1,3 @@ -# Copyright (C) 2022 Intel Corporation -# SPDX-License-Identifier: MIT - import argparse, os import cv2 import torch @@ -270,10 +267,10 @@ def main(opt): if opt.bf16 and not opt.torchscript and not opt.ipex: raise ValueError('Bfloat16 is supported only for torchscript+ipex') if opt.bf16 and unet.dtype != torch.bfloat16: - raise ValueError("Use configs/stable-diffusion/ipex/ configs with bf16 enabled if " + + raise ValueError("Use configs/stable-diffusion/intel/ configs with bf16 enabled if " + "you'd like to use bfloat16 with CPU.") if unet.dtype == torch.float16 and device == torch.device("cpu"): - raise ValueError("Use configs/stable-diffusion/ipex/ configs for your model if you'd like to run it on CPU.") + raise ValueError("Use configs/stable-diffusion/intel/ configs for your model if you'd like to run it on CPU.") if opt.ipex: import intel_extension_for_pytorch as ipex @@ -292,7 +289,7 @@ def main(opt): # get UNET scripted if unet.use_checkpoint: raise ValueError("Gradient checkpoint won't work with tracing. " + - "Use configs/stable-diffusion/ipex/ configs for your model or disable checkpoint in your config.") + "Use configs/stable-diffusion/intel/ configs for your model or disable checkpoint in your config.") img_in = torch.ones(2, 4, 96, 96, dtype=torch.float32) t_in = torch.ones(2, dtype=torch.int64)