This notebook demonstrates how to use a Stable Diffusion model for image generation with OpenVINO TorchDynamo backend. 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:
- 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).
- Graph lowering - all PyTorch operations are decomposed into their constituent kernels specific to the chosen backend.
- Graph compilation - the kernels call their corresponding low-level device-specific operations.
This notebook demonstrates how to run stable diffusion using OpenVINO TorchDynamo backend.
Notebook contains the following steps:
- Create PyTorch models pipeline using Diffusers library.
- Import OpenVINO backend using
torch.compile
. - Run Stable Diffusion pipeline with OpenVINO TorchDynamo backend.
If you have not installed all required dependencies, follow the Installation Guide.