# skyworkai/skyreels-v3 architecture

> Architecture diagram of the GitHub repository skyworkai/skyreels-v3, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-24). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/skyworkai/skyreels-v3
- Repository: https://github.com/skyworkai/skyreels-v3

## Overview

#### Purpose and execution surface
SkyReels V3 is Python/CUDA inference code for multimodal diffusion-based video generation: reference-images-to-video, video extension, and portrait-plus-audio talking avatars. The primary CLI is `generate_video.py`; avatar convenience launchers are `scripts/run_talking_avatar.sh` and `scripts/run_talking_avatar_low_vram.sh`. Inputs may be local files or URLs; pretrained weights are obtained from Hugging Face by default or supplied through `--model_id`.

#### Task routing and pipeline boundary
`generate_video.py` selects a task-specific orchestration pipeline based on `--task_type`, keeping modality preparation and generation policies separate:
- Reference images and prompt: `skyreels_v3/pipelines/reference_to_video_pipeline.py`
- Video continuation and longer single-shot generation: `skyreels_v3/pipelines/single_shot_extension_pipeline.py`
- Cinematic shot-switching extension: `skyreels_v3/pipelines/shot_switching_extension_pipeline.py`
- Portrait/audio-driven generation: `skyreels_v3/pipelines/talking_avatar_pipeline.py`

Each pipeline is the principal boundary between user media/prompt inputs and model tensors, sampling, decoding, and output-video assembly.

#### Model and multimodal encoding stack
The model layer contains the video diffusion Transformer and modality encoders. Core Transformer variants are `skyreels_v3/modules/transformer.py`, `skyreels_v3/modules/transformer_a2v.py`, and `skyreels_v3/modules/reference_to_video/transformer.py`. Text conditioning is provided by T5/CLIP/XLM-R components in `skyreels_v3/modules/t5.py`, `skyreels_v3/modules/clip.py`, and `skyreels_v3/modules/xlm_roberta.py`. Avatar audio features use `skyreels_v3/modules/wav2vec2.py`; video/image latent encoding and reconstruction uses `skyreels_v3/modules/vae.py`.

#### Generation flow
For reference-to-video, up to four images plus text become multimodal conditioning for latent-video denoising. Extension pipelines ingest an existing video plus prompt, encode its temporal context, and generate continuation frames; their policy differs for continuous versus shot-transition output. Talking-avatar inference preprocesses a first-frame portrait and driving audio, extracts audio conditioning, then generates an audio-aligned video sequence. Shared attention behavior resides in `skyreels_v3/modules/attention.py`; iterative diffusion/flow sampling is scheduled by `skyreels_v3/scheduler/fm_solvers_unipc.py`.

#### Avatar-specific preparation
Avatar generation has an explicit media-conditioning stage before the generic model path: `skyreels_v3/utils/avatar_preprocess.py` and `skyreels_v3/utils/avatar_util.py`. This isolates portrait normalization, audio/video timing, and avatar-oriented conditioning from the main `talking_avatar_pipeline.py` orchestration.

#### Distributed and memory execution
The intended runtime is Python 3.12+ with CUDA 12.8+ and PyTorch GPU inference. Single-GPU execution can offload model blocks; low-VRAM mode uses FP8 weight-only quantization and block offload. Multi-GPU execution uses `torchrun` and xDiT USP-style context parallelism, separated by workload in `skyreels_v3/distributed/context_parallel_for_reference.py`, `skyreels_v3/distributed/context_parallel_for_extension.py`, and `skyreels_v3/distributed/context_parallel_for_avatar.py`.

#### Configuration and external dependencies
Shared runtime/model settings are centralized in `skyreels_v3/config.py` and `skyreels_v3/configs/shared_config.py`, with avatar model specialization in `skyreels_v3/configs/talking_avatar_19B.py`. External model distribution is Hugging Face or ModelScope; the repository also points to hosted playground/API offerings, but contains no service server implementation.

