Skip to content

[https://nvbugs/6418815][fix] Revert the per-batch cross-attention slicing (drop real_text_lens plumbing in… - #15986

Open
trtllm-agent wants to merge 2 commits into
NVIDIA:mainfrom
tensorrt-cicd:repair-bot-bug6418815
Open

[https://nvbugs/6418815][fix] Revert the per-batch cross-attention slicing (drop real_text_lens plumbing in…#15986
trtllm-agent wants to merge 2 commits into
NVIDIA:mainfrom
tensorrt-cicd:repair-bot-bug6418815

Conversation

@trtllm-agent

@trtllm-agent trtllm-agent commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Root cause: Commit f50ca53 (Cosmos3 Audio Output Support) silently changed three inputs the T2I LPIPS golden was baked against: (1) added CFG per-batch cross-attention slicing keyed on real_text_lens, (2) replaced the rich COSMOS3_DEFAULT_NEGATIVE_PROMPT with "", (3) bumped default max_sequence_length 1024→4096.
  • Fix: Revert the per-batch cross-attention slicing (drop real_text_lens plumbing in transformer_cosmos3.py) and pin negative_prompt + max_sequence_length in the test to their pre-f50ca53dae values (matching the WAN/LTX2/QwenImage LPIPS-test pattern); remove the T2I waiver.
  • Automated fix generated by repair-bot

Test plan

  • Verify fix on the same GPU type as the original failure
  • Check for regressions in related tests

Links

Summary by CodeRabbit

  • Bug Fixes

    • Improved Cosmos3 generation behavior by using a consistent attention path, which should make outputs more stable.
    • Updated the Cosmos3 LPIPS test setup to use fixed prompt settings and sequence length for more reliable golden comparisons.
  • Tests

    • Re-enabled a previously waived Cosmos3 Nano LPIPS integration test.

@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: a36becbf-77ee-4c0b-a974-fcc68c3a8505

📥 Commits

Reviewing files that changed from the base of the PR and between 011e849 and e904942.

📒 Files selected for processing (3)
  • tensorrt_llm/_torch/visual_gen/models/cosmos3/transformer_cosmos3.py
  • tests/integration/defs/examples/visual_gen/test_visual_gen.py
  • tests/integration/test_lists/waives.txt
💤 Files with no reviewable changes (1)
  • tests/integration/test_lists/waives.txt

📝 Walkthrough

Walkthrough

Cosmos3CrossAttention and Cosmos3GenDecoderLayer no longer accept real_text_lens, replacing per-batch conditional slicing of UND keys/values with a full-attention concatenation path. Cosmos3VFMTransformer.forward updated accordingly. Integration test adds pinned negative prompt/max sequence length constants for Cosmos3 LPIPS, and removes a corresponding test waiver.

Changes

Cosmos3 Cross-Attention Simplification and Test Updates

Layer / File(s) Summary
Remove real_text_lens from cross-attention and gen decoder layer
tensorrt_llm/_torch/visual_gen/models/cosmos3/transformer_cosmos3.py
Cosmos3CrossAttention.forward and Cosmos3GenDecoderLayer.forward drop the real_text_lens parameter; attention always concatenates full UND K/V with generation K/V using a FULL attention mask instead of per-example slicing.
Propagate removal into transformer forward
tensorrt_llm/_torch/visual_gen/models/cosmos3/transformer_cosmos3.py
Cosmos3VFMTransformer.forward stops computing real_text_lens from text_mask and no longer passes it to gen-layer calls.
Cosmos3 LPIPS test config and waiver update
tests/integration/defs/examples/visual_gen/test_visual_gen.py, tests/integration/test_lists/waives.txt
Adds COSMOS3_LPIPS_NEGATIVE_PROMPT and COSMOS3_LPIPS_MAX_SEQUENCE_LENGTH constants, passes them into the Cosmos3 LPIPS pipeline call, and removes the corresponding test waiver entry.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

  • NVIDIA/TensorRT-LLM#15959: Both PRs remove SKIP/waiver entries for examples/visual_gen tests in tests/integration/test_lists/waives.txt.
  • NVIDIA/TensorRT-LLM#15968: Both PRs modify the waiver for test_cosmos3_nano_t2i_lpips_against_golden in the same waives file.

Suggested reviewers: yibinl-nvidia

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title follows the required ticket/type format and summarizes the main Cosmos3 cross-attention and test-pin fix.
Description check ✅ Passed The description includes Summary, Test plan, and Links sections and clearly explains the bug, fix, validation, and bug reference.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@yufeiwu-nv
yufeiwu-nv removed the request for review from ruodil July 16, 2026 06:53

@BowenFu BowenFu left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM — clean, complete revert of the per-batch cross-attention slicing regression; single concatenated-attention path restored with no dangling references.

…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>
@trtllm-agent
trtllm-agent force-pushed the repair-bot-bug6418815 branch from 57af1f8 to 42f89cc Compare July 24, 2026 07:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants