[https://nvbugs/6418815][fix] Revert the per-batch cross-attention slicing (drop real_text_lens plumbing in… - #15986
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughCosmos3 LPIPS tests now use pinned T2V and T2I generation parameters. The T2I golden configuration and waiver are updated. Failed T2I runs preserve generated candidates. OpenCV loading in the LPIPS evaluator is now lazy. ChangesCosmos3 LPIPS evaluation
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant T2V_T2I_Tests
participant Cosmos3Pipeline
participant LPIPSEvaluator
participant OpenCV
T2V_T2I_Tests->>Cosmos3Pipeline: Generate video with pinned parameters
Cosmos3Pipeline-->>T2V_T2I_Tests: Return generated candidate
T2V_T2I_Tests->>LPIPSEvaluator: Evaluate candidate against golden
LPIPSEvaluator->>OpenCV: Load on demand for video decoding
OpenCV-->>LPIPSEvaluator: Return decoded video frames
LPIPSEvaluator-->>T2V_T2I_Tests: Return LPIPS result
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
be138a5 to
1f80504
Compare
1f80504 to
57af1f8
Compare
BowenFu
left a comment
There was a problem hiding this comment.
LGTM — clean, complete revert of the per-batch cross-attention slicing regression; single concatenated-attention path restored with no dangling references.
57af1f8 to
42f89cc
Compare
42f89cc to
8f92aaa
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
scripts/visualgen_eval/visual_gen_lpips_score_eval.py (1)
73-82: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd a return annotation to
_get_cv2().Annotate the function with a precise return type, such as
types.ModuleType, instead of leaving it untyped.As per coding guidelines, annotate every function and avoid unnecessary
Any.🤖 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 `@scripts/visualgen_eval/visual_gen_lpips_score_eval.py` around lines 73 - 82, Update _get_cv2() to declare a precise return annotation using the appropriate module type, and add any necessary standard-library import for that annotation; keep its lazy import and existing ImportError behavior unchanged.Source: Coding guidelines
tests/integration/defs/examples/visual_gen/test_visual_gen_cosmos3.py (1)
147-159: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd type annotations to the modified helper.
_run_cosmos3_lpips_pipelinehas untyped parameters and no return annotation. Add precise annotations fornum_frames,video,negative_prompt,max_sequence_length, and thetorch.Tensor | Nonereturn value.As per coding guidelines,
**/*.pyrequires annotations on every function.Proposed annotation change
-def _run_cosmos3_lpips_pipeline( - num_frames, video=None, negative_prompt=None, max_sequence_length=None -): +def _run_cosmos3_lpips_pipeline( + num_frames: int, + video: bytes | None = None, + negative_prompt: str | None = None, + max_sequence_length: int | None = None, +) -> torch.Tensor | 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 `@tests/integration/defs/examples/visual_gen/test_visual_gen_cosmos3.py` around lines 147 - 159, Update _run_cosmos3_lpips_pipeline with precise annotations for num_frames, video, negative_prompt, and max_sequence_length, and annotate its return type as torch.Tensor | None, using the project’s existing conventions for byte payloads and optional values.Source: Coding guidelines
🤖 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.
Inline comments:
In
`@tests/integration/defs/examples/visual_gen/golden/visual_gen_lpips/cosmos3_nano_t2i_lpips_golden.json`:
- Around line 23-33: Update the rebake_reason for the Cosmos3 T2I golden to
accurately reflect the retained real_text_lens behavior in
transformer_cosmos3.py, including the default non-sharded path covered by
test_cosmos3_nano_t2i_lpips_against_golden. Do not remove per-sample CFG
slicing; ensure the golden provenance and stated objective match the implemented
attention contract.
---
Nitpick comments:
In `@scripts/visualgen_eval/visual_gen_lpips_score_eval.py`:
- Around line 73-82: Update _get_cv2() to declare a precise return annotation
using the appropriate module type, and add any necessary standard-library import
for that annotation; keep its lazy import and existing ImportError behavior
unchanged.
In `@tests/integration/defs/examples/visual_gen/test_visual_gen_cosmos3.py`:
- Around line 147-159: Update _run_cosmos3_lpips_pipeline with precise
annotations for num_frames, video, negative_prompt, and max_sequence_length, and
annotate its return type as torch.Tensor | None, using the project’s existing
conventions for byte payloads and optional values.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 484a19c3-55ab-4cee-8d7a-3f815b901318
⛔ Files ignored due to path filters (1)
tests/integration/defs/examples/visual_gen/golden/visual_gen_lpips/visual_gen_lpips_golden_media.zipis excluded by!**/*.zip
📒 Files selected for processing (4)
scripts/visualgen_eval/visual_gen_lpips_score_eval.pytests/integration/defs/examples/visual_gen/golden/visual_gen_lpips/cosmos3_nano_t2i_lpips_golden.jsontests/integration/defs/examples/visual_gen/test_visual_gen_cosmos3.pytests/integration/test_lists/waives.txt
💤 Files with no reviewable changes (1)
- tests/integration/test_lists/waives.txt
8f92aaa to
9eab8f3
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
…put feature The Cosmos3 audio-output feature (commit f50ca53) silently changed three pipeline behaviors that the T2I LPIPS golden was baked against: 1. Refactored Cosmos3CrossAttention to per-batch slice k_und/v_und by real_text_lens when batch_size > 1. Under CFG (batch_size=2), the shorter (negative-prompt) entry now attends over only its real text length rather than the padded max_real_len slice used by every other batch entry, producing a substantially different image. 2. Replaced the long descriptive COSMOS3_DEFAULT_NEGATIVE_PROMPT with "". 3. Bumped COSMOS3_720P_PARAMS["max_sequence_length"] from 1024 to 4096. The result was LPIPS = 0.608404 on test_cosmos3_nano_t2i_lpips_against_golden (12x the 0.05 threshold). This mirrors the T2V-sibling fix on branch repair-bot-bug6410093 (commit a8cf30c); the same underlying regression affects both variants but T2V happens to still land under the 0.05 threshold with the new pipeline defaults while T2I diverges. Fix: - Revert the per-batch cross-attention slicing: drop the real_text_lens parameter from Cosmos3CrossAttention.forward and Cosmos3GenDecoderLayer.forward, and stop computing/passing it in Cosmos3VFMTransformer.forward. All batch entries now share the same k_und[:, :max_real_len] slice as before. The per-batch path was only preparatory for future audio work and is not exercised by any existing audio test (audio tests use batch_size=1). - Pin the LPIPS-golden-specific negative_prompt and max_sequence_length in the test itself (matching the WAN21/22, LTX2, QwenImage pattern), so the LPIPS test stays decoupled from future public-default changes. - Remove the nvbugs/6418815 waiver. Verified: LPIPS score drops to 0.000142 (well below the 0.05 threshold). Signed-off-by: trtllm-agent <296075020+trtllm-agent@users.noreply.github.com> Signed-off-by: handongl <handongl@nvidia.com>
…only tests Signed-off-by: trtllm-agent <296075020+trtllm-agent@users.noreply.github.com> Signed-off-by: handongl <handongl@nvidia.com>
…real_text_lens The T2I golden was baked at 85665f5, before the Cosmos3 audio-output feature (f50ca53), so it encoded two things that later changed: 1. Two conditioning defaults: the descriptive negative prompt became "" and max_sequence_length went 1024 -> 4096. Pinning the original values in the test (as WAN21/22, LTX2 and QwenImage already do) takes LPIPS from 0.608 to 0.154. 2. The pre-feature cross-attention numerics. f50ca53 added per-sample text slicing (real_text_lens); before it, cross-attention padded every CFG sample to the batch-wide max text length and attended over the padding. Forcing the old padded path makes T2I pass, which confirms this is the remaining 0.154 -- but it also drops the V2V test (whose golden was baked after the feature) to 0.380, so the slicing is correct behavior and must not be reverted. Restore real_text_lens to its upstream form and refresh the T2I golden instead. The regenerated image is bit-exact across two independent runs. Both T2I and V2V now pass, and the waiver is removed. Signed-off-by: trtllm-agent <296075020+trtllm-agent@users.noreply.github.com>
…3 T2I LPIPS test The T2I LPIPS case is single-frame end to end: generation saves one PNG via PIL save_image, and _run_lpips_eval scores it through the eval script's image branch (PIL + lpips). It requested _visual_gen_deps anyway, which provisions video codecs with apt-get update/install ffmpeg. apt-get cannot succeed in the non-root test container, so the fixture raised CalledProcessError (exit 100) and errored the test during setup, before the LPIPS comparison could run. Drop the fixture from this case, matching the sibling image-only test test_cosmos3_feature_accuracy_against_golden, which already omits it. The video and V2V cases keep the fixture since they do decode/encode MP4. Signed-off-by: trtllm-agent <296075020+trtllm-agent@users.noreply.github.com>
9eab8f3 to
f30b287
Compare
Summary
Test plan
Links
Dev Engineer Review
real_text_lensplumbing fromtransformer_cosmos3.py.negative_promptandmax_sequence_lengthvalues.QA Engineer Review
_run_cosmos3_lpips_pipeline.test_cosmos3_nano_t2i_lpips_against_golden.tests/integration/test_lists/waives.txt.