Skip to content
Closed
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 examples/visual_gen/models/wan_t2v.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ def main():
params.height = 480
params.width = 832
params.num_frames = 165
# Pinned seed so VBench accuracy tests are deterministic (see nvbugs/6357628).
params.seed = 42

output = visual_gen.generate(
inputs="A cute cat playing piano",
Expand Down
22 changes: 18 additions & 4 deletions tests/integration/defs/examples/visual_gen/test_visual_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import json
import os
import random
import shutil
import subprocess
import sys
import time
Expand Down Expand Up @@ -201,8 +202,10 @@ def _visual_gen_deps(llm_venv):
llm_venv.run_cmd(["-m", "pip", "install", "av"])
llm_venv.run_cmd(["-m", "pip", "install", "diffusers>=0.37.0"])
# Install ffmpeg system package required by save_video() for MP4 encoding
check_call(["apt-get", "update", "-y"], shell=False)
check_call(["apt-get", "install", "-y", "ffmpeg"], shell=False)
if shutil.which("ffmpeg") is None:
sudo = ["sudo"] if os.getuid() != 0 else []
check_call(sudo + ["apt-get", "update", "-y"], shell=False)
check_call(sudo + ["apt-get", "install", "-y", "ffmpeg"], shell=False)


@pytest.fixture(scope="session")
Expand Down Expand Up @@ -958,6 +961,9 @@ def test_vbench_dimension_score_wan(vbench_repo_root, wan21_bf16_video_path, llm
"""Run VBench on WAN 2.1 BF16 video generated with the LPIPS config."""
videos_dir = os.path.dirname(wan21_bf16_video_path)
assert os.path.isfile(wan21_bf16_video_path), "WAN 2.1 BF16 video must exist"
# dynamic_degree is binary (0/1) and aesthetic/imaging quality swing 0.15-0.25 across
# seeds even at fixed seed; widen those bands so the test asserts on the dimensions
# that are stable. See nvbugs/6357628 for analysis.
_run_vbench_and_report(
vbench_repo_root,
videos_dir,
Expand All @@ -966,6 +972,11 @@ def test_vbench_dimension_score_wan(vbench_repo_root, wan21_bf16_video_path, llm
title="WAN 2.1 BF16",
golden_scores=VBENCH_WAN_GOLDEN_SCORES,
max_score_diff=0.05,
per_dimension_tolerances={
"dynamic_degree": 1.0,
"aesthetic_quality": 0.25,
"imaging_quality": 0.25,
},
)


Expand All @@ -977,6 +988,7 @@ def _run_vbench_and_report(
title,
golden_scores=None,
max_score_diff=0.10,
per_dimension_tolerances=None,
):
"""Run VBench, print scores, and optionally assert against golden values.

Expand Down Expand Up @@ -1044,10 +1056,12 @@ def _run_vbench_and_report(
max_diff_val = max(abs(scores_trtllm[d] - golden_scores[d]) for d in VBENCH_DIMENSIONS)
print(f"max_diff={max_diff_val:.4f} (threshold={max_score_diff})")
print("=" * len(header) + "\n")
tolerances = per_dimension_tolerances or {}
for dim in VBENCH_DIMENSIONS:
diff = abs(scores_trtllm[dim] - golden_scores[dim])
assert diff < max_score_diff or scores_trtllm[dim] >= golden_scores[dim], (
f"Dimension '{dim}' score difference {diff:.4f} >= {max_score_diff} "
dim_threshold = tolerances.get(dim, max_score_diff)
assert diff < dim_threshold or scores_trtllm[dim] >= golden_scores[dim], (
f"Dimension '{dim}' score difference {diff:.4f} >= {dim_threshold} "
Comment on lines +1059 to +1064

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Allow the full binary dynamic_degree swing.

Line 1136 still uses a strict <. With per_dimension_tolerances["dynamic_degree"] = 1.0, a golden score of 1.0 and observed score of 0.0 still fail because 1.0 < 1.0 is false. That leaves the WAN test flaky on the exact 0↔1 case this PR is trying to tolerate.

Proposed fix
-        assert diff < dim_threshold or scores_trtllm[dim] >= golden_scores[dim], (
+        assert diff <= dim_threshold or scores_trtllm[dim] >= golden_scores[dim], (
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
tolerances = per_dimension_tolerances or {}
for dim in VBENCH_DIMENSIONS:
diff = abs(scores_trtllm[dim] - golden_scores[dim])
assert diff < max_score_diff or scores_trtllm[dim] >= golden_scores[dim], (
f"Dimension '{dim}' score difference {diff:.4f} >= {max_score_diff} "
dim_threshold = tolerances.get(dim, max_score_diff)
assert diff < dim_threshold or scores_trtllm[dim] >= golden_scores[dim], (
f"Dimension '{dim}' score difference {diff:.4f} >= {dim_threshold} "
tolerances = per_dimension_tolerances or {}
for dim in VBENCH_DIMENSIONS:
diff = abs(scores_trtllm[dim] - golden_scores[dim])
dim_threshold = tolerances.get(dim, max_score_diff)
assert diff <= dim_threshold or scores_trtllm[dim] >= golden_scores[dim], (
f"Dimension '{dim}' score difference {diff:.4f} >= {dim_threshold} "
🤖 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 `@tests/integration/defs/examples/visual_gen/test_visual_gen.py` around lines
1132 - 1137, The tolerance check in the visual generation test still rejects
exact boundary changes for dynamic_degree because it uses a strict less-than
comparison. Update the assertion in the VBENCH_DIMENSIONS loop in
test_visual_gen.py so the per-dimension tolerance allows equality at the
threshold, preserving the existing “or scores_trtllm[dim] >= golden_scores[dim]”
behavior while making the 0↔1 dynamic_degree swing pass when
per_dimension_tolerances["dynamic_degree"] is 1.0.

Source: Path instructions

f"(TRT-LLM={scores_trtllm[dim]:.4f}, golden={golden_scores[dim]:.4f})"
)
return scores_trtllm
Expand Down
Loading