Main entry points: [`skyreels_v3/modules/transformer.py`](https://github.com/skyworkai/skyreels-v3/blob/main/skyreels_v3/modules/transformer.py) (Video diffusion Transformers), [`generate_video.py`](https://github.com/skyworkai/skyreels-v3/blob/main/generate_video.py) (Generation CLI), [`skyreels_v3/pipelines/talking_avatar_pipeline.py`](https://github.com/skyworkai/skyreels-v3/blob/main/skyreels_v3/pipelines/talking_avatar_pipeline.py) (Talking avatar), [`skyreels_v3/pipelines/reference_to_video_pipeline.py`](https://github.com/skyworkai/skyreels-v3/blob/main/skyreels_v3/pipelines/reference_to_video_pipeline.py) (Reference-to-video)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry &amp; inputs"]
  node_user_media["Media, prompts &amp; URLs<br/>input"]
  node_cli["Generation CLI<br/>python-cli<br/>[generate_video.py]"]
  node_weights[("Pretrained weights<br/>external-models")]
end

subgraph group_pipelines["Task pipelines"]
  node_reference_pipeline["Reference-to-video<br/>pipeline"]
  node_single_shot_pipeline["Single-shot extension<br/>pipeline"]
  node_shot_switch_pipeline["Shot-switch extension<br/>pipeline"]
  node_avatar_pipeline["Talking avatar<br/>pipeline"]
  node_avatar_preprocess["Avatar media preparation<br/>preprocessing"]
end

subgraph group_model["Model &amp; sampling"]
  node_transformers{{"Video diffusion Transformers<br/>cuda-model<br/>[transformer.py]"}}
  node_conditioning["Text &amp; audio encoders<br/>multimodal-encoders<br/>[t5.py]"]
  node_vae["Video VAE<br/>latent-codec<br/>[vae.py]"]
  node_attention["Shared attention<br/>model-component<br/>[attention.py]"]
  node_scheduler["Flow sampling scheduler<br/>sampler"]
end

subgraph group_runtime["Runtime scaling"]
  node_settings["Shared settings<br/>configuration<br/>[config.py]"]
  node_avatar_config["Avatar 19B settings<br/>configuration"]
  node_distributed{{"Context parallelism<br/>distributed-runtime"}}
  node_gpu_runtime{{"CUDA inference runtime<br/>execution-runtime"}}
end

node_video_output["Generated video<br/>output"]

node_user_media -->|"arguments and media"| node_cli
node_weights -.->|"model source"| node_cli
node_cli -->|"reference task"| node_reference_pipeline
node_cli -->|"continuation task"| node_single_shot_pipeline
node_cli -->|"shot-switch task"| node_shot_switch_pipeline
node_cli -->|"avatar task"| node_avatar_pipeline
node_user_media -->|"portrait and audio"| node_avatar_preprocess
node_avatar_preprocess -->|"aligned conditioning"| node_avatar_pipeline
node_reference_pipeline -->|"text/image conditioning"| node_conditioning
node_single_shot_pipeline -->|"encode source context"| node_vae
node_shot_switch_pipeline -->|"encode source context"| node_vae
node_avatar_pipeline -->|"audio and text features"| node_conditioning
node_reference_pipeline -->|"latent denoising"| node_transformers
node_single_shot_pipeline -->|"continuation denoising"| node_transformers
node_shot_switch_pipeline -->|"transition denoising"| node_transformers
node_avatar_pipeline -->|"audio-aligned denoising"| node_transformers
node_conditioning -->|"conditioning features"| node_transformers
node_scheduler -->|"sampling steps"| node_transformers
node_attention -->|"attention behavior"| node_transformers
node_transformers -->|"generated latents"| node_vae
node_vae -->|"decoded frames"| node_video_output
node_settings -.->|"runtime settings"| node_cli
node_avatar_config -.->|"avatar specialization"| node_avatar_pipeline
node_distributed -.->|"multi-GPU reference workload"| node_reference_pipeline
node_distributed -->|"torchrun execution"| node_gpu_runtime
node_gpu_runtime -.->|"CUDA, offload, FP8"| node_transformers

click node_cli "https://github.com/skyworkai/skyreels-v3/blob/main/generate_video.py"
click node_reference_pipeline "https://github.com/skyworkai/skyreels-v3/blob/main/skyreels_v3/pipelines/reference_to_video_pipeline.py"
click node_single_shot_pipeline "https://github.com/skyworkai/skyreels-v3/blob/main/skyreels_v3/pipelines/single_shot_extension_pipeline.py"
click node_shot_switch_pipeline "https://github.com/skyworkai/skyreels-v3/blob/main/skyreels_v3/pipelines/shot_switching_extension_pipeline.py"
click node_avatar_pipeline "https://github.com/skyworkai/skyreels-v3/blob/main/skyreels_v3/pipelines/talking_avatar_pipeline.py"
click node_avatar_preprocess "https://github.com/skyworkai/skyreels-v3/blob/main/skyreels_v3/utils/avatar_preprocess.py"
click node_transformers "https://github.com/skyworkai/skyreels-v3/blob/main/skyreels_v3/modules/transformer.py"
click node_conditioning "https://github.com/skyworkai/skyreels-v3/blob/main/skyreels_v3/modules/t5.py"
click node_vae "https://github.com/skyworkai/skyreels-v3/blob/main/skyreels_v3/modules/vae.py"
click node_attention "https://github.com/skyworkai/skyreels-v3/blob/main/skyreels_v3/modules/attention.py"
click node_scheduler "https://github.com/skyworkai/skyreels-v3/blob/main/skyreels_v3/scheduler/fm_solvers_unipc.py"
click node_settings "https://github.com/skyworkai/skyreels-v3/blob/main/skyreels_v3/config.py"
click node_avatar_config "https://github.com/skyworkai/skyreels-v3/blob/main/skyreels_v3/configs/talking_avatar_19B.py"
click node_distributed "https://github.com/skyworkai/skyreels-v3/blob/main/skyreels_v3/distributed/context_parallel_for_reference.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_user_media,node_cli,node_weights toneBlue
class node_reference_pipeline,node_single_shot_pipeline,node_shot_switch_pipeline,node_avatar_pipeline,node_avatar_preprocess toneAmber
class node_transformers,node_conditioning,node_vae,node_attention,node_scheduler toneMint
class node_settings,node_avatar_config,node_distributed,node_gpu_runtime toneRose
class node_video_output toneNeutral
```

## Components

### Entry & inputs

- **Media, prompts & URLs**: input · Images, source video, portrait, audio, and text prompts.
- [Generation CLI](https://github.com/skyworkai/skyreels-v3/blob/main/generate_video.py): python-cli · Selects task orchestration from --task_type. · `generate_video.py`
- **Pretrained weights**: external-models · Downloaded from Hugging Face or supplied with --model_id.

### Task pipelines

- [Reference-to-video](https://github.com/skyworkai/skyreels-v3/blob/main/skyreels_v3/pipelines/reference_to_video_pipeline.py): pipeline · Builds image-and-text conditioning for up to four references. · `skyreels_v3/pipelines/reference_to_video_pipeline.py`
- [Single-shot extension](https://github.com/skyworkai/skyreels-v3/blob/main/skyreels_v3/pipelines/single_shot_extension_pipeline.py): pipeline · Encodes temporal context and generates continuous video continuation. · `skyreels_v3/pipelines/single_shot_extension_pipeline.py`
- [Shot-switch extension](https://github.com/skyworkai/skyreels-v3/blob/main/skyreels_v3/pipelines/shot_switching_extension_pipeline.py): pipeline · Applies cinematic shot-transition extension policy. · `skyreels_v3/pipelines/shot_switching_extension_pipeline.py`
- [Talking avatar](https://github.com/skyworkai/skyreels-v3/blob/main/skyreels_v3/pipelines/talking_avatar_pipeline.py): pipeline · Orchestrates portrait and audio-conditioned generation. · `skyreels_v3/pipelines/talking_avatar_pipeline.py`
- [Avatar media preparation](https://github.com/skyworkai/skyreels-v3/blob/main/skyreels_v3/utils/avatar_preprocess.py): preprocessing · Normalizes portrait media and aligns audio/video timing. · `skyreels_v3/utils/avatar_preprocess.py`

### Model & sampling

- [Video diffusion Transformers](https://github.com/skyworkai/skyreels-v3/blob/main/skyreels_v3/modules/transformer.py): cuda-model · Task variants denoise latent video sequences. · `skyreels_v3/modules/transformer.py`
- [Text & audio encoders](https://github.com/skyworkai/skyreels-v3/blob/main/skyreels_v3/modules/t5.py): multimodal-encoders · T5, CLIP, XLM-R, and Wav2Vec2 produce conditioning features. · `skyreels_v3/modules/t5.py`
- [Video VAE](https://github.com/skyworkai/skyreels-v3/blob/main/skyreels_v3/modules/vae.py): latent-codec · Encodes input media and reconstructs generated video frames. · `skyreels_v3/modules/vae.py`
- [Shared attention](https://github.com/skyworkai/skyreels-v3/blob/main/skyreels_v3/modules/attention.py): model-component · `skyreels_v3/modules/attention.py`
- [Flow sampling scheduler](https://github.com/skyworkai/skyreels-v3/blob/main/skyreels_v3/scheduler/fm_solvers_unipc.py): sampler · Schedules iterative diffusion/flow denoising. · `skyreels_v3/scheduler/fm_solvers_unipc.py`

### Runtime scaling

- [Shared settings](https://github.com/skyworkai/skyreels-v3/blob/main/skyreels_v3/config.py): configuration · Centralizes runtime and model settings. · `skyreels_v3/config.py`
- [Avatar 19B settings](https://github.com/skyworkai/skyreels-v3/blob/main/skyreels_v3/configs/talking_avatar_19B.py): configuration · `skyreels_v3/configs/talking_avatar_19B.py`
- [Context parallelism](https://github.com/skyworkai/skyreels-v3/blob/main/skyreels_v3/distributed/context_parallel_for_reference.py): distributed-runtime · xDiT USP-style multi-GPU execution by workload. · `skyreels_v3/distributed/context_parallel_for_reference.py`
- **CUDA inference runtime**: execution-runtime · PyTorch GPU execution supports block offload and low-VRAM FP8 weights.

### Other components

- **Generated video**: output · Decoded frames assembled as output video.

## Connections

- Media, prompts & URLs → Generation CLI: arguments and media
- Pretrained weights → Generation CLI: model source
- Generation CLI → Reference-to-video: reference task
- Generation CLI → Single-shot extension: continuation task
- Generation CLI → Shot-switch extension: shot-switch task
- Generation CLI → Talking avatar: avatar task
- Media, prompts & URLs → Avatar media preparation: portrait and audio
- Avatar media preparation → Talking avatar: aligned conditioning
- Reference-to-video → Text & audio encoders: text/image conditioning
- Single-shot extension → Video VAE: encode source context
- Shot-switch extension → Video VAE: encode source context
- Talking avatar → Text & audio encoders: audio and text features
- Reference-to-video → Video diffusion Transformers: latent denoising
- Single-shot extension → Video diffusion Transformers: continuation denoising
- Shot-switch extension → Video diffusion Transformers: transition denoising
- Talking avatar → Video diffusion Transformers: audio-aligned denoising
- Text & audio encoders → Video diffusion Transformers: conditioning features
- Flow sampling scheduler → Video diffusion Transformers: sampling steps
- Shared attention → Video diffusion Transformers: attention behavior
- Video diffusion Transformers → Video VAE: generated latents
- Video VAE → Generated video: decoded frames
- Shared settings → Generation CLI: runtime settings
- Avatar 19B settings → Talking avatar: avatar specialization
- Context parallelism → Reference-to-video: multi-GPU reference workload
- Context parallelism → CUDA inference runtime: torchrun execution
- CUDA inference runtime → Video diffusion Transformers: CUDA, offload, FP8
