Skip to content

feat: Support FastVideo for Video Generation Models#1303

Merged
kcz358 merged 12 commits into
mainfrom
pufanyi/wan2.2
Apr 27, 2026
Merged

feat: Support FastVideo for Video Generation Models#1303
kcz358 merged 12 commits into
mainfrom
pufanyi/wan2.2

Conversation

@pufanyi
Copy link
Copy Markdown
Collaborator

@pufanyi pufanyi commented Apr 22, 2026

Added FastVideo and VBVR

image
#!/usr/bin/env fish
# Run from the lmms-eval repo root.
cd /mnt/umm/users/pufanyi/workspace/lmms-eval; or exit 1

# Rule-based VBVR scorers read the GT mp4s/pngs from this root.
set -gx VBVR_GT_PATH /mnt/umm/users/pufanyi/workspace/Wan-Trainer/storage/datasets/VBVR-Bench

set MODEL_DIR   /mnt/umm/users/pufanyi/workspace/Wan-Trainer/storage/models/Wan2.2-I2V-A14B-Diffusers
set OUT_ROOT    /mnt/umm/users/pufanyi/workspace/Wan-Trainer/storage/eval_out/vbvr_wan22_full_highres
set VIDEOS_DIR  $OUT_ROOT/videos
set METRICS_DIR $OUT_ROOT/metrics
mkdir -p $VIDEOS_DIR $METRICS_DIR

set MODEL_ARGS "model=$MODEL_DIR"
set MODEL_ARGS "$MODEL_ARGS,output_dir=$VIDEOS_DIR"
set MODEL_ARGS "$MODEL_ARGS,data_parallel=4,num_gpus=2,sp_size=2,tp_size=1"
set MODEL_ARGS "$MODEL_ARGS,num_inference_steps=50,num_frames=81"
set MODEL_ARGS "$MODEL_ARGS,height=1024,width=1024,fps=16"
set MODEL_ARGS "$MODEL_ARGS,dit_cpu_offload=False,text_encoder_cpu_offload=True"
set MODEL_ARGS "$MODEL_ARGS,image_encoder_cpu_offload=False,vae_cpu_offload=False"
set MODEL_ARGS "$MODEL_ARGS,enable_torch_compile=True"

exec stdbuf -oL -eL .venv/bin/python -m lmms_eval eval \
    --model fastvideo \
    --model_args $MODEL_ARGS \
    --tasks vbvr \
    --batch_size 1 \
    --log_samples \
    --output_path $METRICS_DIR

There is a minor issue: the current final process results in VBVR are single-threaded. If we want to change this to multi-threaded, it seems we would need to modify the main trunk of the code. The final process results step takes approximately 10 minutes to run. However, if you use 32 threads, it can be completed within a minute.

evaluator = get_evaluator(task_name)
vr = evaluator.evaluate(eval_info, task_specific_only=True)

@pufanyi pufanyi requested a review from kcz358 April 22, 2026 17:38
@pufanyi pufanyi changed the title [feat] Support FastVideo for Video Generation Models feat: Support FastVideo for Video Generation Models Apr 22, 2026
Comment thread lmms_eval/tasks/vbvr/README.md Outdated
Comment on lines +63 to +67
set MODEL_DIR /path/to/Wan2.2-I2V-A14B-Diffusers
set OUT_ROOT /path/to/eval_out/vbvr_wan22_full_highres
set VIDEOS_DIR $OUT_ROOT/videos
set METRICS_DIR $OUT_ROOT/metrics
mkdir -p $VIDEOS_DIR $METRICS_DIR
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This part should utilize the cache directory and the submission directory. Using environment variables seems rather inflexible. After examining the repo structure on HuggingFace, one possibility is to set up a cache directory similar to the other video paths. Then, before each download, we can use snapshot_download from HuggingFace, which would return the path to the video directory. As for the metrics directory, I think it could be handled via generate_submission?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Oh just find forgot to write the downloading code, updated by adding

snapshot_root = snapshot_download(repo_id=_dataset_repo_id(), repo_type="dataset")

Copy link
Copy Markdown
Collaborator Author

@pufanyi pufanyi Apr 23, 2026

Choose a reason for hiding this comment

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

Lemme check the model output. I got lazy before and just pointed it to my training folder randomly. Let me fix that now.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Seems that 笨蛋 claude makes the default output dir to huggingface dir

def _default_output_dir() -> str:
hf_home = os.path.expanduser(os.getenv("HF_HOME", "~/.cache/huggingface"))
return os.path.join(hf_home, "lmms_eval", "generated_videos", "fastvideo")

This definitely needs to be changed.

But I’m not entirely sure how to handle generate_submission. I noticed that Bagel outputs to ./logs/bagel_images/<run_id>/ by default, so maybe we should do the same?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed by adding

def _model_slug(model_path: str) -> str:
base = os.path.basename(str(model_path).rstrip("/"))
return _SAFE_RE.sub("_", base).strip("_") or "model"
def _default_output_dir(model_path: str) -> str:
return os.path.join("./logs/fastvideo", _model_slug(model_path), _generate_run_id())

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Yeah, I think currently could use log dir as the output dir, unless otherwise specify in the init args.

Comment thread lmms_eval/models/chat/fastvideo.py Outdated
Comment on lines +525 to +536
# Resume: if the target mp4 already exists and is non-empty, reuse it.
# Set overwrite=True in model_args to force regeneration.
presults: List[Optional[GenerationResult]] = [None] * len(prepared)
skipped_indices: List[int] = []
if not self.overwrite:
for i, prep in enumerate(prepared):
path = prep.get("output_path")
if path and os.path.isfile(path) and os.path.getsize(path) > 0:
presults[i] = self._pack_result(os.path.abspath(path))
skipped_indices.append(i)
if skipped_indices:
eval_logger.info(f"FastVideo: resume — reusing {len(skipped_indices)}/{len(prepared)} " f"existing mp4s (set overwrite=True to regenerate)")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Maybe can the caching features for lmms-eval instead of hardcoding here? I am fine for this, just wondering if this is possible.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

What I’m actually more concerned about is that right now the videos and the video paths are separated. Videos don’t seem as easy to cache as plain text. But I guess it’s still doable — worst case, it just throws a “video not found” error.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think if we store the video as path in the output, the caching logic would just like plain text? We have a similar structure just like text so can just load from db. Or if this is not the case can just reload from the previously define output dir and keep this code block

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

ok, then I will do this. I was actually concerned about the scenario where the path still exists but the video has been deleted. My understanding is that our script doesn't check for this.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Yeah, I think our script doesn't check for this. If the storage is not persistent then maybe should disable the cache mode or clean the cached data.

@pufanyi
Copy link
Copy Markdown
Collaborator Author

pufanyi commented Apr 23, 2026

I made the changes. I'll run it tonight to check the if the results are the same.

@kcz358
Copy link
Copy Markdown
Collaborator

kcz358 commented Apr 24, 2026

Ok thanks, I think once you feel this PR is mostly done, I will approve and merge the PR. Thanks!

@pufanyi
Copy link
Copy Markdown
Collaborator Author

pufanyi commented Apr 26, 2026

image

Seems that the result is ok.

@kcz358 kcz358 merged commit d6cc2b5 into main Apr 27, 2026
5 checks passed
@kcz358 kcz358 deleted the pufanyi/wan2.2 branch April 27, 2026 13:48
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.

2 participants