-
Notifications
You must be signed in to change notification settings - Fork 1k
[Doc][Bagel] Add BAGEL-7B-MoT documentation and edit the default stage configuration #987
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
hsliuustc0106
merged 14 commits into
vllm-project:main
from
nussejzz:add-bagel-example-scripts
Jan 29, 2026
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
fa3b9d0
[Bugfix] Quote shell variable to prevent word splitting in bagel example
nussejzz d4139d6
feat: Add BAGEL-7B-MoT model examples and documentation for multi-mod…
nussejzz e88cf10
docs: add BAGEL example documentation and fix README issues
nussejzz f908008
Update GPU memory utilization in bagel.yaml
nussejzz 1fb7cca
Fix linting issues
nussejzz eaf75c3
refactor: update Bagel examples to download images and fix documentation
nussejzz bea382a
Improve English expression
nussejzz de72971
Improve English expression
nussejzz aab3cbb
delete unnecessary content
nussejzz a73a2d1
match the Stage Configuration table with bagel.yaml
nussejzz 1497c96
add recommended gpu configuration and needed VRAM
nussejzz dcd0e0d
delete blank line
nussejzz 6e88ea9
Improved documentation
nussejzz 086bad5
Trigger CI retry
nussejzz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,179 @@ | ||
| # BAGEL-7B-MoT | ||
|
|
||
| Source <https://github.com/vllm-project/vllm-omni/tree/main/examples/offline_inference/bagel>. | ||
|
|
||
| ## Set up | ||
|
|
||
| Please refer to the [stage configuration documentation](https://docs.vllm.ai/projects/vllm-omni/en/latest/configuration/stage_configs/) to configure memory allocation appropriately for your hardware setup. | ||
|
|
||
| ## Run examples | ||
|
|
||
| **Note**: These examples work with the default configuration on an **NVIDIA A100 (80GB)**. We also tested on dual **NVIDIA RTX 5000 Ada (32GB each)**. For dual-GPU setups, please modify the stage configuration to distribute the model across devices. | ||
|
|
||
| Get into the bagel folder | ||
|
|
||
| ```bash | ||
| cd examples/offline_inference/bagel | ||
| ``` | ||
|
|
||
| ### Modality Control | ||
|
|
||
| BAGEL-7B-MoT supports multiple modality modes. You can control the mode using the `--modality` argument: | ||
|
|
||
| #### Text to Image (text2img) | ||
|
|
||
| - **Pipeline**: Text → Thinker → DiT → VAE Decode → Image | ||
| - **Stages Used**: Stage 0 (Thinker) + Stage 1 (DiT) | ||
| - **KV Transfer**: Thinker sends KV cache to DiT for conditioned generation | ||
|
|
||
| Generate images from text prompts: | ||
|
|
||
| ```bash | ||
| python end2end.py --model ByteDance-Seed/BAGEL-7B-MoT \ | ||
| --modality text2img \ | ||
| --prompts "A cute cat" | ||
| ``` | ||
|
|
||
| #### Image to Image (img2img) | ||
|
|
||
| - **Pipeline**: Image → VAE Encode → DiT → VAE Decode → New Image | ||
| - **Stages Used**: Stage 1 (DiT) only | ||
| - **Special**: Bypasses the Thinker stage, direct image-to-image transformation | ||
|
|
||
| Transform images based on text prompts: | ||
|
|
||
| ```bash | ||
| python end2end.py --model ByteDance-Seed/BAGEL-7B-MoT \ | ||
| --modality img2img \ | ||
| --image-path /path/to/image.jpg \ | ||
| --prompts "Let the woman wear a blue dress" | ||
| ``` | ||
|
|
||
| #### Image to Text (img2text) | ||
|
|
||
| - **Pipeline**: Image → ViT + VAE Encode → Thinker → Text Output | ||
| - **Stages Used**: Stage 0 (Thinker) only | ||
| - **Special**: Uses both VAE latent encoding AND ViT semantic encoding for comprehensive image understanding | ||
|
|
||
| Generate text descriptions from images: | ||
|
|
||
| ```bash | ||
| python end2end.py --model ByteDance-Seed/BAGEL-7B-MoT \ | ||
| --modality img2text \ | ||
| --image-path /path/to/image.jpg \ | ||
| --prompts "Describe this image in detail" | ||
| ``` | ||
|
|
||
| #### Text to Text (text2text) | ||
|
|
||
| - **Pipeline**: Text → Thinker → Text Output | ||
| - **Stages Used**: Stage 0 (Thinker) only | ||
| - **Special**: No visual components involved, operates as pure language model | ||
|
|
||
| Pure text generation: | ||
|
|
||
| ```bash | ||
| python end2end.py --model ByteDance-Seed/BAGEL-7B-MoT \ | ||
| --modality text2text \ | ||
| --prompts "What is the capital of France?" | ||
|
|
||
| # You can load prompts from a text file (one prompt per line): | ||
| python end2end.py --model ByteDance-Seed/BAGEL-7B-MoT \ | ||
| --modality text2text \ | ||
| --txt-prompts /path/to/prompts.txt | ||
| ``` | ||
|
|
||
| ### Inference Steps | ||
|
|
||
| Control the number of inference steps for image generation: | ||
|
|
||
| ```bash | ||
| # You can adjust steps to 100 to improve image quality | ||
| python end2end.py --model ByteDance-Seed/BAGEL-7B-MoT \ | ||
| --modality text2img \ | ||
| --steps 50 \ | ||
| --prompts "A cute cat" | ||
| ``` | ||
|
|
||
| ### Key arguments | ||
|
|
||
| BAGEL-7B-MoT supports **multiple modality modes** for different use cases. | ||
|
|
||
| The default yaml configuration deploys Thinker and DiT on the same GPU. You can use the default configuration file: [`bagel.yaml`](../../../vllm_omni/model_executor/stage_configs/bagel.yaml) | ||
|
nussejzz marked this conversation as resolved.
|
||
|
|
||
| #### 📌 Command Line Arguments (end2end.py) | ||
|
|
||
| | Argument | Type | Default | Description | | ||
| | :--------------------- | :----- | :---------------------------- | :----------------------------------------------------------- | | ||
| | `--model` | string | `ByteDance-Seed/BAGEL-7B-MoT` | Model path or name | | ||
| | `--modality` | choice | `text2img` | Modality mode: `text2img`, `img2img`, `img2text`, `text2text` | | ||
| | `--prompts` | list | `None` | Input text prompts directly | | ||
| | `--txt-prompts` | string | `None` | Path to txt file with one prompt per line | | ||
| | `--image-path` | string | `None` | Input image path (for `img2img`/`img2text`) | | ||
| | `--steps` | int | `50` | Number of inference steps | | ||
| | `--stage-configs-path` | string | `None` | Custom stage config file path | | ||
| | `--worker-backend` | choice | `process` | Worker backend: `process` or `ray` | | ||
| | `--ray-address` | string | `None` | Ray cluster address | | ||
| | `--enable-stats` | flag | `False` | Enable statistics logging | | ||
| | `--init-sleep-seconds` | int | `20` | Initialization sleep time | | ||
| | `--batch-timeout` | int | `5` | Batch timeout | | ||
| | `--init-timeout` | int | `300` | Initialization timeout | | ||
|
|
||
| ------ | ||
|
|
||
| #### ⚙️ Stage Configuration Parameters (bagel.yaml) | ||
|
|
||
| **Stage 0 - Thinker (LLM Stage)** | ||
|
|
||
| | Parameter | Value | Description | | ||
| | :------------------------------- | :------------------------------ | :----------------------- | | ||
| | `stage_type` | `llm` | Stage type | | ||
| | `devices` | `"0"` | GPU device ID | | ||
| | `max_batch_size` | `1` | Maximum batch size | | ||
| | `model_stage` | `thinker` | Model stage identifier | | ||
| | `model_arch` | `BagelForConditionalGeneration` | Model architecture | | ||
| | `gpu_memory_utilization` | `0.4` | GPU memory utilization | | ||
| | `tensor_parallel_size` | `1` | Tensor parallel size | | ||
| | `max_num_batched_tokens` | `32768` | Maximum batched tokens | | ||
| | `omni_kv_config.need_send_cache` | `true` | Whether to send KV cache | | ||
|
|
||
| ------ | ||
|
|
||
| **Stage 1 - DiT (Diffusion Stage)** | ||
|
|
||
| | Parameter | Value | Description | | ||
| | :------------------------------- | :---------- | :-------------------------- | | ||
| | `stage_type` | `diffusion` | Stage type | | ||
| | `devices` | `"0"` | GPU device ID | | ||
| | `max_batch_size` | `1` | Maximum batch size | | ||
| | `model_stage` | `dit` | Model stage identifier | | ||
| | `gpu_memory_utilization` | `0.4` | GPU memory utilization | | ||
| | `omni_kv_config.need_recv_cache` | `true` | Whether to receive KV cache | | ||
| | `engine_input_source` | `[0]` | Input source from Stage 0 | | ||
|
|
||
| ------ | ||
|
|
||
| #### 🔗 Runtime Configuration | ||
|
|
||
| | Parameter | Value | Description | | ||
| | :-------------------- | :------ | :------------------------------- | | ||
| | `window_size` | `-1` | Window size (-1 means unlimited) | | ||
| | `max_inflight` | `1` | Maximum inflight requests | | ||
| | `shm_threshold_bytes` | `65536` | Shared memory threshold (64KB) | | ||
|
|
||
| ## FAQ | ||
|
|
||
| - If you encounter an error about the backend of librosa, try to install ffmpeg with the command below. | ||
|
|
||
| ```bash | ||
| sudo apt update | ||
| sudo apt install ffmpeg | ||
| ``` | ||
|
|
||
| - If you don’t know how much VRAM is needed for the model or encounter the OOM error, you can try to decrease the max_model_len. | ||
|
|
||
| | Stage | VRAM | | ||
| | :------------------ | :--------------------------- | | ||
| | Stage-0 (Thinker) | **15.04 GiB** **+ KV Cache** | | ||
| | Stage-1 (DiT) | **26.50 GiB** | | ||
| | Total | **~42 GiB + KV Cache** | | ||
|
nussejzz marked this conversation as resolved.
nussejzz marked this conversation as resolved.
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.