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
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"width": 1280,
"num_inference_steps": 35,
"guidance_scale": 6.0,
"max_sequence_length": 4096,
"max_sequence_length": 1024,
"num_frames": 189,
"frame_rate": 24.0,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,14 @@
from .sound_tokenizer import LatentAutoEncoderV2
from .transformer_cosmos3 import Cosmos3VFMTransformer

COSMOS3_DEFAULT_NEGATIVE_PROMPT = ""
COSMOS3_DEFAULT_NEGATIVE_PROMPT = (
"The video captures a series of frames showing ugly scenes, static with no motion, motion blur, "
"over-saturation, shaky footage, low resolution, grainy texture, pixelated images, poorly lit areas, "
"underexposed and overexposed scenes, poor color balance, washed out colors, choppy sequences, jerky movements, "
"low frame rate, artifacting, color banding, unnatural transitions, outdated special effects, fake elements, "
"unconvincing visuals, poorly edited content, jump cuts, visual noise, and flickering. Overall, the video is of "
"poor quality."
)
Comment on lines +42 to +49

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.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Stale comment after negative-prompt default change.

With COSMOS3_DEFAULT_NEGATIVE_PROMPT no longer empty, the unchanged comment at Line 686 ("None negative_prompt means the empty default will be used (safe); skip it.") no longer reflects reality. The guardrail-skip is still fine because the substituted default (Line 708-709) is developer-controlled, but the "empty default" rationale is now inaccurate and could mislead future readers. Consider updating that comment.

🤖 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 `@tensorrt_llm/_torch/visual_gen/models/cosmos3/pipeline_cosmos3.py` around
lines 42 - 49, Update the stale comment in pipeline_cosmos3.py near the
negative-prompt handling in the Cosmos3 pipeline so it no longer says the
default is empty. The logic around the negative_prompt check in the relevant
method (where None is skipped and COSMOS3_DEFAULT_NEGATIVE_PROMPT is
substituted) can stay the same, but the comment should accurately describe that
a developer-controlled default prompt is used instead of an empty one.

COSMOS3_DEFAULT_SYSTEM_PROMPT = (
"You are a helpful assistant who will generate videos from a given prompt."
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,6 @@ def forward(
freqs_cos: torch.Tensor,
freqs_sin: torch.Tensor,
timestep=None,
real_text_lens: Optional[list[int]] = None,
) -> torch.Tensor:
"""
Args:
Expand All @@ -375,33 +374,16 @@ def forward(
q, k = self.apply_qk_norm(q, k)
q, k = qwen3_apply_rotary_pos_emb(q, k, freqs_cos, freqs_sin)

if real_text_lens is not None and batch_size > 1:
outs = []
for b in range(batch_size):
Lb = int(real_text_lens[b])
k_all_b = torch.cat([k_und[b : b + 1, :Lb], k[b : b + 1]], dim=1)
v_all_b = torch.cat([v_und[b : b + 1, :Lb], v[b : b + 1]], dim=1)
outs.append(
self._attn_impl(
q[b : b + 1],
k_all_b,
v_all_b,
attention_mask=PredefinedAttentionMask.FULL,
timestep=timestep,
)
)
out = torch.cat(outs, dim=0)
else:
k_all = torch.cat([k_und, k], dim=1).contiguous()
v_all = torch.cat([v_und, v], dim=1).contiguous()

out = self._attn_impl(
q,
k_all,
v_all,
attention_mask=PredefinedAttentionMask.FULL,
timestep=timestep,
)
k_all = torch.cat([k_und, k], dim=1).contiguous()
v_all = torch.cat([v_und, v], dim=1).contiguous()

out = self._attn_impl(
q,
k_all,
v_all,
attention_mask=PredefinedAttentionMask.FULL,
timestep=timestep,
)

return self.to_out[0](out)

Expand Down Expand Up @@ -521,7 +503,6 @@ def forward(
v_und: torch.Tensor,
freqs: Tuple[torch.Tensor, torch.Tensor],
timestep=None,
real_text_lens: Optional[list[int]] = None,
) -> torch.Tensor:
residual = hidden_states
hidden_states = self.input_layernorm(hidden_states)
Expand All @@ -534,7 +515,6 @@ def forward(
freqs_cos=cos,
freqs_sin=sin,
timestep=timestep,
real_text_lens=real_text_lens,
)
hidden_states = residual + hidden_states

Expand Down Expand Up @@ -1016,7 +996,6 @@ def forward(
T, H, W = video_shape
Hp, Wp, _, _ = self._pad_to_patch_size(H, W)
max_real_len = text_mask.sum(dim=1).max().item()
real_text_lens = text_mask.sum(dim=1).tolist()

hidden_gen = self.vae2llm(self.patchify(hidden_states, T, H, W))

Expand Down Expand Up @@ -1113,22 +1092,13 @@ def forward(
if not self.sharder.is_active:
k_und = k_und[:, :max_real_len]
v_und = v_und[:, :max_real_len]
hidden_gen = layer(
hidden_gen,
k_und,
v_und,
freqs_gen,
timestep=timestep,
real_text_lens=real_text_lens,
)
else:
hidden_gen = layer(
hidden_gen,
k_und,
v_und,
freqs_gen,
timestep=timestep,
)
hidden_gen = layer(
hidden_gen,
k_und,
v_und,
freqs_gen,
timestep=timestep,
)

hidden_gen = self.sharder.gather(hidden_gen, dim=1, unpad_to=S_gen)

Expand Down
1 change: 0 additions & 1 deletion tests/integration/test_lists/waives.txt
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ examples/test_ray.py::test_llm_inference_distributed_ray[pp2] SKIP (https://nvbu
examples/test_ray.py::test_llm_inference_distributed_ray[tp2pp2] SKIP (https://nvbugs/6427411)
examples/test_ray.py::test_ray_disaggregated_serving[tp2] SKIP (https://nvbugs/5612502)
examples/test_whisper.py::test_llm_whisper_general[large-v3-disable_gemm_plugin-disable_attention_plugin-disable_weight_only-float16-nb:1-use_python_runtime] SKIP (https://nvbugs/5244570)
examples/visual_gen/test_visual_gen.py::test_cosmos3_nano_t2i_lpips_against_golden SKIP (https://nvbugs/6418815)
examples/visual_gen/test_visual_gen_multi_gpu.py::test_wan22_t2v_lpips_against_golden_multi_gpu[attn2d_2x2] SKIP (https://nvbugs/6272644)
examples/visual_gen/test_visual_gen_multi_gpu.py::test_wan22_t2v_lpips_against_golden_multi_gpu[cfg2_ulysses2] SKIP (https://nvbugs/6272644)
examples/visual_gen/test_visual_gen_multi_gpu.py::test_wan22_t2v_lpips_against_golden_multi_gpu[cfg2_ulysses2_attn2d_2x1] SKIP (https://nvbugs/6272644)
Expand Down
Loading