Skip to content

Gsq/dev train#1211

Open
gushiqiao wants to merge 3 commits into
mainfrom
gsq/dev-train
Open

Gsq/dev train#1211
gushiqiao wants to merge 3 commits into
mainfrom
gsq/dev-train

Conversation

@gushiqiao

Copy link
Copy Markdown
Contributor

No description provided.

@gemini-code-assist gemini-code-assist Bot left a comment

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.

Code Review

This pull request introduces support for the Wan2.2 TI2V 5B model, adding new training and inference configurations, model definitions, and VAE components. It implements sequence parallel (SP) support across the attention layers and dataset loaders, introduces new DMD video trainers (VideoDmdTrainer and VideoArDmdTrainer), and adds a utility script to pre-compute teacher-forcing caches. A critical issue was identified in the VAE implementation where comparing a PyTorch tensor directly with a string placeholder could raise a RuntimeError due to ambiguous boolean evaluation.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +112 to +129
if cache_x.shape[2] < 2 and feat_cache[idx] is not None and feat_cache[idx] != "Rep":
# cache last frame of last two chunk
cache_x = torch.cat(
[
feat_cache[idx][:, :, -1, :, :].unsqueeze(2).to(cache_x.device),
cache_x,
],
dim=2,
)
if cache_x.shape[2] < 2 and feat_cache[idx] is not None and feat_cache[idx] == "Rep":
cache_x = torch.cat(
[torch.zeros_like(cache_x).to(cache_x.device), cache_x],
dim=2,
)
if feat_cache[idx] == "Rep":
x = self.time_conv(x)
else:
x = self.time_conv(x, feat_cache[idx])

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.

high

Comparing a PyTorch tensor directly with a string using == or != returns a tensor of booleans. When evaluated in an if condition, this will raise a RuntimeError: Boolean value of Tensor with more than one value is ambiguous. Since feat_cache[idx] can be either "Rep" (a string) or a PyTorch tensor, we should use isinstance(feat_cache[idx], str) to safely check if it is the placeholder string before performing any comparisons.

Suggested change
if cache_x.shape[2] < 2 and feat_cache[idx] is not None and feat_cache[idx] != "Rep":
# cache last frame of last two chunk
cache_x = torch.cat(
[
feat_cache[idx][:, :, -1, :, :].unsqueeze(2).to(cache_x.device),
cache_x,
],
dim=2,
)
if cache_x.shape[2] < 2 and feat_cache[idx] is not None and feat_cache[idx] == "Rep":
cache_x = torch.cat(
[torch.zeros_like(cache_x).to(cache_x.device), cache_x],
dim=2,
)
if feat_cache[idx] == "Rep":
x = self.time_conv(x)
else:
x = self.time_conv(x, feat_cache[idx])
is_rep = isinstance(feat_cache[idx], str) and feat_cache[idx] == "Rep"
if cache_x.shape[2] < 2 and feat_cache[idx] is not None and not is_rep:
# cache last frame of last two chunk
cache_x = torch.cat(
[
feat_cache[idx][:, :, -1, :, :].unsqueeze(2).to(cache_x.device),
cache_x,
],
dim=2,
)
if cache_x.shape[2] < 2 and feat_cache[idx] is not None and is_rep:
cache_x = torch.cat(
[torch.zeros_like(cache_x).to(cache_x.device), cache_x],
dim=2,
)
if is_rep:
x = self.time_conv(x)
else:
x = self.time_conv(x, feat_cache[idx])

# Conflicts:
#	lightx2v_train/configs/infer/wan2_1_t2v_1_3b_tf_chunkwise_ar.yaml
#	lightx2v_train/configs/train/dmd/wan2_1_t2v_1_3b_ar_dmd.yaml
#	lightx2v_train/configs/train/dmd/wan2_1_t2v_1_3b_dmd.yaml
#	lightx2v_train/lightx2v_train/infer/video.py
#	lightx2v_train/lightx2v_train/model_zoo/__init__.py
#	lightx2v_train/lightx2v_train/model_zoo/wan_t2v.py
#	lightx2v_train/lightx2v_train/trainers/__init__.py
#	lightx2v_train/lightx2v_train/trainers/dmd.py
#	lightx2v_train/scripts/run_wan_t2v.sh
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.

1 participant