---
title: "Accelerating SD Turbo and SDXL Turbo Inference with ONNX Runtime and Olive"
description: "ONNX Runtime's CUDA and TensorRT execution providers run SD Turbo and SDXL Turbo faster than PyTorch on NVIDIA A100 and RTX 4090 GPUs for every batch-size and step combination tested."
url: "https://swe.quest/articles/accelerating-sd-turbo-and-sdxl-turbo-inference-with-onnx-runtime-and-olive-c7ff7774ed240b5b"
canonical: "https://huggingface.co/blog/sdxl_ort_inference"
source: "Hugging Face"
published: "2024-01-15"
difficulty: "medium"
kind: "Research"
reading_minutes: 8
tags: ["inference","performance","computer-vision","hardware"]
---

# Accelerating SD Turbo and SDXL Turbo Inference with ONNX Runtime and Olive

A post on [Hugging Face](https://swe.quest/sources/hugging-face.md), published 2024-01-15, 8 min read, Research. Original: [https://huggingface.co/blog/sdxl\_ort\_inference](https://huggingface.co/blog/sdxl_ort_inference)

## Summary

ONNX Runtime's CUDA and TensorRT execution providers run SD Turbo and SDXL Turbo faster than PyTorch on NVIDIA A100 and RTX 4090 GPUs for every batch-size and step combination tested. Throughput gains reach 229% for SDXL Turbo and 120% for SD Turbo. The speedups come from CUDA graphs for static shapes, Flash Attention V2, trimming unused text-encoder outputs and SkipGroupNorm fusion. TensorRT does slightly better with static shapes but needs a separate engine per batch and image size, while the CUDA provider is often the better pick for dynamic shapes on A100. Olive-optimized models, a usage example, and C# and Java community ports are provided.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Inference & serving](https://swe.quest/tags/inference.md) (AI & ML)
- [Performance engineering](https://swe.quest/tags/performance.md) (Reliability & operations)
- [Computer vision](https://swe.quest/tags/computer-vision.md) (AI & ML)
- [Hardware](https://swe.quest/tags/hardware.md) (Infrastructure)

## Prerequisites

- Stable Diffusion pipeline basics
- GPU inference concepts ([easy posts on Hardware](https://swe.quest/tags/hardware.md?difficulty=easy))
- ONNX models

## Keywords

ONNX Runtime, Olive, SDXL Turbo, SD Turbo, TensorRT, CUDA, Flash Attention, PyTorch

## Related posts

- [Optimum+ONNX Runtime - Easier, Faster training for your Hugging Face models](https://swe.quest/articles/optimum-onnx-runtime-easier-faster-training-for-your-hugging-face-models-99e01d7695af970a.md): Hugging Face · 2023-01-24 · Medium · 6 min read · Model training, Performance engineering, Python
  Hugging Face Optimum's ORTTrainer swaps ONNX Runtime in as the training backend for Transformers models.
- [Accelerated Inference with Optimum and Transformers Pipelines](https://swe.quest/articles/accelerated-inference-with-optimum-and-transformers-pipelines-9ff6245f88a35ca0.md): Hugging Face · 2022-05-10 · Medium · 12 min read · Inference & serving, Python, Performance engineering, Machine learning
  Optimum 1.2 adds inference support via ONNX Runtime with ORTModelForXxx classes that drop into Hugging Face Transformers pipelines in place of AutoModelForXxx.
- [AMD + 🤗: Large Language Models Out-of-the-Box Acceleration with AMD GPU](https://swe.quest/articles/amd-large-language-models-out-of-the-box-acceleration-with-amd-gpu-fa18508c54402fa1.md): Hugging Face · 2023-12-05 · Easy · 7 min read · Inference & serving, Hardware, LLMs, Performance engineering
  Hugging Face Transformers now runs all models and tasks on AMD Instinct GPUs with no code changes versus NVIDIA, backed by ROCm support for Flash Attention v2, vLLM Paged Attention, DeepSpeed, GPTQ via AutoGPTQ, ONNX Runtime's ROCMExecutionProvider, and Optimum-Benchmark.
- [Exploring simple optimizations for SDXL](https://swe.quest/articles/exploring-simple-optimizations-for-sdxl-b199204d28422c69.md): Hugging Face · 2023-10-24 · Medium · 8 min read · Inference & serving, Performance engineering, Computer vision, Python
  Running SDXL out of the box in fp32 on an A100 takes about 28GB and 72 seconds for 4 images.
- [Make your ZeroGPU Spaces go brrr with ahead-of-time compilation](https://swe.quest/articles/make-your-zerogpu-spaces-go-brrr-with-ahead-of-time-compilation-51092e3d8eed121c.md): Hugging Face · 2025-09-02 · Medium · 13 min read · Inference & serving, Performance engineering, Compilers, Python
  PyTorch ahead-of-time compilation (torch.export plus AOTInductor) suits ZeroGPU Spaces, where each GPU task runs in a short-lived forked process and torch.compile's just-in-time caching costs tens of seconds to minutes per task.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
