ERNIE-Image Multi-Prompt Batch Generation Workflow: Run 100 Different Prompts in One ComfyUI Queue
Published: 2026-06-15
Author: ERNIE-Image Blog
Keywords: ernie-image batch generation, ernie-image comfyui batch prompt, ernie-image multi-prompt workflow
Introduction
Batch generation has always been a pain point in AI image generation workflows. ComfyUI's default batch_size parameter lets you generate multiple images from the same prompt, but if you want to generate 100 images from 100 different prompts, each prompt has to queue sequentially — which is extremely inefficient in production.
ERNIE-Image community users frequently discuss this on Reddit: "Setting batch size to 4 will generate 4 at the same time with the same prompt, what I want is a different prompt for each image in that batch." This isn't just a ComfyUI problem — it's a universal challenge for AI creators who need batch production.
This article dives deep into multi-prompt batch generation with ERNIE-Image in ComfyUI — one queue, different prompts, each image independently output.
ERNIE-Image Model Foundation
Before diving into the batch workflow, let's review ERNIE-Image's core architecture:
- ERNIE-Image (SFT version): 50 inference steps, CFG 4.0, stronger general-purpose capability and instruction fidelity
- ERNIE-Image-Turbo: 8 inference steps, CFG 1.0, DMD + RL optimized, 6x+ speed improvement
- Prompt Enhancer (PE): Fine-tuned on Ministral 3B, expands brief prompts into rich descriptions
For batch production, Turbo mode is the optimal choice — 8 steps + CFG 1.0 achieves approximately 4 seconds per image on an RTX 4090.
Approach 1: ComfyUI Official Prompt Multi Batch Generation Template
ComfyUI provides an official "Prompt Multi Batch Generation" workflow template. The core idea is to use Blueprint or Partner Nodes to process multiple prompts in parallel.
Getting the Template
- Open ComfyUI → Navigate to the Template panel
- Search for "Prompt Multi Batch Generation"
- Click to load the template
Key Modifications for ERNIE-Image
The official template defaults to SDXL-like models. Adapting it for ERNIE-Image requires these node changes:
[Load Checkpoint] → ernie-image-turbo.safetensors
↓
[CLIP Text Encode (Batch)] → Read prompt list from CSV/JSON
↓
[Empty Latent Image (Batch)] → 1264 × 848, batch_size = number of prompts
↓
[KSampler] → steps=8, cfg=1.0, scheduler=euler_ancestral
↓
[VAE Decode] → flux2-vae.safetensors
↓
[Save Image] → Output directory + auto-numbering
Key Nodes Explained
CLIP Text Encode (Batch): This is the core node for multi-prompt batching. It accepts a prompt list (not a single string) and encodes each prompt independently.
Empty Latent Image (Batch): Must match the length of the prompt list. If you input 10 prompts, set batch_size to 10.
Approach 2: Custom CSV/JSON Prompt List Batch Generation
For more flexible control, you can build a custom workflow that reads prompt lists from external files.
Prompt File Formats
CSV format (recommended for large prompt lists):
prompt,output_prefix
"a cinematic cityscape at dusk with neon reflections",city_
"a vintage coffee shop interior with warm lighting",cafe_
"minimalist product photography on white background",product_
"anime style character portrait, detailed eyes",anime_
JSON format (recommended when additional parameters are needed):
[
{"prompt": "cinematic cityscape at dusk", "seed": 42, "cfg": 1.0},
{"prompt": "vintage coffee shop interior", "seed": 123, "cfg": 1.0},
{"prompt": "minimalist product on white", "seed": 456, "cfg": 1.0}
]
Workflow Setup Steps
- Add a Python Script node: Read CSV/JSON file, output prompt list
- Connect to CLIP Text Encode: Feed the prompt list in
- Configure Empty Latent Image: Dynamically set batch_size
- Configure Sampler: Turbo mode steps=8, cfg=1.0
- Save Image node: Configure output directory and auto-numbering
Approach 3: SGLang API Batch Endpoint
For production environments, SGLang provides more efficient batch inference endpoints.
Starting the SGLang Service
sglang serve --model-path baidu/ERNIE-Image-Turbo \
--host 0.0.0.0 \
--port 30000 \
--mem-fraction-static 0.8
Batch API Calls
import requests
import json
prompts = [
"cinematic cityscape at dusk with neon reflections",
"vintage coffee shop interior with warm lighting",
"minimalist product photography on white background",
"anime style character portrait, detailed eyes"
]
for i, prompt in enumerate(prompts):
response = requests.post(
"http://localhost:30000/v1/images/generations",
headers={"Content-Type": "application/json"},
json={
"prompt": prompt,
"height": 1264,
"width": 848,
"num_inference_steps": 8,
"guidance_scale": 1.0
}
)
image_data = response.json()["data"][0]["b64_json"]
# Save as file
with open(f"output_{i}.png", "wb") as f:
import base64
f.write(base64.b64decode(image_data))
Concurrent Batch Calls (Advanced)
import concurrent.futures
import requests
def generate_image(prompt, idx):
response = requests.post(
"http://localhost:30000/v1/images/generations",
headers={"Content-Type": "application/json"},
json={
"prompt": prompt,
"height": 1264,
"width": 848,
"num_inference_steps": 8,
"guidance_scale": 1.0
}
)
return idx, response.json()
with concurrent.futures.ThreadPoolExecutor(max_workers=4) as executor:
futures = [executor.submit(generate_image, p, i) for i, p in enumerate(prompts)]
for future in concurrent.futures.as_completed(futures):
idx, result = future.result()
print(f"Completed: {idx}")
Performance Comparison and Optimization Strategies
RTX 4090 (24GB VRAM) Benchmarks
| Configuration | Per-Image Time | 100 Images Total | Throughput |
|---|---|---|---|
| BF16 + 50 steps | ~25 sec | ~45 min | 2.2 img/min |
| FP8 + 8 steps (Turbo) | ~4 sec | ~7 min | 14 img/min |
| GGUF Q4 + 8 steps | ~3 sec | ~5 min | 20 img/min |
Key takeaway: Turbo mode + quantization = optimal batch production configuration. FP8 quantization doubles throughput while maintaining image quality.
Key Optimization Tips
- Use Turbo model: 8 steps + CFG 1.0, 6x speed improvement
- FP8 quantized loading:
torch_dtype=torch.float8_e4m3fn, halves VRAM requirements - Continuous batching: Don't wait for all images to finish before starting the next batch — use streaming output
- Delayed VAE decode: Only decode VAE at save time, reducing memory usage
- Seed control: Fixed seeds for reproducibility, random seeds for variety
Real-World Use Cases
Use Case 1: E-commerce Product Photo Batch Generation
Input 50 product description prompts, batch-generate white-background product photos:
prompt,output_prefix
"professional product photography of a leather wallet on white background, studio lighting",wallet_
"professional product photography of a stainless steel water bottle on white background",bottle_
"professional product photography of wireless earbuds on white background, minimal style",earbuds_
Use Case 2: Social Media Content Batch Production
Batch-generate cover images for different social platforms:
[
{"prompt": "YouTube thumbnail style, AI art tutorial, vibrant colors, bold text 'AI ART TIPS'", "width": 1280, "height": 720},
{"prompt": "Instagram post style, minimalist design, pastel colors, coffee theme", "width": 1080, "height": 1080},
{"prompt": "LinkedIn article cover, professional business illustration, blue tones", "width": 1200, "height": 627}
]
Use Case 3: A/B Testing Prompt Variations
Generate multiple style variations of the same subject for comparison:
prompt,style
"a futuristic city skyline, realistic photography style",realistic
"a futuristic city skyline, anime illustration style",anime
"a futuristic city skyline, oil painting style",painting
"a futuristic city skyline, watercolor style",watercolor
"a futuristic city skyline, pixel art style",pixel
Common Issues and Solutions
Q1: Batch Size Limits
Problem: ComfyUI has default batch_size limits — too many prompts cause OOM.
Solution: Process in chunks. Split 100 prompts into 5 groups of 20, execute sequentially.
Q2: Inconsistent Prompt Lengths
Problem: Varying prompt lengths cause uneven encoding times.
Solution: Use PE (Prompt Enhancer) to uniformly expand prompt lengths, or manually truncate/pad to consistent lengths.
Q3: Messy Output File Naming
Problem: After batch generation, files are hard to map back to original prompts.
Solution: Use prompt summaries or sequence numbers as filename prefixes in the Save Image node, combined with the output_prefix column in your CSV.
Summary
The core idea behind ERNIE-Image's multi-prompt batch generation workflow is to parallelize what would otherwise be sequential generation through ComfyUI Batch nodes, custom CSV/JSON input, or concurrent SGLang API calls.
Recommended setup: ERNIE-Image-Turbo + FP8 quantization + ComfyUI Batch nodes achieves approximately 14 images/minute on an RTX 4090.
For production-grade batch tasks (1000+ images), the SGLang API + concurrent calls approach is recommended, supporting horizontal scaling and multi-GPU parallelism.