```bash
pip3 install -U torch torchao
```  
[torch.compile](https://pytorch.org/tutorials/intermediate/torch_compile_tutorial.html) with `mode="max-autotune-no-cudagraphs"` or `mode="max-autotune"` selects the best kernel for performance. Compilation can take a long time if it's the first time the model is called, but it is worth it once the model has been compiled.  
This example only quantizes the transformer model, but you can also quantize the text encoder to reduce memory usage even more.  
> [!TIP]