2025-12-12 09:59:56 +05:30
# TeaCache Configuration Guide
TeaCache speeds up diffusion model inference by caching transformer computations when consecutive timesteps are similar. This typically provides **1.5x-2.0x speedup** with minimal quality loss.
## Quick Start
2025-12-15 15:10:45 +08:00
Enable TeaCache by setting `cache_backend` to `"tea_cache"` :
2025-12-12 09:59:56 +05:30
```python
from vllm_omni import Omni
2026-01-28 16:07:42 +08:00
from vllm_omni.inputs.data import OmniDiffusionSamplingParams
2025-12-12 09:59:56 +05:30
2025-12-15 15:10:45 +08:00
# Simple configuration - model_type is automatically extracted from pipeline.__class__.__name__
2025-12-12 09:59:56 +05:30
omni = Omni (
model = "Qwen/Qwen-Image" ,
2025-12-15 15:10:45 +08:00
cache_backend = "tea_cache" ,
2025-12-12 09:59:56 +05:30
cache_config = {
"rel_l1_thresh" : 0.2 # Optional, defaults to 0.2
}
)
2026-01-28 16:07:42 +08:00
outputs = omni . generate (
"A cat sitting on a windowsill" ,
OmniDiffusionSamplingParams (
num_inference_steps = 50 ,
),
)
2025-12-12 09:59:56 +05:30
```
### Using Environment Variable
You can also enable TeaCache via environment variable:
```bash
2025-12-15 15:10:45 +08:00
export DIFFUSION_CACHE_BACKEND = tea_cache
2025-12-12 09:59:56 +05:30
```
2025-12-15 15:10:45 +08:00
Then initialize without explicitly setting `cache_backend` :
2025-12-12 09:59:56 +05:30
```python
from vllm_omni import Omni
omni = Omni (
model = "Qwen/Qwen-Image" ,
cache_config = { "rel_l1_thresh" : 0.2 } # Optional
)
```
2025-12-19 16:50:32 +08:00
## Online Serving (OpenAI-Compatible)
Enable TeaCache for online serving by passing `--cache-backend tea_cache` when starting the server:
```bash
vllm serve Qwen/Qwen-Image --omni --port 8091 \
--cache-backend tea_cache \
--cache-config '{"rel_l1_thresh": 0.2}'
```
2025-12-12 09:59:56 +05:30
## Configuration Parameters
### `rel_l1_thresh` (float, default: `0.2`)
Controls the balance between speed and quality. Lower values prioritize quality, higher values prioritize speed.
**Recommended values:**
- `0.2` - ** ~1.5x speedup** with minimal quality loss (recommended)
- `0.4` - ** ~1.8x speedup** with slight quality loss
- `0.6` - ** ~2.0x speedup** with noticeable quality loss
- `0.8` - ** ~2.25x speedup** with significant quality loss
## Examples
### Python API
```python
from vllm_omni import Omni
2026-01-28 16:07:42 +08:00
from vllm_omni.inputs.data import OmniDiffusionSamplingParams
2025-12-12 09:59:56 +05:30
omni = Omni (
model = "Qwen/Qwen-Image" ,
2025-12-15 15:10:45 +08:00
cache_backend = "tea_cache" ,
2025-12-12 09:59:56 +05:30
cache_config = { "rel_l1_thresh" : 0.2 }
)
2026-01-28 16:07:42 +08:00
outputs = omni . generate (
"A cat sitting on a windowsill" ,
OmniDiffusionSamplingParams (
num_inference_steps = 50 ,
),
)
2025-12-12 09:59:56 +05:30
```
## Performance Tuning
Start with the default `rel_l1_thresh=0.2` and adjust based on your needs:
- **Maximum quality**: Use `0.1-0.2`
- **Balanced**: Use `0.2-0.4` (recommended)
- **Maximum speed**: Use `0.6-0.8` (may reduce quality)
## Troubleshooting
### Quality Degradation
If you notice quality issues, lower the threshold:
```python
cache_config = { "rel_l1_thresh" : 0.1 } # More conservative caching
```
## Supported Models
2025-12-23 15:09:25 +08:00
### ImageGen
2025-12-18 12:16:34 +08:00
<style>
th {
white-space: nowrap;
min-width: 0 !important;
}
</style>
2025-12-12 09:59:56 +05:30
2025-12-18 12:16:34 +08:00
| Architecture | Models | Example HF Models |
|--------------|--------|-------------------|
| `QwenImagePipeline` | Qwen-Image | `Qwen/Qwen-Image` |
| `QwenImageEditPipeline` | Qwen-Image-Edit | `Qwen/Qwen-Image-Edit` |
2025-12-23 15:09:25 +08:00
| `QwenImageEditPlusPipeline` | Qwen-Image-Edit-2509 | `Qwen/Qwen-Image-Edit-2509` |
2025-12-23 18:21:23 +08:00
| `QwenImageLayeredPipeline` | Qwen-Image-Layered | `Qwen/Qwen-Image-Layered` |
2026-01-25 18:42:02 +08:00
| `BagelForConditionalGeneration` | BAGEL (DiT-only) | `ByteDance-Seed/BAGEL-7B-MoT` |
2025-12-23 15:09:25 +08:00
### VideoGen
No VideoGen models are supported by TeaCache yet.
2025-12-12 09:59:56 +05:30
2025-12-18 12:16:34 +08:00
### Coming Soon
2025-12-12 09:59:56 +05:30
2025-12-18 12:16:34 +08:00
<style>
th {
white-space: nowrap;
min-width: 0 !important;
}
</style>
| Architecture | Models | Example HF Models |
|--------------|--------|-------------------|
| `FluxPipeline` | Flux | - |
| `CogVideoXPipeline` | CogVideoX | - |