From 5dbc52c2b76cb09c2669a7a16bd77bb717164e37 Mon Sep 17 00:00:00 2001 From: Mick Date: Thu, 4 Jun 2026 08:45:56 +0800 Subject: [PATCH] [diffusion] doc: add ernie Image diffusion (#27195) --- .../diffusion/Ernie-Image/Ernie-Image.mdx | 77 +++++++++++++++++++ docs_new/cookbook/diffusion/README.mdx | 2 + docs_new/cookbook/diffusion/intro.mdx | 6 ++ docs_new/docs.json | 6 ++ 4 files changed, 91 insertions(+) create mode 100644 docs_new/cookbook/diffusion/Ernie-Image/Ernie-Image.mdx diff --git a/docs_new/cookbook/diffusion/Ernie-Image/Ernie-Image.mdx b/docs_new/cookbook/diffusion/Ernie-Image/Ernie-Image.mdx new file mode 100644 index 000000000..fe8a0d7a2 --- /dev/null +++ b/docs_new/cookbook/diffusion/Ernie-Image/Ernie-Image.mdx @@ -0,0 +1,77 @@ +--- +title: ERNIE-Image +metatags: + description: "Deploy ERNIE-Image and ERNIE-Image-Turbo with SGLang Diffusion." +--- + +## 1. Model introduction + +[ERNIE-Image](https://huggingface.co/baidu/ERNIE-Image) is Baidu's text-to-image diffusion model family. SGLang Diffusion supports both the regular and Turbo checkpoints with the native `ErnieImagePipeline`. + +| Model | Hugging Face model ID | Notes | +| --- | --- | --- | +| ERNIE-Image | `baidu/ERNIE-Image` | Regular text-to-image checkpoint | +| ERNIE-Image-Turbo | `baidu/ERNIE-Image-Turbo` | Turbo text-to-image checkpoint | + +## 2. Installation + +Install SGLang with the diffusion dependencies: + +```bash Command +pip install -e "python[diffusion]" +``` + +For full installation options, see the [SGLang Diffusion installation guide](/docs/sglang-diffusion/installation). + +## 3. Serve the model + +The commands below target a single supported NVIDIA CUDA or AMD ROCm GPU. Start with `--performance-mode auto`; use `speed` only when the full pipeline fits comfortably on the selected GPU(s), and use `memory` when you need lower peak GPU memory. + +Serve ERNIE-Image: + +```bash Command +sglang serve \ + --model-path baidu/ERNIE-Image \ + --num-gpus 1 \ + --performance-mode auto \ + --port 30010 +``` + +Serve ERNIE-Image-Turbo: + +```bash Command +sglang serve \ + --model-path baidu/ERNIE-Image-Turbo \ + --num-gpus 1 \ + --performance-mode auto \ + --port 30010 +``` + +## 4. Generate an image + +Use the OpenAI-compatible image generation API after the server starts: + +```python Python +import base64 +from openai import OpenAI + +client = OpenAI(api_key="EMPTY", base_url="http://127.0.0.1:30010/v1") + +response = client.images.generate( + model="baidu/ERNIE-Image-Turbo", + prompt="A cinematic photo of a quiet lakeside cabin at sunrise", + n=1, + response_format="b64_json", +) + +image_bytes = base64.b64decode(response.data[0].b64_json) +with open("ernie_image.png", "wb") as f: + f.write(image_bytes) +``` + +## 5. Configuration tips + +- ERNIE-Image is a text-to-image pipeline; do not pass `--image-path`. +- `--performance-mode auto` keeps conservative defaults while preserving explicit user flags. +- If the checkpoint includes a PE component, SGLang loads it automatically from `model_index.json`. +- Treat FSDP, SP/Ulysses/Ring, and TP as explicit benchmark knobs. Measure the target resolution, step count, and GPU type before making them production defaults. diff --git a/docs_new/cookbook/diffusion/README.mdx b/docs_new/cookbook/diffusion/README.mdx index 75e37534b..10570d314 100644 --- a/docs_new/cookbook/diffusion/README.mdx +++ b/docs_new/cookbook/diffusion/README.mdx @@ -45,6 +45,8 @@ sgl-cookbook/docs/diffusion/ │ └── Wan2.2.md ├── Z-Image/ # Z-Image series models docs │ └── Z-Image-Turbo.md +├── Ernie-Image/ # ERNIE-Image series models docs +│ └── Ernie-Image.md └── ... ``` diff --git a/docs_new/cookbook/diffusion/intro.mdx b/docs_new/cookbook/diffusion/intro.mdx index 18eb9e534..a4235d52d 100644 --- a/docs_new/cookbook/diffusion/intro.mdx +++ b/docs_new/cookbook/diffusion/intro.mdx @@ -47,6 +47,12 @@ Offline models generate each image or video request as a bounded denoising job. href="/cookbook/diffusion/Z-Image/Z-Image-Turbo" img="/cards/logos/zimage.png" /> +