Skip to content

[None][feat] add FLUX visual generation examples#14987

Open
karljang wants to merge 1 commit into
NVIDIA:mainfrom
karljang:feat/flux-examples
Open

[None][feat] add FLUX visual generation examples#14987
karljang wants to merge 1 commit into
NVIDIA:mainfrom
karljang:feat/flux-examples

Conversation

@karljang
Copy link
Copy Markdown
Collaborator

@karljang karljang commented Jun 5, 2026

Description

Add lightweight VisualGen examples for FLUX.1 and FLUX.2, following the per-model example pattern used by models/wan_t2v.py and PR #14981:

  • examples/visual_gen/models/flux1.py
  • examples/visual_gen/models/flux2.py
  • shared NVFP4 1-GPU YAML configs for both models
  • README usage entries

The examples start from visual_gen.default_params, set num_images_per_prompt, and save either one image or indexed image outputs for multi-image generation.

Test Coverage

  • python3 -m py_compile examples/visual_gen/models/flux1.py examples/visual_gen/models/flux2.py
  • git diff --check
  • pre-commit run --files examples/visual_gen/README.md examples/visual_gen/models/flux1.py examples/visual_gen/models/flux2.py examples/visual_gen/configs/flux1-dev-fp4-1gpu.yaml examples/visual_gen/configs/flux2-dev-fp4-1gpu.yaml

PR Checklist

Please review the following before submitting your PR:

  • PR description clearly explains what and why. If using CodeRabbit's summary, please make sure it makes sense.

  • PR Follows TRT-LLM CODING GUIDELINES to the best of your knowledge.

  • Test cases are provided for new code paths (see test instructions)

  • If PR introduces API changes, an appropriate PR label is added - either api-compatible or api-breaking. For api-breaking, include BREAKING in the PR title.

  • Any new dependencies have been scanned for license and vulnerabilities

  • CODEOWNERS updated if ownership changes

  • Documentation updated as needed

  • Update tava architecture diagram if there is a significant design change in PR.

  • The reviewers assigned automatically/manually are appropriate for the PR.

  • Please check this after reviewing the above items as appropriate for this PR.

Summary by CodeRabbit

  • Documentation

    • Updated usage instructions with examples for FLUX.1 and FLUX.2 models featuring quantization configurations.
  • New Features

    • Added standalone CLI scripts for FLUX.1 and FLUX.2 text-to-image generation.
    • Added quantization configuration files optimized for efficient single-GPU execution.

@karljang karljang requested a review from a team as a code owner June 5, 2026 03:59
@karljang karljang requested review from QiJune and Shixiaowei02 June 5, 2026 03:59
@karljang
Copy link
Copy Markdown
Collaborator Author

karljang commented Jun 5, 2026

/bot run --disable-fail-fast

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 5, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

This PR extends the FLUX text-to-image generation examples by adding two new Python CLI scripts (flux1.py and flux2.py), corresponding single-GPU NVFP4 quantization configurations, and usage documentation. Both scripts implement identical CLI and generation workflows using the existing VisualGen API.

Changes

FLUX Model Examples and Configuration

Layer / File(s) Summary
FLUX quantization configurations
examples/visual_gen/configs/flux1-dev-fp4-1gpu.yaml, examples/visual_gen/configs/flux2-dev-fp4-1gpu.yaml
Two matching YAML config files define single-GPU FLUX.1-dev and FLUX.2-dev setups with NVFP4 dynamic quantization, vanilla attention backend, unit parallelism sizes, and disabled CUDA graphs.
FLUX.1 example script
examples/visual_gen/models/flux1.py
CLI script that accepts model, optional YAML config, prompt text, image count, and output path; loads VisualGenArgs from YAML if provided; constructs VisualGen instance; generates images from prompt using model defaults overridden with requested image count; saves to computed output paths.
FLUX.2 example script
examples/visual_gen/models/flux2.py
Parallel implementation of flux1.py for FLUX.2 model with identical argument parsing, YAML config loading, image generation, and output handling logic.
Usage documentation
examples/visual_gen/README.md
Updated Usage section with python models/flux1.py and python models/flux2.py command examples, each referencing their respective 1-GPU NVFP4 config YAML.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested labels

VisualGen, Doc

