-
Notifications
You must be signed in to change notification settings - Fork 71
Wan Animate Pipeline #367
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
csgoogle
wants to merge
3
commits into
main
Choose a base branch
from
sagarchapara/wananimate-pipeline
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Wan Animate Pipeline #367
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,332 @@ | ||
| # Copyright 2023 Google LLC | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # https://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| # This sentinel is a reminder to choose a real run name. | ||
| run_name: '' | ||
|
|
||
| metrics_file: "" # for testing, local file that stores scalar metrics. If empty, no metrics are written. | ||
| # If true save metrics such as loss and TFLOPS to GCS in {base_output_directory}/{run_name}/metrics/ | ||
| write_metrics: True | ||
|
|
||
| timing_metrics_file: "" # for testing, local file that stores function timing metrics such as state creation, compilation. If empty, no metrics are written. | ||
| write_timing_metrics: True | ||
|
|
||
| gcs_metrics: False | ||
| # If true save config to GCS in {base_output_directory}/{run_name}/ | ||
| save_config_to_gcs: False | ||
| log_period: 100 | ||
|
|
||
| pretrained_model_name_or_path: 'Wan-AI/Wan2.2-Animate-14B-Diffusers' | ||
| model_name: wan2.2 | ||
| model_type: 'I2V' | ||
|
|
||
| # Overrides the transformer from pretrained_model_name_or_path | ||
| wan_transformer_pretrained_model_name_or_path: '' | ||
|
|
||
| unet_checkpoint: '' | ||
| revision: '' | ||
| # This will convert the weights to this dtype. | ||
| # When running inference on TPUv5e, use weights_dtype: 'bfloat16' | ||
| weights_dtype: 'bfloat16' | ||
| # This sets the layer's dtype in the model. Ex: nn.Dense(dtype=activations_dtype) | ||
| activations_dtype: 'bfloat16' | ||
|
|
||
| # Replicates vae across devices instead of using the model's sharding annotations for sharding. | ||
| replicate_vae: False | ||
| # Number of devices to shard VAE spatial activations across. -1 uses all devices. | ||
| vae_spatial: -1 | ||
|
|
||
| # matmul and conv precision from https://jax.readthedocs.io/en/latest/jax.lax.html#jax.lax.Precision | ||
| # Options are "DEFAULT", "HIGH", "HIGHEST" | ||
| # fp32 activations and fp32 weights with HIGHEST will provide the best precision | ||
| # at the cost of time. | ||
| precision: "DEFAULT" | ||
| # Use jax.lax.scan for transformer layers | ||
| scan_layers: False | ||
|
|
||
| # if False state is not jitted and instead replicate is called. This is good for debugging on single host | ||
| # It must be True for multi-host. | ||
| jit_initializers: True | ||
|
|
||
| # Set true to load weights from pytorch | ||
| from_pt: True | ||
| split_head_dim: True | ||
| attention: 'flash' # Supported attention: dot_product, flash, tokamax_flash, cudnn_flash_te, ring, tokamax_ring, ulysses, ulysses_custom | ||
| use_base2_exp: True | ||
| use_experimental_scheduler: True | ||
| flash_min_seq_length: 4096 | ||
| # If mask_padding_tokens is True, we pass in segment ids to splash attention to avoid attending to padding tokens. | ||
| # Else we do not pass in segment ids and on vpu bound hardware like trillium this is faster. | ||
| # However, when padding tokens are significant, this will lead to worse quality and should be set to True. | ||
| mask_padding_tokens: True | ||
| # Maxdiffusion has 2 types of attention sharding strategies: | ||
| # 1. attention_sharding_uniform = True : same sequence sharding rules applied for q in both (self and cross attention) | ||
| # 2. attention_sharding_uniform = False : Heads are sharded uniformly across devices for self attention while sequence is sharded | ||
| # in cross attention q. | ||
| attention_sharding_uniform: True | ||
| dropout: 0.0 | ||
|
|
||
| # Tuned for 720p (720x1280), 81 frames, CP=8 on Trillium (32MB VMEM): | ||
| # block_q=2048, block_kv=4096, block_kv_compute=1024 | ||
| # ~31% faster than default (512,512,512): 389s vs 508s at 40 steps | ||
| flash_block_sizes: { | ||
| "block_q" : 2048, | ||
| "block_kv_compute" : 1024, | ||
| "block_kv" : 4096, | ||
| "block_q_dkv" : 512, | ||
| "block_kv_dkv" : 512, | ||
| "block_kv_dkv_compute" : 512, | ||
| "block_q_dq" : 512, | ||
| "block_kv_dq" : 512, | ||
| "use_fused_bwd_kernel": False, | ||
| } | ||
| # Default smaller-shape block sizes: | ||
| # flash_block_sizes: { | ||
| # "block_q" : 512, | ||
| # "block_kv_compute" : 512, | ||
| # "block_kv" : 512, | ||
| # "block_q_dkv" : 512, | ||
| # "block_kv_dkv" : 512, | ||
| # "block_kv_dkv_compute" : 512, | ||
| # "block_q_dq" : 512, | ||
| # "block_kv_dq" : 512, | ||
| # "use_fused_bwd_kernel": False, | ||
| # } | ||
| # GroupNorm groups | ||
| norm_num_groups: 32 | ||
|
|
||
| # Text encoder training keys are unused by generate_wan_animate.py. | ||
| train_text_encoder: False | ||
| text_encoder_learning_rate: 4.25e-6 | ||
|
|
||
| # Training loss keys are unused by generate_wan_animate.py. | ||
| snr_gamma: -1.0 | ||
|
|
||
| timestep_bias: { | ||
| # a value of later will increase the frequency of the model's final training steps. | ||
| # none, earlier, later, range | ||
| strategy: "none", | ||
| # multiplier for bias, a value of 2.0 will double the weight of the bias, 0.5 will halve it. | ||
| multiplier: 1.0, | ||
| # when using strategy=range, the beginning (inclusive) timestep to bias. | ||
| begin: 0, | ||
| # when using strategy=range, the final step (inclusive) to bias. | ||
| end: 1000, | ||
| # portion of timesteps to bias. | ||
| # 0.5 will bias one half of the timesteps. Value of strategy determines | ||
| # whether the biased portions are in the earlier or later timesteps. | ||
| portion: 0.25 | ||
| } | ||
|
|
||
| # Override parameters from checkpoints's scheduler. | ||
| diffusion_scheduler_config: { | ||
| _class_name: 'FlaxEulerDiscreteScheduler', | ||
| prediction_type: 'epsilon', | ||
| rescale_zero_terminal_snr: False, | ||
| timestep_spacing: 'trailing' | ||
| } | ||
|
|
||
| # Output directory | ||
| # Create a GCS bucket, e.g. my-maxtext-outputs and set this to "gs://my-maxtext-outputs/" | ||
| base_output_directory: "" | ||
|
|
||
| # Hardware | ||
| hardware: 'tpu' # Supported hardware types are 'tpu', 'gpu' | ||
| skip_jax_distributed_system: False | ||
|
|
||
| # Parallelism | ||
| mesh_axes: ['data', 'fsdp', 'context', 'tensor'] | ||
|
|
||
| # batch : batch dimension of data and activations | ||
| # hidden : | ||
| # embed : attention qkv dense layer hidden dim named as embed | ||
| # heads : attention head dim = num_heads * head_dim | ||
| # length : attention sequence length | ||
| # temb_in : dense.shape[0] of resnet dense before conv | ||
| # out_c : dense.shape[1] of resnet dense before conv | ||
| # out_channels : conv.shape[-1] activation | ||
| # keep_1 : conv.shape[0] weight | ||
| # keep_2 : conv.shape[1] weight | ||
| # conv_in : conv.shape[2] weight | ||
| # conv_out : conv.shape[-1] weight | ||
| logical_axis_rules: [ | ||
| ['batch', ['data', 'fsdp']], | ||
| ['activation_batch', ['data', 'fsdp']], | ||
| ['activation_self_attn_heads', ['context', 'tensor']], | ||
| ['activation_cross_attn_q_length', ['context', 'tensor']], | ||
| ['activation_length', 'context'], | ||
| ['activation_heads', 'tensor'], | ||
| ['mlp','tensor'], | ||
| ['embed', ['context', 'fsdp']], | ||
| ['heads', 'tensor'], | ||
| ['norm', 'tensor'], | ||
| ['conv_batch', ['data', 'context', 'fsdp']], | ||
| ['out_channels', 'tensor'], | ||
| ['conv_out', 'context'], | ||
| ] | ||
| data_sharding: [['data', 'fsdp', 'context', 'tensor']] | ||
|
|
||
| # One axis for each parallelism type may hold a placeholder (-1) | ||
| # value to auto-shard based on available slices and devices. | ||
| # By default, product of the DCN axes should equal number of slices | ||
| # and product of the ICI axes should equal number of devices per slice. | ||
| dcn_data_parallelism: 1 # recommended DCN axis to be auto-sharded | ||
| dcn_fsdp_parallelism: 1 | ||
| dcn_context_parallelism: -1 | ||
| dcn_tensor_parallelism: 1 | ||
| ici_data_parallelism: 1 | ||
| ici_fsdp_parallelism: 1 | ||
| ici_context_parallelism: -1 # recommended ICI axis to be auto-sharded | ||
| ici_tensor_parallelism: 1 | ||
|
|
||
| allow_split_physical_axes: False | ||
|
|
||
| # Dataset keys are kept for shared pyconfig compatibility. | ||
| # They are not used by generate_wan_animate.py. | ||
| dataset_name: '' | ||
| train_split: 'train' | ||
| dataset_type: 'tfrecord' | ||
| cache_latents_text_encoder_outputs: True | ||
| dataset_save_location: '' | ||
| load_tfrecord_cached: True | ||
| train_data_dir: '' | ||
| dataset_config_name: '' | ||
| jax_cache_dir: '.jax_cache' | ||
| hf_data_dir: '' | ||
| hf_train_files: '' | ||
| hf_access_token: '' | ||
| image_column: 'image' | ||
| caption_column: 'text' | ||
| resolution: 1024 | ||
| center_crop: False | ||
| random_flip: False | ||
| # If cache_latents_text_encoder_outputs is True | ||
| # the num_proc is set to 1 | ||
| tokenize_captions_num_proc: 4 | ||
| transform_images_num_proc: 4 | ||
| reuse_example_batch: False | ||
| enable_data_shuffling: True | ||
|
|
||
| # Defines the type of gradient checkpoint to enable. | ||
| # NONE - means no gradient checkpoint | ||
| # FULL - means full gradient checkpoint, whenever possible (minimum memory usage) | ||
| # MATMUL_WITHOUT_BATCH - means gradient checkpoint for every linear/matmul operation, | ||
| # except for ones that involve batch dimension - that means that all attention and projection | ||
| # layers will have gradient checkpoint, but not the backward with respect to the parameters. | ||
| # OFFLOAD_MATMUL_WITHOUT_BATCH - same as MATMUL_WITHOUT_BATCH but offload instead of recomputing. | ||
| # CUSTOM - set names to offload and save. | ||
| remat_policy: "NONE" | ||
| # For CUSTOM policy set below, current annotations are for: attn_output, query_proj, key_proj, value_proj | ||
| # xq_out, xk_out, ffn_activation | ||
| names_which_can_be_saved: [] | ||
| names_which_can_be_offloaded: [] | ||
|
|
||
| # checkpoint every number of samples, -1 means don't checkpoint. | ||
| checkpoint_every: -1 | ||
| checkpoint_dir: "" | ||
| # enables one replica to read the ckpt then broadcast to the rest | ||
| enable_single_replica_ckpt_restoring: False | ||
|
|
||
| # Shared training keys are kept for shared pyconfig compatibility. | ||
| learning_rate: 1.e-5 | ||
| scale_lr: False | ||
| max_train_samples: -1 | ||
| # max_train_steps takes priority over num_train_epochs. | ||
| max_train_steps: 1500 | ||
| num_train_epochs: 1 | ||
| seed: 0 | ||
| output_dir: 'wan-animate-outputs' | ||
| per_device_batch_size: 0.125 | ||
| # If global_batch_size % jax.device_count is not 0, use FSDP sharding. | ||
| global_batch_size: 0 | ||
|
|
||
| # For creating tfrecords from dataset | ||
| tfrecords_dir: '' | ||
| no_records_per_shard: 0 | ||
| enable_eval_timesteps: False | ||
| timesteps_list: [125, 250, 375, 500, 625, 750, 875] | ||
| num_eval_samples: 420 | ||
|
|
||
| warmup_steps_fraction: 0.1 | ||
| learning_rate_schedule_steps: -1 # By default the length of the schedule is set to the number of steps. | ||
| save_optimizer: False | ||
|
|
||
| # However you may choose a longer schedule (learning_rate_schedule_steps > steps), in which case the training will end before | ||
| # dropping fully down. Or you may choose a shorter schedule, where the unspecified steps will have a learning rate of 0. | ||
|
|
||
| # AdamW optimizer parameters | ||
| adam_b1: 0.9 # Exponential decay rate to track the first moment of past gradients. | ||
| adam_b2: 0.999 # Exponential decay rate to track the second moment of past gradients. | ||
| adam_eps: 1.e-8 # A small constant applied to denominator outside of the square root. | ||
| adam_weight_decay: 0 # AdamW Weight decay | ||
| max_grad_norm: 1.0 | ||
|
|
||
| enable_profiler: False | ||
| # ML Diagnostics settings | ||
| enable_ml_diagnostics: False | ||
| profiler_gcs_path: "" | ||
| enable_ondemand_xprof: False | ||
| # Skip first n steps for profiling, to omit things like compilation and to give | ||
| # the iteration time a chance to stabilize. | ||
| skip_first_n_steps_for_profiler: 5 | ||
| profiler_steps: 10 | ||
|
|
||
| # Enable JAX named scopes for detailed profiling and debugging | ||
| # When enabled, adds named scopes around key operations in transformer and attention layers | ||
| enable_jax_named_scopes: False | ||
|
|
||
| # Generation parameters | ||
| prompt: "The person from the reference image follows the motion from the driving videos with natural body movement, stable identity, expressive face, cinematic framing, and realistic lighting." | ||
| negative_prompt: "Bright tones, overexposed, static, blurred details, subtitles, style, works, paintings, images, static, overall gray, worst quality, low quality, JPEG compression residue, ugly, incomplete, extra fingers, poorly drawn hands, poorly drawn faces, deformed, disfigured, misshapen limbs, fused fingers, still picture, messy background, three legs, many people in the background, walking backwards" | ||
| height: 720 | ||
| width: 1280 | ||
| num_frames: 121 | ||
| flow_shift: 5.0 | ||
| num_inference_steps: 30 | ||
| fps: 24 | ||
| save_final_checkpoint: False | ||
|
|
||
| # Wan Animate input overrides (used by generate_wan_animate.py). | ||
| # Set these to local paths or HTTP(S) URLs. Sample assets should not live in the repo. | ||
| mode: "animate" | ||
| reference_image_path: "" | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we point to some default image path in huggingface? |
||
| pose_video_path: "" | ||
| face_video_path: "" | ||
| background_video_path: "" | ||
| mask_video_path: "" | ||
| segment_frame_length: 77 | ||
| prev_segment_conditioning_frames: 1 | ||
| motion_encode_batch_size: null | ||
| # Values greater than 1.0 enable classifier-free guidance for WAnimate. | ||
| animate_guidance_scale: 1.0 | ||
|
|
||
| # Quantization plumbing is currently kept disabled for WAnimate. | ||
| quantization: '' | ||
| # Shard the range finding operation for quantization. By default this is set to number of slices. | ||
| quantization_local_shard_count: -1 | ||
| compile_topology_num_slices: -1 # Number of target slices, set to a positive integer. | ||
| use_qwix_quantization: False | ||
| # Quantization calibration method used for weights, activations and bwd. Supported methods can be found in https://github.com/google/qwix/blob/dc2a0770351c740e5ab3cce7c0efe9f7beacce9e/qwix/qconfig.py#L70-L80 | ||
| weight_quantization_calibration_method: "absmax" | ||
| act_quantization_calibration_method: "absmax" | ||
| bwd_quantization_calibration_method: "absmax" | ||
| qwix_module_path: ".*" | ||
|
|
||
| # Eval model on per eval_every steps. -1 means don't eval. | ||
| eval_every: -1 | ||
| eval_data_dir: "" | ||
| enable_generate_video_for_eval: False # This will increase the used TPU memory. | ||
| eval_max_number_of_samples_in_bucket: 60 # The number of samples per bucket for evaluation. This is calculated by num_eval_samples / len(timesteps_list). | ||
|
|
||
| enable_ssim: False | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's remove the folder
assests/wan_animateall together and remove this