Memory-V2V: Memory-Augmented Video-to-Video Diffusion for Consistent Multi-Turn Editing (ECCV 2026)
Dohun Lee, Chun-Hao Paul Huang, Xuelin Chen, Jong Chul Ye, Duygu Ceylan, Hyeonho Jeong
[Paper] [Project Page] [Checkpoint]
Note. This repository is a reproduction of Memory-V2V, implemented by following the Memory-V2V paper. Implementation details and results may differ from those reported in the paper.
This repository reproduces Memory-V2V for multi-turn video novel view synthesis: a video is re-rendered along several novel camera trajectories, one after another. The view for each trajectory is generated conditioned on the source video and on all previously generated views, which act as the memory, so that the views stay consistent with each other. The model is built on ReCamMaster (Wan2.1-T2V-1.3B).
What is added on top of ReCamMaster (diffsynth/models/wan_video_dit.py, camera_utils.py, inference.py):
- Multi-video conditioning. The noisy target video and N clean condition videos are tokenized into a
single sequence. All condition videos are patchified by the FramePack-style condition patch embedders
(
clean_x_embedder): the first condition (the source video) at full resolution and the following ones with 2x / 4x compression. The camera trajectories of the target and of the condition videos are injected through the per-block camera encoders, as in ReCamMaster. - RoPE layout. Target tokens use the time positions
[0, f), the source video[f, 2f)and the other conditions[2f, 3f). Compressed tokens use spatially downsampled RoPE frequencies. - Adaptive token merging (ATM). Before blocks 10 and 20, the condition frames that receive the most
attention from the target are kept, and the tokens of the other frames are merged 2x2 by a learnable
downsampler (
down2x_mid_10,down2x_mid_20). It is used in training and at inference (on by default). - VideoFOV (inference). Before each view is generated, the previous views are ranked by the overlap of
their field of view with that of the target trajectory (
camera_utils.video_fov_scores), and the most relevant ones get the finer condition tokenizers (on by default).
1. Create the conda environment.
git clone https://github.com/DoHunLee1/Memory-V2V.git && cd Memory-V2V
conda create -n memoryv2v python=3.11 -y
conda activate memoryv2vRecent conda versions ask you to accept the Terms of Service of the default Anaconda channels the first
time you create an environment (CondaToSNonInteractiveError). Either accept them as the error message says
conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/main
conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/ror create the environment from conda-forge instead:
conda create -n memoryv2v -c conda-forge --override-channels python=3.11 -y.
2. Install PyTorch built for your GPU. PyTorch publishes a separate build for each CUDA version
(cu126, cu128, ...), and each build contains GPU code only for a fixed list of GPU architectures. The
builds ship their own CUDA runtime, so inference needs no system-wide CUDA toolkit, only an NVIDIA driver that
supports your GPU (for training, see the DeepSpeed note under Tested environments). The model runs in
bfloat16, so use an Ampere or newer GPU.
| GPU architecture | Compute capability | Example GPUs | PyTorch build |
|---|---|---|---|
| Blackwell | 10.0, 12.0 | B200, RTX 5090, RTX PRO 6000 Blackwell | cu128 (cu126 and older do not support Blackwell) |
| Hopper | 9.0 | H100, H200 | cu128 or cu126 |
| Ada Lovelace | 8.9 | RTX 4090, RTX 6000 Ada, L40S | cu128 or cu126 |
| Ampere | 8.0, 8.6 | A100, RTX A6000, RTX 3090 | cu128 or cu126 |
nvidia-smi --query-gpu=name,compute_cap,driver_version --format=csv shows the compute capability and the
driver version of your GPUs, and the header of nvidia-smi shows the newest CUDA version the driver
supports (CUDA Version). Both CUDA 12 builds run on any driver from R525 on (CUDA Version 12.0 or
higher), even when it is lower than the build's own CUDA version (CUDA minor-version compatibility).
Blackwell GPUs need an R570 or newer driver and the cu128 build. With an older driver, update the driver.
# CUDA 12.8 build: Blackwell, Hopper, Ada, Ampere (recommended)
pip install torch==2.7.1 torchvision==0.22.1 --index-url https://download.pytorch.org/whl/cu128
# CUDA 12.6 build: Hopper, Ada, Ampere
pip install torch==2.7.1 torchvision==0.22.1 --index-url https://download.pytorch.org/whl/cu126Check that the build matches the GPU:
python -c "import torch; print(torch.__version__, torch.cuda.is_available(), torch.cuda.get_device_capability(), torch.cuda.get_arch_list())"
# e.g. on an RTX PRO 6000 Blackwell:
# 2.7.1+cu128 True (12, 0) ['sm_75', 'sm_80', 'sm_86', 'sm_90', 'sm_100', 'sm_120', 'compute_120']torch.cuda.is_available() must be True, and for a GPU of compute capability X.Y the list must contain an
sm_XZ entry with the same major version X and Z ≤ Y (e.g. sm_86 also covers sm_89, Ada). With a
build that does not support the GPU, PyTorch warns
... with CUDA capability sm_120 is not compatible with the current PyTorch installation and the model fails
with CUDA error: no kernel image is available for execution on the device. In that case reinstall PyTorch
from the right index URL above.
3. Install the other dependencies.
pip install -r requirements.txt torch==2.7.1 torchvision==0.22.1Listing torch and torchvision again keeps the build installed in step 2: if another package ever requires
a different PyTorch version, pip reports an error instead of silently replacing the build. Run step 2 first;
otherwise pip installs PyTorch from PyPI, whose CUDA build may not support your GPU.
Attention backend (optional). Attention uses the first of FlashAttention-3 (flash_attn_interface),
FlashAttention-2 (flash_attn), SageAttention (sageattention) and PyTorch SDPA that can be imported. None
of them is required: without them PyTorch SDPA is used, which is how the release was tested on Blackwell.
FlashAttention-3 targets Hopper GPUs and does not run on Blackwell. Install a backend after PyTorch, into the
same environment. Building one from source needs a CUDA toolkit (nvcc) with the same major version as the
PyTorch build, i.e. CUDA 12.x for cu126 / cu128 (PyTorch refuses to build extensions with a CUDA 13
toolkit). A backend that imports is used without any fallback: if an installed backend fails to import (e.g.
it was built for another PyTorch version) or does not support your GPU, uninstall it to use PyTorch SDPA.
Tested environments.
| Python | PyTorch | Other packages | GPU, attention | |
|---|---|---|---|---|
| Training and inference | 3.11 | 2.7.1+cu126 | Lightning 2.5.1, DeepSpeed 0.17.1 | - |
| Inference and training (release check) | 3.11.18 | 2.7.1+cu128 | transformers 5.22.2, Lightning 2.6.6, DeepSpeed 0.20.0, numpy 2.4.6, pandas 3.1.1 | RTX PRO 6000 Blackwell (driver 595.58), PyTorch SDPA |
The second row is what the commands above installed in November 2026. The Lightning and DeepSpeed versions of
the first row can be installed with pip install lightning==2.5.1 deepspeed==0.17.1. Training uses DeepSpeed, and
DeepSpeed 0.17.1 runs nvcc -V when it is imported on a GPU machine, so it needs a CUDA toolkit: put nvcc on
PATH or set CUDA_HOME (no DeepSpeed op is compiled with the default ZeRO stage 1). Newer DeepSpeed versions,
such as the 0.20.0 installed by requirements.txt, do not need it.
GPU memory. Peak memory per GPU at 832x480 and 81 frames (allocated by PyTorch), and the GPU memory we recommend:
| Task | Peak memory per GPU | Recommended GPU memory |
|---|---|---|
Inference (inference.sh / inference.py) |
17.0 GiB for the first view and about 0.5 GiB more for every previous view (18.9 GiB for the fifth view), with or without ATM | 24 GB |
Inference with --cpu_offload |
11.3 GiB for the first view, 12.0 GiB for the fifth | 16 GB |
Latent extraction (train.py --task data_process --tiled) |
12.0 GiB | 16 GB |
| Training from extracted latents | 25.5 GiB (27.5 GiB on a single GPU) | 32 GB |
| Training with on-the-fly VAE / T5 encoding | 37.1 GiB | 48 GB (40 GB is just enough with train.sh) |
Most of the inference memory is taken by the weights: the T5 text encoder alone takes 10.6 GiB, and --cpu_offload
keeps only the model in use on the GPU. The training numbers are for the worst case of 8 condition views, with
the settings of train.sh (gradient checkpointing, tiled VAE, DeepSpeed ZeRO stage 1, which splits the optimizer
states over the GPUs, so a single GPU needs 2 GiB more). Training with on-the-fly encoding adds the VAE and T5 on
every GPU. The recommended sizes leave room for the CUDA context and for the fragmentation of the GPU memory
(checked with five views for inference). train.sh sets PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True,
which reduces this fragmentation and is needed to train from latents on a single 32 GB GPU or with on-the-fly
encoding on 40 GB GPUs. On a GPU with more memory, nvidia-smi shows more, since PyTorch keeps freed memory
cached.
- Wan2.1-T2V-1.3B (to
models/Wan-AI/Wan2.1-T2V-1.3B), from ModelScope:or from Hugging Face (can be much faster depending on your location; about 17.6 GB in total):python download_wan2.1.py
python -c "from huggingface_hub import snapshot_download; snapshot_download('Wan-AI/Wan2.1-T2V-1.3B', local_dir='models/Wan-AI/Wan2.1-T2V-1.3B')" - Our checkpoint, from Hugging Face (to
models/checkpoints/memoryv2v.ckpt, 3.0 GB):python -c "from huggingface_hub import hf_hub_download; hf_hub_download('DHCAI/Memory-V2V', 'memoryv2v.ckpt', local_dir='models/checkpoints')" - (Training only) the ReCamMaster checkpoint used for
initialization (to
models/ReCamMaster/checkpoints/step20000.ckpt):python -c "from huggingface_hub import hf_hub_download; hf_hub_download('KlingTeam/ReCamMaster-Wan2.1', 'step20000.ckpt', local_dir='models/ReCamMaster/checkpoints')"
bash inference.sh # the example videos, on GPU 0
CUDA_VISIBLE_DEVICES=0,1 bash inference.sh # the same, split over GPUs 0 and 1
bash inference.sh --no-use_atm # without adaptive token merging (ATM)
bash inference.sh --no-use_videofov # without VideoFOV (previous views in generation order)inference.sh re-renders the four example videos of example_test_data/, each along its own trajectories
(see the table below): 1.mp4 and 2.mp4 along cam 1 → 2 → 9 → 10, 3.mp4 along 2 → 3 → 12 and 4.mp4
along 1 → 3 → 11. With several GPUs in CUDA_VISIBLE_DEVICES, the videos are distributed over them
and processed in parallel. Other arguments are passed to inference.py. To render every video of the
metadata along the same trajectories, call inference.py directly:
python inference.py --cam_type 2 3 12 --ckpt_path ./models/checkpoints/memoryv2v.ckptThe trajectories in --cam_type are generated in the given order: the view for cam_type[i] is
conditioned on the source video and on the views of cam_type[0], ..., cam_type[i-1]. The results are
stored in one folder per source video and per trajectory sequence (a view depends on the views generated
before it); for every video in example_test_data/metadata.csv the command above writes
results/<video>/cam_type_2_3_12/cam02_seed<seed>.mp4
results/<video>/cam_type_2_3_12/cam03_seed<seed>.mp4
results/<video>/cam_type_2_3_12/cam12_seed<seed>.mp4
| Argument | Default | Description |
|---|---|---|
--cam_type |
1 |
Target trajectories, generated in this order (see the table below). |
--dataset_path |
./example_test_data |
Folder with videos/ and the metadata csv. |
--metadata_file |
metadata.csv |
csv with columns file_name (in videos/) and text (caption). |
--camera_path |
<dataset_path>/cameras/camera_extrinsics.json |
Camera trajectories. |
--seed |
random | A random seed is drawn for every video if not set; it is saved in the file name. |
--num_inference_steps / --cfg_scale |
50 / 5.0 |
Sampling steps and classifier-free guidance scale. |
--start / --num_videos |
0 / all |
Subset of the metadata to process. |
--cpu_offload |
off | Keep only the model in use on the GPU (lower VRAM, slower). |
--use_videofov / --no-use_videofov |
on | Order the previous views by VideoFOV (see below). |
--use_atm / --no-use_atm |
on | Adaptive token merging (see below). |
--ckpt_path |
./models/checkpoints/memoryv2v.ckpt |
Our checkpoint. |
--wan_model_dir |
./models/Wan-AI/Wan2.1-T2V-1.3B |
Wan2.1 weights. |
--output_dir |
./results |
Videos are written to <output_dir>/<video>/cam_type_<ids>/; _no_videofov / _no_atm is appended to the folder name when VideoFOV / ATM is off. |
--fps |
30 |
Frame rate of the saved videos. |
Generating a view takes 17-19 GiB of GPU memory (11-12 GiB with --cpu_offload), and memory grows with every
view, since all previous views are conditions (see GPU memory in Installation). On an RTX
PRO 6000 Blackwell (Max-Q, 300 W) with PyTorch SDPA and the default 50 steps, the three views of one video took
about 8, 9.5 and 8.3 minutes with ATM (11.3 minutes for the third view without ATM), and nvidia-smi showed
about 24 GB for the first two views and 27 GB for the third (including memory cached by PyTorch).
VideoFOV and adaptive token merging (ATM) are both on by default.
-
VideoFOV. Before view
i, every previous view is scored by the overlap of its field of view with that of the target trajectory: directions are sampled on a sphere (radius 30 m) around the first camera of the target, the field of view of a trajectory is the set of directions seen by any of its frames, and the score is the mean of their IoU and of the fraction of the target's field of view that is covered (weighted by area). The source video is always the first condition (finest tokenizer); the previous views follow in the order of their score, the first three with the 2x tokenizer and the others with the 4x one. With up to three previous views, all of them get the 2x tokenizer and the order only changes which camera-embedding slot each view takes (and, with ATM, which frames are kept); from the fifth view on, VideoFOV also decides which views get the finer tokenizer. In the examples, only the fourth view of1.mp4and2.mp4(cam 10) is reordered, to cam 2, 1, 9. The order and the scores are printed for every view from the third one on. The field of view of the generated views is that of a 24 mm lens on a 23.76 mm sensor cropped to 832x480 (52.7° x 31.9°), seecamera_utils.py. -
ATM. Before DiT blocks 10 and 20, every condition frame is scored by the attention it receives from the target. The most relevant frames are kept, as many as two condition videos have (keep ratio 1, 1, 0.67, 0.5 and 0.4 with 1 to 5 conditions, the source video included), and the tokens of the other frames are merged 2x2. ATM is skipped while the keep ratio is 1. Since the number of kept frames stays the same, the time per denoising step no longer grows with the number of views (RTX PRO 6000 Blackwell Max-Q, PyTorch SDPA, CFG):
Conditions (source video + previous views) 1 2 3 4 5 Time per step without ATM 8.8 s 10.8 s 12.9 s 15.3 s 16.0 s Time per step with ATM 8.8 s 10.8 s 9.3 s 10.0 s 9.5 s
Multiple GPUs. inference.py runs on one GPU, selected with CUDA_VISIBLE_DEVICES. To use several GPUs,
start one process per GPU on disjoint parts of the metadata with --start / --num_videos (this is what
inference.sh does for the example videos), e.g. on GPUs 0 and 1:
CUDA_VISIBLE_DEVICES=0 python inference.py --cam_type 2 3 12 --start 0 --num_videos 2 &
CUDA_VISIBLE_DEVICES=1 python inference.py --cam_type 2 3 12 --start 2 --num_videos 2 &
waitSet --seed to make the results reproducible; otherwise every process draws its own random seed per video.
The seed is saved in the file name.
Your own videos. Put the videos (at least 81 frames; the first 81 frames are used) in
<dataset_path>/videos/ and list them with a caption in <dataset_path>/metadata.csv. Frames are resized
to 832x480 without cropping, so 16:9 videos work best. See the
prompt extension of Wan2.1 for writing captions.
Camera trajectories. example_test_data/cameras/camera_extrinsics.json contains 12 trajectories of 81
frames that all start from the pose of the source camera:
cam_type |
Trajectory | cam_type |
Trajectory |
|---|---|---|---|
| 1 | Pan Right | 6 | Zoom Out |
| 2 | Pan Left | 7 | Translate Up (with rotation) |
| 3 | Tilt Up | 8 | Translate Down (with rotation) |
| 4 | Tilt Down | 9 | Arc Left (with rotation) |
| 5 | Zoom In | 10 | Arc Right (with rotation) |
| 11 | Arc Left by about 40° around a point in front of the camera, tilting up and back down mid-clip | 12 | Arc Right by about 40°, otherwise like 11 |
Trajectories 1-10 are the ReCamMaster ones. New trajectories can be added in the same format: a
cam{id:02d} entry under every key frame0, ..., frame80, starting from the same frame0 pose as the
other trajectories.
Training fine-tunes ReCamMaster (download Wan2.1 and the ReCamMaster checkpoint first, see Checkpoints, steps 1 and 3; run the commands below from the repository root) on MultiCamVideo-Dataset, the training data of ReCamMaster: 13.6K scenes rendered with Unreal Engine 5, each with 10 synchronized 81-frame videos (1280x1280) and their camera trajectories. It takes three steps:
DATASET=/path/to/MultiCamVideo-Dataset
python download_multicamvideo.py --dataset_path "$DATASET" # 1. download
CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 python train.py --task data_process \
--dataset_path "$DATASET" --tiled --dataloader_num_workers 8 # 2. (optional) extract the latents
DATASET="$DATASET" bash train.sh # 3. train on 8 GPUs1. Download. download_multicamvideo.py streams the dataset from the Hugging Face Hub (a .tar.gz split into
16 parts, 333 GB) and extracts the training scenes on the fly, so the archive is never stored. With
--num_scenes N it stops after N complete scenes (about 19 MB each; the first scenes of the archive are mostly
from f35_aperture2.4), without it the whole dataset is extracted. Files that already exist are skipped, so an
interrupted download can be restarted with the same command. The dataset has no captions: the script writes
metadata.csv with the Tarsier2 captions of yslan/recammaster_caption
(third-party captions of the whole dataset, downloaded automatically; use --captions_json for your own captions
in the same format, and --skip_download to only rewrite metadata.csv). The result is
$DATASET
├── metadata.csv # file_name,text: one row per video
├── captions/recammaster_official_train_captions.json
├── train/
│ └── f35_aperture2.4/ # f18_aperture10, f24_aperture5, f35_aperture2.4, f50_aperture2.4
│ └── scene473/
│ ├── videos/cam01.mp4 ... cam10.mp4 # 81 frames, 1280x1280
│ └── cameras/camera_extrinsics.json # trajectories of the 10 cameras
└── latents/ # written by step 2
└── f35_aperture2.4/scene473/videos/cam01.pth ... cam10.pth
file_name in metadata.csv is relative to $DATASET/train, e.g.
f35_aperture2.4/scene473/videos/cam01.mp4,"A woman in a black shirt and jeans is seen in an industrial area ...".
Frames are resized to 832x832 and center-cropped to 832x480 (--height / --width).
2. Latents (optional). --task data_process encodes every video of metadata.csv with the VAE and its caption
with T5, once, and writes $DATASET/latents/<focal>/<scene>/videos/camXX.pth (change the folder with
--latent_path). Videos whose latents already exist are skipped, so the command can be resumed. It uses all the
GPUs in CUDA_VISIBLE_DEVICES. EXTRACT_LATENTS=1 bash train.sh runs it before training (with the same extra
arguments).
3. Training. bash train.sh (set DATASET, or edit it in the script) trains on 8 GPUs (the GPUs in
CUDA_VISIBLE_DEVICES, 0-7 by default) with batch size 1 per GPU and gradient accumulation over 4 steps, i.e. a
total batch size of 8 x 4 = 32, for 100 epochs of 16,000 samples (50,000 optimizer steps) with a learning rate of
1e-4. Other arguments are passed to train.py (e.g. --max_epochs 1). With another number of GPUs, keep the
total batch size of 32 with --accumulate_grad_batches, e.g.
CUDA_VISIBLE_DEVICES=0,1 bash train.sh --accumulate_grad_batches 16 for 2 GPUs. Views whose latents were
extracted in step 2 are loaded from $DATASET/latents (or --latent_path); the other views are encoded with the
VAE on the fly, and the target caption with T5 when the target view has no extracted latents, so step 2 can be
skipped. Training is then slower, and the VAE and T5 are kept on every GPU (each is loaded only if some view or
caption needs it; see GPU memory in Installation). The two can be mixed: views with latents
are always loaded from disk.
Every sample is a target view and a random number (1-8) of other views of the same scene, with a random
condition patch-embedder schedule and a random RoPE layout (the first condition has its own time segment or shares
the one of the other conditions).
Adaptive token merging (ATM) is applied with probability 0.25. The target is noised at a timestep drawn uniformly
from the 1000 training timesteps, and the conditions stay clean, except that when the first condition has its own
segment, all other conditions are lightly noised with probability 0.75 to mimic generated views: they get the noise
of one of the last 40 training timesteps (t from 172 down to 5, i.e. a noise level sigma = t / 1000 of at most 0.17).
With several GPUs, the number of condition views and these choices are the same on all the GPUs (and for all the
samples of an optimizer step with --accumulate_grad_batches), since they decide which parameters are trained and
DeepSpeed needs the same ones on every GPU; the videos, the noise and the timesteps differ. --seed (default 0)
makes the sampling reproducible; use another seed to continue training from a checkpoint, which only restores
the weights and would otherwise repeat the samples of the first run. The camera encoders / projectors, the
self-attention layers, the condition patch embedders and the token downsamplers are trained; the rest of
Wan2.1 is frozen. Checkpoints (3.0 GB each) are saved to <output_path>/checkpoints/step<N>.ckpt
(./models/train/checkpoints/ with train.sh) every --save_every_n_steps optimizer steps (1000 in
train.sh) and can be used directly with inference.py --ckpt_path. Use --num_nodes (e.g. with torchrun or
SLURM) for multi-node training, with the same --latent_path content on every node, and
--training_strategy deepspeed_stage_2 (DeepSpeed ZeRO stage 2 instead of 1) to partition the gradients over the
GPUs. ZeRO stage 3 and DDP are not supported.
This code is built on ReCamMaster, DiffSynth-Studio, Wan2.1 and FramePack. We thank the authors for releasing their code and data.
If you find this code useful, please cite
@inproceedings{lee2026memoryv2v,
title={Memory-V2V: Memory-Augmented Video-to-Video Diffusion for Consistent Multi-Turn Editing},
author={Lee, Dohun and Huang, Chun-Hao Paul and Chen, Xuelin and Ye, Jong Chul and Ceylan, Duygu and Jeong, Hyeonho},
booktitle={European Conference on Computer Vision (ECCV)},
year={2026}
}and ReCamMaster, on which this code is built:
@article{bai2025recammaster,
title={ReCamMaster: Camera-Controlled Generative Rendering from A Single Video},
author={Bai, Jianhong and Xia, Menghan and Fu, Xiao and Wang, Xintao and Mu, Lianrui and Cao, Jinwen and Liu, Zuozhu and Hu, Haoji and Bai, Xiang and Wan, Pengfei and others},
journal={arXiv preprint arXiv:2503.11647},
year={2025}
}