Suggested reviewers

  • chang-l
  • nv-guomingz
  • venkywonka
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title '[None][feat] add FLUX visual generation examples' clearly and concisely summarizes the main change—adding FLUX.1 and FLUX.2 example scripts with configs.
Description check ✅ Passed The PR description adequately covers the what (new example files and configs), why (following established patterns from wan_t2v.py), test coverage (compilation, linting, pre-commit checks), and checklist completion.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
examples/visual_gen/models/flux2.py (1)

37-37: ⚡ Quick win

Add return type annotation to main().

Per the coding guidelines, functions should always be annotated: "Always annotate functions. Make the return type None if the function does not return anything." As per coding guidelines, Python functions and methods should use snake_case (e.g., def my_awesome_function():), and type annotations should be complete.

📝 Suggested fix
-def main():
+def main() -> None:
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@examples/visual_gen/models/flux2.py` at line 37, The function definition for
main lacks a return type annotation; update the signature of main (def main) to
include an explicit return type of None (e.g., change to def main() -> None:) to
satisfy the "Always annotate functions" guideline and keep the existing
snake_case name; ensure any internal or related function docstrings/type hints
remain consistent with the new annotation.
examples/visual_gen/models/flux1.py (1)

37-37: ⚡ Quick win

Add return type annotation to main().

Per the coding guidelines, functions should always be annotated: "Always annotate functions. Make the return type None if the function does not return anything." As per coding guidelines, Python functions and methods should use snake_case (e.g., def my_awesome_function():), and type annotations should be complete.

📝 Suggested fix
-def main():
+def main() -> None:
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@examples/visual_gen/models/flux1.py` at line 37, The function definition for
main lacks a return type annotation; update the signature of the main function
(def main()) to include an explicit return type of None (i.e., def main() ->
None:) per the coding guidelines, and verify the function name follows
snake_case (main is fine) and that any other functions in this module likewise
have complete type annotations.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@examples/visual_gen/models/flux1.py`:
- Line 37: The function definition for main lacks a return type annotation;
update the signature of the main function (def main()) to include an explicit
return type of None (i.e., def main() -> None:) per the coding guidelines, and
verify the function name follows snake_case (main is fine) and that any other
functions in this module likewise have complete type annotations.

In `@examples/visual_gen/models/flux2.py`:
- Line 37: The function definition for main lacks a return type annotation;
update the signature of main (def main) to include an explicit return type of
None (e.g., change to def main() -> None:) to satisfy the "Always annotate
functions" guideline and keep the existing snake_case name; ensure any internal
or related function docstrings/type hints remain consistent with the new
annotation.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 7e50b627-95ac-4aa2-8494-3f815f4a459e

📥 Commits

Reviewing files that changed from the base of the PR and between 81e86a5 and cd9bde1.

📒 Files selected for processing (5)
  • examples/visual_gen/README.md
  • examples/visual_gen/configs/flux1-dev-fp4-1gpu.yaml
  • examples/visual_gen/configs/flux2-dev-fp4-1gpu.yaml
  • examples/visual_gen/models/flux1.py
  • examples/visual_gen/models/flux2.py

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #52232 [ run ] triggered by Bot. Commit: cd9bde1 Link to invocation

@karljang karljang force-pushed the feat/flux-examples branch from cd9bde1 to f509cb9 Compare June 5, 2026 06:12
@karljang
Copy link
Copy Markdown
Collaborator Author

karljang commented Jun 5, 2026

/bot run --disable-fail-fast

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #52273 [ run ] triggered by Bot. Commit: f509cb9 Link to invocation

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #52232 [ run ] completed with state ABORTED. Commit: cd9bde1

Link to invocation

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #52273 [ run ] completed with state SUCCESS. Commit: f509cb9
/LLM/main/L0_MergeRequest_PR pipeline #41584 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

CI Agent Failure Analysis

Link to invocation

Signed-off-by: Kanghwan Jang <861393+karljang@users.noreply.github.com>
@karljang karljang force-pushed the feat/flux-examples branch from f509cb9 to cacf20b Compare June 5, 2026 17:00
@karljang
Copy link
Copy Markdown
Collaborator Author

karljang commented Jun 5, 2026

/bot run --disable-fail-fast

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #52391 [ run ] triggered by Bot. Commit: cacf20b Link to invocation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants