Skip to main content
Qwen3-TTS supports efficient batch processing, allowing you to generate multiple audio files in a single call. This is essential for high-throughput applications, offline processing, and dataset generation.

Overview

Batch processing allows you to:
  • Process multiple texts in a single forward pass
  • Improve GPU utilization and throughput
  • Reduce per-sample overhead
  • Generate consistent audio for multiple inputs efficiently

Basic Batch Processing

All generation methods support batch inputs by passing lists:

CustomVoice Batch

VoiceDesign Batch

Voice Clone Batch

Batch Size Considerations

Memory Management

Choose appropriate batch sizes based on your GPU memory:

Processing Large Datasets

For large datasets, process in chunks:

Performance Optimization

Model Selection

Choose the right model for your throughput needs:

Use Non-Streaming Mode

For batch processing, disable streaming for better throughput:

Enable FlashAttention-2

Always use FlashAttention-2 for best performance:

Complete Batch Processing Example

Here’s a production-ready example:

Batch with Different Voices

Process multiple texts with different cloned voices:

Performance Benchmarks

Throughput Comparison

Benchmarks measured with FlashAttention-2 enabled and bfloat16 precision.

Memory Usage Guidelines

Best Practices

Start with batch_size=8 and increase until you hit memory limits. Monitor GPU memory usage with nvidia-smi.
Texts of similar length in each batch improve efficiency. Sort texts by length before batching.
When using the same voice multiple times, create the prompt once and reuse it across batches.
For batch processing, non_streaming_mode=True provides better throughput than streaming.
bfloat16 provides the best balance of speed and quality. fp16 may be slightly faster but less stable.

Troubleshooting

Reduce batch_size, use the 0.6B model instead of 1.7B, or enable gradient checkpointing if available.
Ensure FlashAttention-2 is installed and enabled. Use bfloat16 dtype. Increase batch size for better GPU utilization.
Some samples in batch have different quality? Check input text lengths - very short texts may have lower quality.

Next Steps