[Refactor]: Intrduce x_to_text.py in examples (#5384)

Signed-off-by: princepride <wangzhipeng628@gmail.com>
Signed-off-by: 汪志鹏 <wangzhipeng628@gmail.com>
This commit is contained in:
汪志鹏 authored and GitHub committed 2026-07-26 16:33:17 +08:00
1 parent b6c4578dac
commit ccdb2b51aa
12 files changed
+457 -9

No files matched your search

+22 -1
View File
@@ -6,7 +6,7 @@
- Vendor: ByteDance Seed
- Model: `ByteDance-Seed/BAGEL-7B-MoT`
- Task: Text-to-image and image-to-image generation
- Task: Text-to-image, image-to-image, text-to-text, and image-to-text
- Mode: Offline inference and OpenAI-compatible online serving
- Maintainer: Community
@@ -26,6 +26,8 @@ parameters through the pipeline-declared `extra_args` contract.
[`examples/offline_inference/text_to_image/text_to_image.py`](../../examples/offline_inference/text_to_image/text_to_image.py)
- Related offline image-to-image example:
[`examples/offline_inference/image_to_image/image_edit.py`](../../examples/offline_inference/image_to_image/image_edit.py)
- Related offline understanding example:
[`examples/offline_inference/x_to_text/x_to_text.py`](../../examples/offline_inference/x_to_text/x_to_text.py)
- Related online example:
[`examples/online_serving/text_to_image/openai_chat_client.py`](../../examples/online_serving/text_to_image/openai_chat_client.py)
- Related online image-to-image example:
@@ -118,6 +120,25 @@ The `--extra-args` JSON forwards BAGEL-specific parameters (e.g. `cfg_text_scale
`cfg_img_scale`, `cfg_interval`, `cfg_renorm_type`) into
`OmniDiffusionSamplingParams.extra_args` via the model-extras registry.
Run text-to-text with the shared understanding example. BAGEL's default
`bagel.yaml` deploy config is discovered from the checkpoint, so no model-specific
example or explicit deploy config is required:
```bash
python examples/offline_inference/x_to_text/x_to_text.py \
--model ByteDance-Seed/BAGEL-7B-MoT \
--prompt "Where is the capital of France?"
```
Add `--image` to run image-to-text with the same example:
```bash
python examples/offline_inference/x_to_text/x_to_text.py \
--model ByteDance-Seed/BAGEL-7B-MoT \
--image /path/to/input.jpg \
--prompt "Please describe this image in detail."
```
#### Online Commands
Start the OpenAI-compatible server:
+25 -4
View File
@@ -1,6 +1,6 @@
# MammothModa2-Preview
> MammothModa2-Preview text-to-image generation through the shared offline image example
> MammothModa2-Preview generation and understanding through shared offline examples
## Summary
@@ -13,8 +13,8 @@
## When to use this recipe
Use this recipe to run MammothModa2-Preview text-to-image through the shared
offline image example (`text_to_image.py`) instead of a model-specific script.
Use this recipe to run MammothModa2-Preview through shared task-oriented
offline examples. Text-to-image uses the shared image example (`text_to_image.py`) instead of a model-specific script.
The generic example formats the AR prompt, drives the AR → DiT stage pipeline,
and forwards MammothModa2-specific generation parameters through the
pipeline-declared `extra_body` contract.
@@ -29,8 +29,10 @@ flags. Image size uses the standard `--height` / `--width` flags.
- Upstream model:
[`bytedance-research/MammothModa2-Preview`](https://huggingface.co/bytedance-research/MammothModa2-Preview)
- Related offline example:
- Related text-to-image example:
[`examples/offline_inference/text_to_image/text_to_image.py`](../../examples/offline_inference/text_to_image/text_to_image.py)
- Related T2T/I2T example:
[`examples/offline_inference/x_to_text/x_to_text.py`](../../examples/offline_inference/x_to_text/x_to_text.py)
- Declared parameters:
[`vllm_omni/model_extras/mammothmodal2_preview.py`](../../vllm_omni/model_extras/mammothmodal2_preview.py)
- Deploy config:
@@ -100,6 +102,25 @@ so unknown keys for MammothModa2 are silently dropped:
`--height` and `--width` must be multiples of 16.
Run text-to-text through the shared understanding example. It recognizes the
MammothModa2 checkpoint and automatically selects `mammoth_moda2_ar.yaml`:
```bash
python examples/offline_inference/x_to_text/x_to_text.py \
--model ./MammothModa2-Preview \
--prompt "Explain multimodal generation in three sentences."
```
Add an image for image-to-text or image summarization. The shared example
uses MammothModa2's chat and vision-token template:
```bash
python examples/offline_inference/x_to_text/x_to_text.py \
--model ./MammothModa2-Preview \
--image /path/to/input.jpg \
--prompt "Please summarize the content of this image."
```
#### Verification
The example writes the generated image to the `--output` path. Confirm the file
+30 -3
View File
@@ -8,8 +8,8 @@
- Vendor: Tencent Hunyuan
- Model: `tencent/HunyuanImage-3.0-Instruct`
- Task: Text-to-image generation
- Mode: Online serving and performance benchmarking, DiT stage only
- Task: Text-to-image generation; text-to-text and image-to-text understanding
- Mode: Offline understanding, online serving, and performance benchmarking
- Maintainer: Community
## When to use this recipe
@@ -31,8 +31,10 @@ FP8/NVFP4 configuration:
## References
- Model: <https://huggingface.co/tencent/HunyuanImage-3.0-Instruct>
- Offline example:
- Existing model-specific offline example:
[`examples/offline_inference/hunyuan_image3`](../../examples/offline_inference/hunyuan_image3)
- Shared T2T/I2T example:
[`examples/offline_inference/x_to_text/x_to_text.py`](../../examples/offline_inference/x_to_text/x_to_text.py)
- Related PRs:
[#2495](https://github.com/vllm-project/vllm-omni/pull/2495) for DiT performance CI,
[#3055](https://github.com/vllm-project/vllm-omni/pull/3055) for GEBench accuracy CI,
@@ -42,6 +44,31 @@ FP8/NVFP4 configuration:
## GPU
### Shared T2T/I2T offline example
For text-to-text, the shared x-to-text example automatically selects the
AR-only Hunyuan deploy config and applies the checkpoint's prompt tokens and
stop-token rules:
```bash
python examples/offline_inference/x_to_text/x_to_text.py \
--model tencent/HunyuanImage-3.0-Instruct \
--prompt "Explain why the sky appears blue."
```
Add `--image` for image-to-text:
```bash
python examples/offline_inference/x_to_text/x_to_text.py \
--model tencent/HunyuanImage-3.0-Instruct \
--image /path/to/input.jpg \
--prompt "Describe the content of this image."
```
The AR-only default uses four GPUs. Pass `--deploy-config` to override the
layout. Image-output tasks remain documented by the existing model-specific
example and the DiT sections below.
### 4x H100/H800 80GB
#### Environment