-
Notifications
You must be signed in to change notification settings - Fork 849
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Stable Diffusion with OV TorchDynamo backend (#1338)
- Loading branch information
Showing
8 changed files
with
452 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
412 changes: 412 additions & 0 deletions
412
...s/276-stable-diffusion-torchdynamo-backend/276-stable-diffusion-torchdynamo-backend.ipynb
Large diffs are not rendered by default.
Oops, something went wrong.
25 changes: 25 additions & 0 deletions
25
notebooks/276-stable-diffusion-torchdynamo-backend/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Image Generation with Stable Diffusion using OpenVINO TorchDynamo backend | ||
|
||
This notebook demonstrates how to use a **[Stable Diffusion](https://huggingface.co/stabilityai/stable-diffusion-2-1)** model for image generation with [OpenVINO TorchDynamo backend](https://docs.openvino.ai/2023.1/pytorch_2_0_torch_compile.html). The `torch.compile` feature enables you to use OpenVINO for PyTorch-native applications. It speeds up PyTorch code by JIT-compiling it into optimized kernels. | ||
|
||
By default, Torch code runs in eager-mode, but with the use of torch.compile it goes through the following steps: | ||
|
||
1. Graph acquisition - the model is rewritten as blocks of subgraphs that are either: | ||
* compiled by TorchDynamo and “flattened”, | ||
* falling back to the eager-mode, due to unsupported Python constructs (like control-flow code). | ||
2. Graph lowering - all PyTorch operations are decomposed into their constituent kernels specific to the chosen backend. | ||
3. Graph compilation - the kernels call their corresponding low-level device-specific operations. | ||
|
||
## Notebook Contents | ||
|
||
This notebook demonstrates how to run stable diffusion using OpenVINO TorchDynamo backend. | ||
|
||
Notebook contains the following steps: | ||
|
||
1. Create PyTorch models pipeline using Diffusers library. | ||
2. Import OpenVINO backend using `torch.compile`. | ||
3. Run Stable Diffusion pipeline with OpenVINO TorchDynamo backend. | ||
|
||
## Installation Instructions | ||
|
||
If you have not installed all required dependencies, follow the [Installation Guide](../../README.md). |