Skip to content

Commit

Permalink
adjust licenses and naming
Browse files Browse the repository at this point in the history
  • Loading branch information
aalbersk committed Feb 3, 2023
1 parent 872cc9e commit 3349693
Show file tree
Hide file tree
Showing 11 changed files with 7 additions and 25 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <number of an instance> --enable_jemalloc scripts/txt2img.py --prompt \"a corgi is playing guitar, oil on canvas\" --ckpt <path/to/768model.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 <number of an instance> --enable_jemalloc scripts/txt2img.py --prompt \"a corgi is playing guitar, oil on canvas\" --ckpt <path/to/768model.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 <number of an instance> --enable_jemalloc scripts/txt2img.py --prompt \"a corgi is playing guitar, oil on canvas\" --ckpt <path/to/model.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 <number of an instance> --enable_jemalloc scripts/txt2img.py --prompt \"a corgi is playing guitar, oil on canvas\" --ckpt <path/to/model.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 <number of an instance> --enable_jemalloc scripts/txt2img.py --prompt \"a corgi is playing guitar, oil on canvas\" --ckpt <path/to/768model.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 <number of an instance> --enable_jemalloc scripts/txt2img.py --prompt \"a corgi is playing guitar, oil on canvas\" --ckpt <path/to/768model.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 <number of an instance> --enable_jemalloc scripts/txt2img.py --prompt \"a corgi is playing guitar, oil on canvas\" --ckpt <path/to/model.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 <number of an instance> --enable_jemalloc scripts/txt2img.py --prompt \"a corgi is playing guitar, oil on canvas\" --ckpt <path/to/model.ckpt/> --config configs/stable-diffusion/intel/v2-inference-bf16.yaml --precision full --device cpu --torchscript --ipex --bf16
```

### Image Modification with Stable Diffusion
Expand Down
3 changes: 0 additions & 3 deletions ldm/models/diffusion/ddim.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# Copyright (C) 2022 Intel Corporation
# SPDX-License-Identifier: MIT

"""SAMPLING ONLY."""

import torch
Expand Down
3 changes: 0 additions & 3 deletions ldm/models/diffusion/ddpm.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 0 additions & 3 deletions ldm/models/diffusion/dpm_solver/sampler.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# Copyright (C) 2022 Intel Corporation
# SPDX-License-Identifier: MIT

"""SAMPLING ONLY."""
import torch

Expand Down
3 changes: 0 additions & 3 deletions ldm/models/diffusion/plms.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# Copyright (C) 2022 Intel Corporation
# SPDX-License-Identifier: MIT

"""SAMPLING ONLY."""

import torch
Expand Down
3 changes: 0 additions & 3 deletions ldm/modules/diffusionmodules/openaimodel.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# Copyright (C) 2022 Intel Corporation
# SPDX-License-Identifier: MIT

from abc import abstractmethod
import math

Expand Down
9 changes: 3 additions & 6 deletions scripts/txt2img.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# Copyright (C) 2022 Intel Corporation
# SPDX-License-Identifier: MIT

import argparse, os
import cv2
import torch
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit 3349693

Please sign in to comment.