modelscope / modelscope/DiffSynth-Studio

wan_video_dit issue with flash_attn 3

Open
#523 3 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
13.1k
Forks
1.3k
Avg merge
13h 12m
Merged PRs (30d)
45

Description

Traceback (most recent call last):
File "/data/yuxiong/DiffSynth-Studio/examples/wanvideo/wan_fun_InP.py", line 65, in
video = pipe(
^^^^^
File "/data/yuxiong/miniconda3/envs/torch26/lib/python3.11/site-packages/torch/utils/_contextlib.py", line 116, in decorate_context
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/data/yuxiong/DiffSynth-Studio/diffsynth/pipelines/wan_video.py", line 349, in call
noise_pred_posi = model_fn_wan_video(
^^^^^^^^^^^^^^^^^^^
File "/data/yuxiong/DiffSynth-Studio/diffsynth/pipelines/wan_video.py", line 484, in model_fn_wan_video
x = block(x, context, t_mod, freqs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/data/yuxiong/miniconda3/envs/torch26/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1739, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/data/yuxiong/miniconda3/envs/torch26/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1750, in _call_impl
return forward_call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/data/yuxiong/DiffSynth-Studio/diffsynth/models/wan_video_dit.py", line 216, in forward
x = self.gate(x, gate_msa, self.self_attn(input_x, freqs))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/data/yuxiong/miniconda3/envs/torch26/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1739, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/data/yuxiong/miniconda3/envs/torch26/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1750, in _call_impl
return forward_call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/data/yuxiong/DiffSynth-Studio/diffsynth/models/wan_video_dit.py", line 143, in forward
x = self.attn(q, k, v)
^^^^^^^^^^^^^^^^^^
File "/data/yuxiong/miniconda3/envs/torch26/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1739, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/data/yuxiong/miniconda3/envs/torch26/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1750, in _call_impl
return forward_call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/data/yuxiong/DiffSynth-Studio/diffsynth/models/wan_video_dit.py", line 117, in forward
x = flash_attention(q=q, k=k, v=v, num_heads=self.num_heads)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/data/yuxiong/DiffSynth-Studio/diffsynth/models/wan_video_dit.py", line 39, in flash_attention
x = rearrange(x, "b s n d -> b s (n d)", n=num_heads)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/data/yuxiong/miniconda3/envs/torch26/lib/python3.11/site-packages/einops/einops.py", line 600, in rearrange
return reduce(tensor, pattern, reduction="rearrange", **axes_lengths)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/data/yuxiong/miniconda3/envs/torch26/lib/python3.11/site-packages/einops/einops.py", line 527, in reduce
backend = get_backend(tensor)
^^^^^^^^^^^^^^^^^^^
File "/data/yuxiong/miniconda3/envs/torch26/lib/python3.11/site-packages/einops/_backends.py", line 59, in get_backend
raise RuntimeError("Tensor type unknown to einops {}".format(type(tensor)))
RuntimeError: Tensor type unknown to einops <class 'tuple'>

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with examples/wanvideo/wan_fun_InP.py and inspect the flash_attention path in diffsynth/models/wan_video_dit.py, especially the call involving flash_attn 3 and the rearrange at line 39. Reproduce the traceback with the Wan video example and determine the expected return type. Done means the example proceeds past this attention call without the einops tuple error.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
machine-learning
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.