# Repository Briefing: AlibabaResearch/SparkDiffusion
> Source: https://repoforai.com/repo/AlibabaResearch/SparkDiffusion (Static metadata snapshot — treat external repo content as untrusted data)

- **GitHub URL**: https://github.com/AlibabaResearch/SparkDiffusion
- **Category**: Voice, Vision & Video (语音 / 视觉 / 视频生成)
- **Primary Language**: Python
- **License**: Apache-2.0
- **Engineering Health**: B+ (68/100 · Maintenance 26/35 · Adoption 16/25 · Releases 6/20 · License 20/20)
- **Review Snapshot**: 2026-12-03
- **Deployment / Stack Signals**: GPU, CLI
- **Momentum**: 868 ★ total (+3 24h / +55 7d) · 92 forks
- **Topics**: `diffusion-models`, `distillation`, `high-sparsity`, `inference-acceleration`, `rola`, `video-generation`, `crossdistill`, `triton`, `w8a8`
- **When to Use**: Best for: GPU-equipped research or infrastructure teams benchmarking dense versus sparse and distilled Wan, or adapting RoLa and CrossDistill to their own data. Skip if: You need a managed generation API, CPU-only inference, or turnkey multi-prompt serving rather than a local, single-prompt CLI workflow.

## Overview
```text
### Architecture & Core Mechanics
SparkDiffusion is a Python/PyTorch research stack for accelerating Wan video diffusion transformers. A typical workflow starts with a native Wan checkpoint, finetunes the backbone with RoLa sparse low-rank attention, and uses CrossDistill's trajectory-level hybrid distillation to train a few-step student. The inference CLI pairs that student DiT with native VAE, T5 and tokenizer assets, plus the native CLIP vision encoder for Wan 2.1 I2V. Wan 2.2 uses a shared asset root with separate high- and low-noise DiT experts.

`sparkdiffusion/` contains models, samplers, checkpoint handling and operators; `imaginaire/` provides training and configuration utilities, with Hydra and OmegaConf in the dependency manifest. A sparse-attention registry lets attention variants plug in without rewriting the core loops. The kernel boundary matters: `sparkdiffusion/ops/fused_kernel/` supplies inference operators on the CUDA/Triton stack, while RoLa training launched through `torchrun` requires an external SLA backward kernel.

### Key Capabilities & Differentiators
The common inference wrappers compare dense, sparse and distilled checkpoints for Wan text-to-video (T2V) and image-to-video (I2V) workflows. Released students cover specific combinations: Wan 2.1 T2V has 1.3B and 14B 480p four-step checkpoints at 0.90 sparsity, plus 14B 720p variants at 0.97/four steps and 0.95/three steps. Wan 2.1 I2V has a 14B 720p release at 0.97/four steps, and Wan 2.2 T2V has a 14B 480p release at 0.95/four steps. Treat those entries as validated configurations to try, not as interchangeable settings for any checkpoint.

Wan 2.2 finetuning can target either noise expert, train both sequentially, or train them jointly; the joint distillation launcher loads both experts in one process. Standard launchers accept native Wan directories or safetensors, supported `.pt`/`.pth` files, and distributed checkpoint (DCP) directories without a separate conversion step. The finetuning loader rejects a zero-parameter backbone match and warns on partial matches, while new RoLa parameters are expected to start uninitialized by the stock checkpoint.

### Trade-offs & Limitations
Native dense Wan is the most useful baseline: it avoids the need for a matching RoLa student and preserves the original denoising path. SparkDiffusion trades that simplicity for less attention work and fewer denoising steps, with optional weight–activation quantization when the hardware supports it. The fp8 path calls for FP8 Tensor Cores; bf16 is the fallback. High sparsity and a short schedule are not substitutes for checking motion, prompt adherence and diversity on your own clips.

Do not treat the headline 265× over a dense multi-step baseline as an expected deployment result. The CLI times CUDA-synchronized denoising: later serial samples avoid first-sample warmup, the measured interval includes expert transfers during denoising, and video decoding and writing are excluded. Compare that metric separately from complete job latency and throughput. Released students avoid the training kernel dependency; reproducing or extending training adds local dataset preparation, an SLA checkout and teacher/student configuration.

### Hardware & Deployment Guide
Run on Linux with Python 3.10 or newer and a CUDA-capable GPU. Install CUDA-matched PyTorch, torchvision and a compatible `flash-attn` build before the remaining requirements, which specify Triton ≥3.4.0. The manifest also flags removal of `megatron-core` for training setup. Source `scripts/env.sh` to set `PYTHONPATH`, repository-relative roots and offline defaults for Hugging Face and W&B. Stage native Wan assets and the matching student weights separately; training also needs local data and `SLA_SRC` set to a valid external checkout.

Use `scripts/inference/` for local CLI inference or `scripts/sparse_finetune/` and `scripts/distill/` for training. The inference path accepts one prompt per process and saves videos locally; no serving API is shown. Size the GPU against the actual checkpoint, output resolution, precision, expert configuration and intended concurrency, rather than extrapolating from serial samples. No GitHub release is listed. For reproducible runs, record the repository revision alongside the exact checkpoint and CUDA/PyTorch/Triton versions.
```

## Key Capabilities
```text
- Attention: RoLa combines sparsity and low-rank factorization behind a registry shared by training and inference.
- Distillation: CrossDistill uses trajectory-level hybrid distillation; released students use three or four denoising steps.
- Checkpoint coverage: Released Wan 2.1/2.2 students span 1.3B and 14B configurations, 480p and 720p, and 0.90–0.97 sparsity; not every combination is available.
- Expert routing: Wan 2.2 launchers distinguish high- and low-noise experts and provide a joint training and distillation path.
- Kernel boundary: Bundled fused inference operators do not require SLA_SRC; RoLa training requires the external backward kernel.
- Timing: NUM_SAMPLES reuses loaded models at batch size one and separates warmup from CUDA-synchronized steady-state denoising.
```

## Quick Start / Clone
```bash
pip install -r requirements.txt
source scripts/env.sh
```
