[Doc] Host model recipes in recipes/ (#61302)
Signed-off-by: esmeetu <jasonailu87@gmail.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
f98ae6a9fd
commit
b515648641
@@ -0,0 +1,148 @@
|
||||
meta:
|
||||
title: "ERNIE-4.5"
|
||||
slug: "ernie-4.5"
|
||||
provider: "Ernie (Baidu)"
|
||||
description: "Baidu ERNIE 4.5 MoE text models (21B-A3B, 300B-A47B) with BF16 and FP8 support plus ERNIE-MTP speculative decoding"
|
||||
date_added: 2025-09-03
|
||||
date_updated: 2026-04-17
|
||||
tasks:
|
||||
- text
|
||||
related_recipes:
|
||||
- baidu/ERNIE-4.5-VL-28B-A3B-PT
|
||||
|
||||
model:
|
||||
model_id: "baidu/ERNIE-4.5-21B-A3B-PT"
|
||||
min_vllm_version: "0.10.1"
|
||||
architecture: moe
|
||||
parameter_count: "21B"
|
||||
active_parameters: "3B"
|
||||
context_length: 131072
|
||||
base_args: []
|
||||
base_env: {}
|
||||
|
||||
features:
|
||||
spec_decoding:
|
||||
description: "ERNIE-MTP (multi-token prediction) speculative decoding"
|
||||
args:
|
||||
- "--speculative-config"
|
||||
- '{"method":"ernie_mtp","model":"baidu/ERNIE-4.5-21B-A3B-PT","num_speculative_tokens":1}'
|
||||
|
||||
opt_in_features:
|
||||
- spec_decoding
|
||||
|
||||
variants:
|
||||
default:
|
||||
precision: bf16
|
||||
vram_minimum_gb: 106
|
||||
description: "BF16 weights; fits on 1x80GB GPU (21B variant)"
|
||||
|
||||
"300b":
|
||||
model_id: "baidu/ERNIE-4.5-300B-A47B-PT"
|
||||
precision: bf16
|
||||
vram_minimum_gb: 640
|
||||
description: "300B total / 47B active; 8x80GB with FP8 online, 16x80GB for BF16"
|
||||
extra_args:
|
||||
- "--tensor-parallel-size"
|
||||
- "8"
|
||||
- "--gpu-memory-utilization"
|
||||
- "0.95"
|
||||
- "--quantization"
|
||||
- "fp8"
|
||||
|
||||
compatible_strategies:
|
||||
- single_node_tp
|
||||
- multi_node_tp
|
||||
- multi_node_tep
|
||||
- multi_node_dep
|
||||
|
||||
kv_offload_support:
|
||||
offloading_cpu: verified
|
||||
offloading_fs: verified
|
||||
|
||||
hardware_overrides:
|
||||
amd:
|
||||
extra_args:
|
||||
- "--gpu-memory-utilization"
|
||||
- "0.9"
|
||||
extra_env:
|
||||
VLLM_ROCM_USE_AITER: "1"
|
||||
SAFETENSORS_FAST_GPU: "1"
|
||||
strategy_overrides: {}
|
||||
|
||||
guide: |
|
||||
## Overview
|
||||
|
||||
ERNIE 4.5 is Baidu's MoE language model family. This recipe covers the text-only
|
||||
variants:
|
||||
|
||||
- `baidu/ERNIE-4.5-21B-A3B-PT` — 21B total / 3B active (fits on 1x80GB)
|
||||
- `baidu/ERNIE-4.5-300B-A47B-PT` — 300B total / 47B active (8x80GB FP8 or 16x80GB BF16)
|
||||
|
||||
Both support ERNIE-MTP speculative decoding via `--speculative-config`.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- transformers >= 4.54.0
|
||||
- vLLM >= 0.10.1
|
||||
- Hardware depends on variant (see above)
|
||||
|
||||
### Install vLLM
|
||||
|
||||
```bash
|
||||
uv venv --python 3.12 --seed
|
||||
source .venv/bin/activate
|
||||
uv pip install vllm --torch-backend=auto
|
||||
```
|
||||
|
||||
## Launch commands
|
||||
|
||||
21B on 1x80GB GPU:
|
||||
|
||||
```bash
|
||||
vllm serve baidu/ERNIE-4.5-21B-A3B-PT
|
||||
```
|
||||
|
||||
300B on 8x80GB with vLLM FP8 online quantization:
|
||||
|
||||
```bash
|
||||
vllm serve baidu/ERNIE-4.5-300B-A47B-PT \
|
||||
--tensor-parallel-size 8 \
|
||||
--gpu-memory-utilization 0.95 \
|
||||
--quantization fp8
|
||||
```
|
||||
|
||||
300B on 16x80GB native BF16 (multi-node via Ray):
|
||||
|
||||
```bash
|
||||
vllm serve baidu/ERNIE-4.5-300B-A47B-PT --tensor-parallel-size 16
|
||||
```
|
||||
|
||||
ERNIE-MTP speculative decoding (21B example):
|
||||
|
||||
```bash
|
||||
vllm serve baidu/ERNIE-4.5-21B-A3B-PT \
|
||||
--speculative-config '{"method":"ernie_mtp","model":"baidu/ERNIE-4.5-21B-A3B-PT","num_speculative_tokens":1}'
|
||||
```
|
||||
|
||||
## Client Usage
|
||||
|
||||
Standard OpenAI-compatible API; model ID is the HF repo.
|
||||
|
||||
## Benchmarking
|
||||
|
||||
```bash
|
||||
vllm bench serve \
|
||||
--model baidu/ERNIE-4.5-21B-A3B-PT \
|
||||
--dataset-name random \
|
||||
--random-input-len 8000 --random-output-len 1000 \
|
||||
--request-rate 10 --num-prompts 16 --ignore-eos
|
||||
```
|
||||
|
||||
Test configurations: prompt-heavy (8k/1k), decode-heavy (1k/8k), balanced (1k/1k).
|
||||
Vary `--num-prompts` across 1, 16, 32, 64, 128, 256, 512.
|
||||
|
||||
## References
|
||||
|
||||
- [ERNIE-4.5-21B-A3B-PT](https://huggingface.co/baidu/ERNIE-4.5-21B-A3B-PT)
|
||||
- [ERNIE-4.5-300B-A47B-PT](https://huggingface.co/baidu/ERNIE-4.5-300B-A47B-PT)
|
||||
- [vLLM multi-node deployment](https://docs.vllm.ai/en/latest/serving/parallelism_scaling.html)
|
||||
@@ -0,0 +1,163 @@
|
||||
meta:
|
||||
title: "ERNIE-4.5-VL"
|
||||
slug: "ernie-4.5-vl"
|
||||
provider: "Ernie (Baidu)"
|
||||
description: "Baidu ERNIE 4.5 VL MoE vision-language models (28B-A3B, 424B-A47B) with heterogeneous text/vision experts"
|
||||
date_added: 2025-09-03
|
||||
date_updated: 2026-04-17
|
||||
tasks:
|
||||
- multimodal
|
||||
related_recipes:
|
||||
- baidu/ERNIE-4.5-21B-A3B-PT
|
||||
hardware:
|
||||
mi300x: verified
|
||||
mi325x: verified
|
||||
mi355x: verified
|
||||
|
||||
model:
|
||||
model_id: "baidu/ERNIE-4.5-VL-28B-A3B-PT"
|
||||
min_vllm_version: "0.11.0"
|
||||
architecture: moe
|
||||
parameter_count: "28B"
|
||||
active_parameters: "3B"
|
||||
context_length: 131072
|
||||
base_args:
|
||||
- "--trust-remote-code"
|
||||
base_env: {}
|
||||
|
||||
features:
|
||||
text_only:
|
||||
description: "Skip loading the vision encoder for text-only workloads — frees VRAM for KV cache. Mutually exclusive with encoder_parallel."
|
||||
args:
|
||||
- "--language-model-only"
|
||||
encoder_parallel:
|
||||
description: "Run the vision encoder in data-parallel mode — avoids TP comm overhead on the small encoder. Mutually exclusive with text_only."
|
||||
args:
|
||||
- "--mm-encoder-tp-mode"
|
||||
- "data"
|
||||
|
||||
opt_in_features:
|
||||
- text_only
|
||||
|
||||
variants:
|
||||
default:
|
||||
precision: bf16
|
||||
vram_minimum_gb: 67
|
||||
description: "BF16 weights; fits on 1x80GB GPU (28B VL variant)"
|
||||
|
||||
"424b":
|
||||
model_id: "baidu/ERNIE-4.5-VL-424B-A47B-PT"
|
||||
precision: bf16
|
||||
vram_minimum_gb: 1120
|
||||
description: "424B total / 47B active; 8x140GB BF16 or 16x80GB BF16"
|
||||
extra_args:
|
||||
- "--trust-remote-code"
|
||||
- "--tensor-parallel-size"
|
||||
- "8"
|
||||
|
||||
"424b_fp8":
|
||||
model_id: "baidu/ERNIE-4.5-VL-424B-A47B-PT"
|
||||
precision: fp8
|
||||
vram_minimum_gb: 640
|
||||
description: "424B with FP8 online quantization + CPU offload for 8x80GB testing"
|
||||
extra_args:
|
||||
- "--trust-remote-code"
|
||||
- "--tensor-parallel-size"
|
||||
- "8"
|
||||
- "--quantization"
|
||||
- "fp8"
|
||||
- "--cpu-offload-gb"
|
||||
- "50"
|
||||
|
||||
compatible_strategies:
|
||||
- single_node_tp
|
||||
- multi_node_tp
|
||||
- multi_node_tep
|
||||
- multi_node_dep
|
||||
|
||||
kv_offload_support:
|
||||
offloading_cpu: verified
|
||||
offloading_fs: verified
|
||||
|
||||
hardware_overrides: {}
|
||||
strategy_overrides: {}
|
||||
|
||||
guide: |
|
||||
## Overview
|
||||
|
||||
ERNIE 4.5 VL is Baidu's multimodal MoE model with heterogeneous experts (separate text
|
||||
and vision experts). Because of the heterogeneous architecture, **torch.compile and CUDA
|
||||
graphs are not supported**.
|
||||
|
||||
- `baidu/ERNIE-4.5-VL-28B-A3B-PT` — 28B total / 3B active (1x80GB)
|
||||
- `baidu/ERNIE-4.5-VL-424B-A47B-PT` — 424B total / 47B active (8x140GB BF16, 8x80GB FP8+offload, or 16x80GB BF16)
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- vLLM: support added to main branch recently; install latest
|
||||
- Hardware depends on variant
|
||||
|
||||
### Install vLLM (CUDA)
|
||||
|
||||
```bash
|
||||
uv venv --python 3.12 --seed
|
||||
source .venv/bin/activate
|
||||
uv pip install -U vllm --torch-backend auto
|
||||
```
|
||||
|
||||
### Install vLLM (AMD ROCm MI300X/MI325X/MI355X)
|
||||
|
||||
```bash
|
||||
uv pip install vllm --extra-index-url https://wheels.vllm.ai/rocm/
|
||||
```
|
||||
|
||||
## Launch commands
|
||||
|
||||
28B on 1x80GB:
|
||||
|
||||
```bash
|
||||
vllm serve baidu/ERNIE-4.5-VL-28B-A3B-PT --trust-remote-code
|
||||
```
|
||||
|
||||
424B BF16 on 8x140GB:
|
||||
|
||||
```bash
|
||||
vllm serve baidu/ERNIE-4.5-VL-424B-A47B-PT \
|
||||
--trust-remote-code \
|
||||
--tensor-parallel-size 8
|
||||
```
|
||||
|
||||
424B with FP8 + CPU offload on 8x80GB (testing only):
|
||||
|
||||
```bash
|
||||
vllm serve baidu/ERNIE-4.5-VL-424B-A47B-PT \
|
||||
--trust-remote-code \
|
||||
--tensor-parallel-size 8 \
|
||||
--quantization fp8 \
|
||||
--cpu-offload-gb 50
|
||||
```
|
||||
|
||||
28B on AMD MI300X+:
|
||||
|
||||
```bash
|
||||
VLLM_ROCM_USE_AITER=1 SAFETENSORS_FAST_GPU=1 \
|
||||
vllm serve baidu/ERNIE-4.5-VL-28B-A3B-PT \
|
||||
--tensor-parallel-size 4 \
|
||||
--gpu-memory-utilization 0.9 \
|
||||
--trust-remote-code
|
||||
```
|
||||
|
||||
## Benchmarking
|
||||
|
||||
```bash
|
||||
vllm bench serve \
|
||||
--model baidu/ERNIE-4.5-VL-28B-A3B-PT \
|
||||
--dataset-name random \
|
||||
--random-input-len 8000 --random-output-len 1000 \
|
||||
--request-rate 10 --num-prompts 16 --ignore-eos --trust-remote-code
|
||||
```
|
||||
|
||||
## References
|
||||
|
||||
- [ERNIE-4.5-VL-28B-A3B-PT](https://huggingface.co/baidu/ERNIE-4.5-VL-28B-A3B-PT)
|
||||
- [ERNIE-4.5-VL-424B-A47B-PT](https://huggingface.co/baidu/ERNIE-4.5-VL-424B-A47B-PT)
|
||||
@@ -0,0 +1,147 @@
|
||||
meta:
|
||||
title: "Unlimited-OCR"
|
||||
slug: "unlimited-ocr"
|
||||
provider: "Ernie (Baidu)"
|
||||
description: "Baidu's state-of-the-art document-parsing model with Reference Sliding Window Attention (R-SWA), optimized for full-page OCR and markdown generation."
|
||||
date_added: 2026-06-28
|
||||
date_updated: 2026-06-28
|
||||
tasks:
|
||||
- multimodal
|
||||
performance_headline: "One-shot long-horizon document parsing to markdown"
|
||||
related_recipes:
|
||||
- "deepseek-ai/DeepSeek-OCR"
|
||||
|
||||
model:
|
||||
model_id: "baidu/Unlimited-OCR"
|
||||
min_vllm_version: "0.25.0"
|
||||
docker_image: "vllm/vllm-openai:unlimited-ocr"
|
||||
install:
|
||||
pip:
|
||||
note: "Unlimited-OCR (UnlimitedOCRForCausalLM) is supported since vLLM v0.25.0."
|
||||
architecture: dense
|
||||
parameter_count: "3B"
|
||||
active_parameters: "3B"
|
||||
context_length: 32768
|
||||
base_args:
|
||||
- "--trust-remote-code"
|
||||
- "--logits_processors"
|
||||
- "vllm.model_executor.models.unlimited_ocr:NGramPerReqLogitsProcessor"
|
||||
- "--no-enable-prefix-caching"
|
||||
- "--mm-processor-cache-gb"
|
||||
- "0"
|
||||
base_env: {}
|
||||
|
||||
features:
|
||||
encoder_parallel:
|
||||
description: "Run the vision encoder in data-parallel mode — avoids TP comm overhead on the small encoder."
|
||||
args:
|
||||
- "--mm-encoder-tp-mode"
|
||||
- "data"
|
||||
|
||||
opt_in_features:
|
||||
- encoder_parallel
|
||||
|
||||
variants:
|
||||
default:
|
||||
precision: bf16
|
||||
vram_minimum_gb: 8
|
||||
description: "Full precision BF16 (~3B params)"
|
||||
|
||||
compatible_strategies:
|
||||
- single_node_tp
|
||||
- multi_node_tp
|
||||
|
||||
hardware_overrides: {}
|
||||
|
||||
strategy_overrides: {}
|
||||
|
||||
guide: |
|
||||
## Overview
|
||||
|
||||
[Unlimited-OCR](https://huggingface.co/baidu/Unlimited-OCR) is Baidu's
|
||||
DeepSeek-OCR-lineage document-parsing model. It shares the DeepSeek-OCR
|
||||
*gundam* vision stack (SAM-ViT-B + CLIP-L DeepEncoder, `base_size=1024` /
|
||||
`image_size=640` / crop) and ships with the same n-gram logits processor for
|
||||
high-quality, repetition-free document → markdown generation.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- **Hardware**: a single GPU with >=8 GB VRAM is enough for BF16 inference.
|
||||
- **vLLM**: served from the dedicated release image (the architecture is not yet
|
||||
in a stable pip wheel). Pull the image shown in the Install → Docker tab.
|
||||
|
||||
## Serving recipe (required)
|
||||
|
||||
The model has **no chat template** and is trained for a specific prompt/decode
|
||||
recipe — without it the model returns empty output. The required pieces:
|
||||
|
||||
- register the no-repeat-ngram logits processor on the server:
|
||||
`--logits_processors vllm.model_executor.models.unlimited_ocr:NGramPerReqLogitsProcessor`
|
||||
- prompt text must begin with a literal `<image>` (e.g. `<image>document parsing.`)
|
||||
- `skip_special_tokens=False`
|
||||
- pass the processor args per request: `ngram_size=35`, `window_size=128`
|
||||
(use `window_size=1024` for multi-page / PDF input)
|
||||
|
||||
## Client Usage
|
||||
|
||||
### Online OCR serving
|
||||
|
||||
```bash
|
||||
docker run --rm --gpus all --network host --ipc host \
|
||||
vllm/vllm-openai:unlimited-ocr \
|
||||
baidu/Unlimited-OCR \
|
||||
--trust-remote-code \
|
||||
--logits_processors vllm.model_executor.models.unlimited_ocr:NGramPerReqLogitsProcessor \
|
||||
--no-enable-prefix-caching \
|
||||
--mm-processor-cache-gb 0
|
||||
```
|
||||
|
||||
```python
|
||||
import time
|
||||
from openai import OpenAI
|
||||
|
||||
client = OpenAI(api_key="EMPTY", base_url="http://localhost:8000/v1", timeout=3600)
|
||||
|
||||
messages = [
|
||||
{
|
||||
"role": "user",
|
||||
"content": [
|
||||
{"type": "text", "text": "<image>document parsing."},
|
||||
{"type": "image_url", "image_url": {"url": "https://huggingface.co/baidu/Unlimited-OCR/resolve/main/assets/baidu.png"}},
|
||||
],
|
||||
}
|
||||
]
|
||||
|
||||
start = time.time()
|
||||
response = client.chat.completions.create(
|
||||
model="baidu/Unlimited-OCR",
|
||||
messages=messages,
|
||||
max_tokens=8192,
|
||||
temperature=0.0,
|
||||
extra_body={
|
||||
"skip_special_tokens": False,
|
||||
"vllm_xargs": {"ngram_size": 35, "window_size": 128},
|
||||
},
|
||||
)
|
||||
print(f"Response costs: {time.time() - start:.2f}s")
|
||||
print(f"Generated text: {response.choices[0].message.content}")
|
||||
```
|
||||
|
||||
The raw output carries `<|ref|>…<|/ref|>` / `<|det|>…<|/det|>` grounding tokens;
|
||||
unwrap the `<|ref|>` text and drop the `<|det|>` coordinate boxes to get clean markdown.
|
||||
|
||||
## Troubleshooting / Configuration Tips
|
||||
|
||||
- **The custom logits processor is required** — without it long documents loop on
|
||||
`<|det|>` coordinate tokens.
|
||||
- Empty output almost always means the prompt is missing the literal `<image>`
|
||||
prefix or `skip_special_tokens` was left `True`.
|
||||
- OCR tasks don't benefit from prefix caching / image reuse, so prefix caching and
|
||||
the mm-processor cache are disabled in the recipe.
|
||||
- Single-image input uses gundam (crop) mode; multi-image requests automatically
|
||||
fall back to non-crop (base) mode — use `window_size=1024` for those.
|
||||
|
||||
## References
|
||||
|
||||
- [Unlimited-OCR on Hugging Face](https://huggingface.co/baidu/Unlimited-OCR)
|
||||
- [vLLM multimodal inputs guide](https://docs.vllm.ai/en/latest/features/multimodal_inputs.html#offline-inference)
|
||||
Reference in New Issue
Block a user