Skip to content

feat: add Wan2.2 S2V (speech-to-video) support - #1925

Open
noctrex wants to merge 1 commit into
leejet:masterfrom
noctrex:wan22-s2v-support
Open

feat: add Wan2.2 S2V (speech-to-video) support#1925
noctrex wants to merge 1 commit into
leejet:masterfrom
noctrex:wan22-s2v-support

Conversation

@noctrex

@noctrex noctrex commented Aug 30, 2026

Copy link
Copy Markdown

Summary

Audio-driven video generation for Wan2.2-S2V-14B: a reference portrait plus a driving WAV produce a lip-synced video whose output container carries the driving audio.

  • detect S2V checkpoints by audio-module key presence; uses the wan2.1 VAE
  • wav2vec2 audio encoder model class, backend module, --audio-encoder flag
  • S2V modules in the Wan DiT: causal audio encoder, motion encoder, audio injector (AdaLN + cross-attention), reference-latent tokens
  • audio windowing/bucketing to the latent frame count; uncond uses silence
  • new --audio flag; mux the driving track into avi/webm (wav sidecar)
  • skip ComfyUI fp8_scaled .scale_input keys at parse time
  • docs: downloads, S2V example, sampler and 24 GB VRAM guidance

Additional Information

Verification

wav2vec2 audio encoder parity (vs ComfyUI torch reference):

  • Final hidden state max abs error 0.0082 against the fp32 torch reference, inside the torch-fp16-vs-fp32 envelope (torch's own fp16 execution error: 0.0221).
    Per-layer error ratio 0.35-0.94 across layers, max 1.02 at layers 22/23.
    Includes the grouped positional conv (weight-norm, drop-last) and stable-LN conv frontend.
    A deliberately broken negative control fails the gate (0.547 vs 0.02 tolerance), so the harness is not vacuous.

End-to-end (RX 7900 XTX 24 GB, ROCm, GGML_HIP_GRAPHS=OFF, 640x368, 13 frames):

checkpoint VRAM s/it
wan2.2_s2v_14B_int8_convrot.safetensors 17.6 GB 5.05
wan2.2_s2v-14B-Q8_0.gguf 18.4 GB 6.19
wan2.2_s2v-14B-Q4_K_M.gguf 13.4 GB 10.99
  • Full 77-frame run (int8_convrot + lightx2v low-noise lightning LoRA, 4 steps, cfg 1.0): ~164 s wall including ~50 s VAE decode.
  • Baseline quality run (int8_convrot, 20 steps, cfg 6.0, no LoRA, 33 frames): 14.3 s/it.
  • Output audio muxing validated end-to-end on ROCm and Vulkan (driving track copied and truncated to video duration, e.g. 236147 -> 13000 samples for a 13-frame clip, muxed into .avi).

Note: int8_convrot only works on CUDA out of the box with the current ggml revision.
ROCm and Vulkan support comes from my ggml PRs (leejet/ggml#6-#9, currently open).
The ROCm/Vulkan numbers above were measured with that stack applied. GGUF checkpoints (Q8_0 / Q4_K_M) are unaffected by any of this.

Regression (existing Wan models unchanged):

  • Wan2.1 T2V 14B (Q8_0 GGUF, ROCm)
  • Wan2.1 I2V 14B 480p (Q8_0 GGUF + clip_vision, Vulkan)
  • Wan2.2 TI2V 5B T2V + I2V (fp16, 48-ch VAE, ROCm)
  • Wan2.2 T2V A14B + I2V A14B (int8_convrot MoE, ROCm)

All report the correct Version: lines and never detect as S2V.

Known limitations

  • One generation covers the first S2V chunk window (--video-frames, 77-81 frames at 16 fps); long-video chunked extend mode is not implemented yet.
  • bf16 and fp8_scaled checkpoints do not fit 24 GB GPUs. int8_convrot, Q8_0, Q4_K_M tested ok.
  • On ROCm, tiled VAE decode of longer clips currently needs GGML_HIP_GRAPHS=OFF (HIP graph capture issue for that graph shape, not specific to this PR's code paths).

Sample outputs

77 frames, 512x512, 56.86s/it, ROCm, generate_video completed in 1176.76s

s2v_test_q22_h264.mp4

Checklist

LLM Disclosure: Yes, used GLM-5.3-Flash

Audio-driven video generation for Wan2.2-S2V-14B: a reference portrait
plus a driving WAV produce a lip-synced video whose output container
carries the driving audio.

- detect S2V checkpoints by audio-module key presence; uses the wan2.1 VAE
- wav2vec2 audio encoder model class, backend module, --audio-encoder flag
- S2V modules in the Wan DiT: causal audio encoder, motion encoder,
  audio injector (AdaLN + cross-attention), reference-latent tokens
- audio windowing/bucketing to the latent frame count; uncond uses silence
- new --audio flag; mux the driving track into avi/webm (wav sidecar)
- skip ComfyUI fp8_scaled .scale_input keys at parse time
- docs: downloads, S2V example, sampler and 24 GB VRAM guidance
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