Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/source/models/visual-generation.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ TensorRT-LLM **VisualGen** provides a unified inference stack for diffusion mode
| `nvidia/Cosmos3-Edge` | Text-to-Image, Text-to-Video, Image-to-Video (Nemotron-dense backbone, 480p-native) |
| `hunyuanvideo-community/HunyuanVideo-1.5-Diffusers-480p_t2v` | Text-to-Video |
| `hunyuanvideo-community/HunyuanVideo-1.5-Diffusers-720p_t2v` | Text-to-Video |
| `zai-org/GLM-Image` | Text-to-Image |


Models are auto-detected from the checkpoint directory. Diffusers-format models are detected via `model_index.json`; LTX-2 monolithic safetensors checkpoints are detected via embedded metadata. The `AutoPipeline` registry selects the appropriate pipeline class automatically.
Expand All @@ -67,6 +68,7 @@ Models are auto-detected from the checkpoint directory. Diffusers-format models
| **Qwen-Image-Edit-2511** | Yes | Yes | No | No | Yes | No | No | Yes | Yes | No | No | No | No | No |
| **Cosmos3** | Yes | Yes | No | No | Yes | Yes | Yes | Yes | Yes | Yes | No | No | Yes | No |
| **HunyuanVideo 1.5** | Yes | Yes | No | No | No | No | No | No | No | Yes | No | No | No | No |
| **GlmImage** | Yes | Yes | No | No | No | No | No | No | No | Yes | No | No | No | No |

[^1]: FLUX models use embedded guidance and do not have a separate negative prompt path, so CFG parallelism is not applicable.

Expand Down
1 change: 1 addition & 0 deletions examples/visual_gen/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ python models/cosmos3_ti2v.py --prompt "A robot arm picks fruit in a grocery sto
python models/qwen_image.py
python models/qwen_image_layered.py --image /path/to/image.png
python models/qwen_image_edit.py --image /path/to/source.png --prompt "Make the image look like a watercolor painting"
python models/glm_image.py
python models/hunyuan_t2v.py

# With engine config (quant, parallelism, etc.)
Expand Down
81 changes: 81 additions & 0 deletions examples/visual_gen/models/glm_image.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Copyright (c) 2026, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""GlmImage text-to-image generation.

Usage:
python glm_image.py
"""

import argparse
from pathlib import Path

from tensorrt_llm import VisualGen, VisualGenArgs


def _output_paths(output_path: str, num_images: int) -> str | list[str]:
if num_images == 1:
return output_path

path = Path(output_path)
return [str(path.with_name(f"{path.stem}_{index}{path.suffix}")) for index in range(num_images)]


def parse_args() -> argparse.Namespace:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument(
"--model",
default="zai-org/GLM-Image",
help="Hugging Face model id or local checkpoint path.",
)
parser.add_argument(
"--visual_gen_args",
"--extra_visual_gen_options",
dest="visual_gen_args",
help="Optional VisualGenArgs YAML file.",
)
parser.add_argument(
"--prompt",
default="A serene mountain lake at sunrise, watercolor style, highly detailed",
help="Text prompt for image generation.",
)
parser.add_argument(
"--num_images_per_prompt",
type=int,
default=1,
help="Number of images to generate for the prompt.",
)
parser.add_argument(
"--output_path",
default="glm_image_output.png",
help="Image output path. Multiple images append an index before the suffix.",
)
return parser.parse_args()


def main() -> None:
args = parse_args()
if args.num_images_per_prompt < 1:
raise ValueError("--num_images_per_prompt must be >= 1")
extra_args = VisualGenArgs.from_yaml(args.visual_gen_args) if args.visual_gen_args else None
visual_gen = VisualGen(model=args.model, args=extra_args)
params = visual_gen.default_params
params.num_images_per_prompt = args.num_images_per_prompt
output = visual_gen.generate(inputs=args.prompt, params=params)
saved = output.save(_output_paths(args.output_path, args.num_images_per_prompt))
print(f"Saved image(s) to {saved}")


if __name__ == "__main__":
main()
2 changes: 2 additions & 0 deletions tensorrt_llm/_torch/visual_gen/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
from ..pipeline_registry import AutoPipeline, register_pipeline
from .cosmos3 import Cosmos3OmniMoTPipeline
from .flux import Flux2Pipeline, FluxPipeline
from .glm_image import GlmImagePipeline
from .hunyuan_video1_5 import HunyuanVideo15Pipeline
from .ltx2 import LTX2Pipeline # noqa: F401
from .qwen_image import QwenImageEditPlusPipeline, QwenImagePipeline
Expand All @@ -46,6 +47,7 @@
"BasePipeline",
"FluxPipeline",
"Flux2Pipeline",
"GlmImagePipeline",
"QwenImageEditPlusPipeline",
"QwenImageLayeredPipeline",
"QwenImagePipeline",
Expand Down
19 changes: 19 additions & 0 deletions tensorrt_llm/_torch/visual_gen/models/glm_image/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# SPDX-FileCopyrightText: Copyright (c) 2022-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from .pipeline_glm_image import GlmImagePipeline
from .transformer_glm_image import GlmImageAttention, GlmImageTransformer2DModel

__all__ = ["GlmImageAttention", "GlmImagePipeline", "GlmImageTransformer2DModel"]
Loading
Loading