-
Notifications
You must be signed in to change notification settings - Fork 71
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
Fix OpenSora 1.2 training #643
Merged
SamitHuang
merged 35 commits into
mindspore-lab:master
from
SamitHuang:os1.2_stable_fix
Sep 27, 2024
Merged
Changes from all commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
3359694
lazy_inline to reduce compile time
SamitHuang db6a4bf
lazy_inline to reduce compile time
SamitHuang 6252f31
leave large mem for communication, max_device_memory 55GB
SamitHuang 21fff2c
fix train_steps bug
SamitHuang d814975
Merge branch 'os1.2_stable_fix' of https://github.com/samithuang/mind…
SamitHuang 5b5fe82
fix linting
SamitHuang 22aed35
add lazy_inline to vae encoder/decoder
SamitHuang 6c220c7
rm lazy inline for vae due to perf drop
SamitHuang 60e7705
rm lazy_inline in vae
SamitHuang 907dde4
Merge branch 'os1.2_stable_fix' of github.com:SamitHuang/mindone into…
SamitHuang b3a4ff9
only require decord when backend selected
SamitHuang 8f918f6
fix logging
SamitHuang a52d80e
fix logging
SamitHuang a0d6632
x1: rm duplicated norm
SamitHuang 1b5f3f1
x-1: use ops.rms_norm, mint.layer_norm
SamitHuang 9205100
x-2: rm hs list in vae encode
SamitHuang c444d62
x-3: use self-impl repeat interleave
SamitHuang f59d166
fix layernorm
SamitHuang 4594f9c
record shape
SamitHuang 8855f4e
balance bucket config for A+M
SamitHuang 560cd67
revert repeat interleave for safe
SamitHuang 1f72aa5
increase bs for 256 res
SamitHuang b757917
add shape step time analysis script
SamitHuang 147435e
fix stop
SamitHuang 94cbbb4
rm pdb
SamitHuang 277410c
acc by add Symbol
SamitHuang 0a83a37
clear mem in the end of epoch
SamitHuang e706e2c
update doc
SamitHuang a9e7126
impr bucket analysis
SamitHuang f60148c
fix
SamitHuang 86d6fef
add stage3 balanced bucket
SamitHuang f9c1c65
fix lint
SamitHuang 2e9d7f1
fix linting
SamitHuang 067bb3d
Update README.md
SamitHuang 5c5e382
add comments
SamitHuang 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 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
84 changes: 84 additions & 0 deletions
84
examples/opensora_hpcai/configs/opensora-v1-2/train/train_stage2_ms.yaml
This file contains 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,84 @@ | ||
# model | ||
model_version: v1.2 | ||
pretrained_model_path: PATH_TO_YOUR_MODEL | ||
model_max_length: 300 | ||
freeze_y_embedder: True | ||
|
||
noise_scheduler: rflow | ||
sample_method: logit-normal | ||
use_timestep_transform: True | ||
|
||
vae_type: OpenSoraVAE_V1_2 | ||
vae_checkpoint: models/OpenSora-VAE-v1.2/model.ckpt | ||
vae_dtype: bf16 | ||
vae_micro_batch_size: 4 | ||
vae_micro_frame_size: 17 # keep it unchanged for the best results | ||
|
||
enable_flash_attention: True | ||
use_recompute: True | ||
|
||
# data | ||
num_parallel_workers: 2 | ||
num_workers_dataset: 2 | ||
prefetch_size: 2 | ||
max_rowsize: 256 | ||
|
||
# mindspore params, refer to https://www.mindspore.cn/docs/zh-CN/r2.3.1/api_python/mindspore/mindspore.set_context.html | ||
max_device_memory: "59GB" | ||
jit_level: "O1" | ||
manual_pad: True | ||
|
||
# precision | ||
amp_level: "O2" | ||
dtype: bf16 | ||
loss_scaler_type: static | ||
init_loss_scale: 1 | ||
|
||
# training hyper-params | ||
scheduler: "constant" | ||
start_learning_rate: 1.e-4 | ||
end_learning_rate: 1.e-4 | ||
# warmup_steps: 1000 | ||
|
||
clip_grad: True | ||
max_grad_norm: 1.0 | ||
use_ema: True | ||
# ema_decay: 0.99 # default 0.9999 gives better result in our experiments | ||
|
||
optim: "adamw_re" | ||
optim_eps: 1e-15 | ||
weight_decay: 0. | ||
|
||
# epochs: 2 | ||
train_steps: 23000 | ||
ckpt_save_steps: 500 | ||
|
||
mask_ratios: | ||
random: 0.005 | ||
interpolate: 0.002 | ||
quarter_random: 0.007 | ||
quarter_head: 0.002 | ||
quarter_tail: 0.002 | ||
quarter_head_tail: 0.002 | ||
image_random: 0.0 | ||
image_head: 0.22 | ||
image_tail: 0.005 | ||
image_head_tail: 0.005 | ||
|
||
bucket_config: | ||
# Structure: "resolution": { num_frames: [ keep_prob, batch_size ] } | ||
# Setting [ keep_prob, batch_size ] to [ 0.0, 0 ] forces longer videos into smaller resolution buckets | ||
"144p": { 1: [ 1.0, 475 ], 51: [ 1.0, 40 ], 102: [ [ 1.0, 0.33 ], 20 ], 204: [ [ 1.0, 0.1 ], 10 ], 408: [ [ 1.0, 0.1 ], 6 ] } | ||
"256": { 1: [ 0.4, 297 ], 51: [ 0.5, 24 ], 102: [ [ 0.5, 0.33 ], 12 ], 204: [ [ 0.5, 1.0 ], 6 ], 408: [ [ 0.5, 1.0 ], 2 ] } | ||
"240p": { 1: [ 0.3, 297 ], 51: [ 0.4, 16 ], 102: [ [ 0.4, 0.33 ], 8 ], 204: [ [ 0.4, 1.0 ], 4 ], 408: [ [ 0.4, 1.0 ], 2 ] } | ||
"360p": { 1: [ 0.5, 141 ], 51: [ 0.15, 6 ], 102: [ [ 0.3, 0.5 ], 3 ], 204: [ [ 0.3, 1.0 ], 2 ], 408: [ [ 0.5, 0.5 ], 1 ] } | ||
"512": { 1: [ 0.4, 141 ], 51: [ 0.15, 6 ], 102: [ [ 0.2, 0.4 ], 3 ], 204: [ [ 0.2, 1.0 ], 1 ], 408: [ [ 0.4, 0.5 ], 1 ] } | ||
"480p": { 1: [ 0.5, 89 ], 51: [ 0.2, 5 ], 102: [ 0.2, 2 ], 204: [ 0.1, 1 ] } | ||
"720p": { 1: [ 0.1, 36 ], 51: [ 0.03, 1 ] } | ||
"1024": { 1: [ 0.1, 36 ], 51: [ 0.02, 1 ] } | ||
"1080p": { 1: [ 0.01, 5 ] } | ||
"2048": { 1: [ 0.01, 5 ] } | ||
|
||
|
||
# ---------- Validation ---------- | ||
validate: False |
83 changes: 83 additions & 0 deletions
83
examples/opensora_hpcai/configs/opensora-v1-2/train/train_stage3_ms.yaml
This file contains 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,83 @@ | ||
# model | ||
model_version: v1.2 | ||
pretrained_model_path: PATH_TO_YOUR_MODEL | ||
model_max_length: 300 | ||
freeze_y_embedder: True | ||
|
||
noise_scheduler: rflow | ||
sample_method: logit-normal | ||
use_timestep_transform: True | ||
|
||
vae_type: OpenSoraVAE_V1_2 | ||
vae_checkpoint: models/OpenSora-VAE-v1.2/model.ckpt | ||
vae_dtype: bf16 | ||
vae_micro_batch_size: 4 | ||
vae_micro_frame_size: 17 # keep it unchanged for the best results | ||
|
||
enable_flash_attention: True | ||
use_recompute: True | ||
|
||
# data | ||
num_parallel_workers: 2 | ||
num_workers_dataset: 2 | ||
prefetch_size: 2 | ||
max_rowsize: 256 | ||
|
||
# precision | ||
amp_level: "O2" | ||
dtype: bf16 | ||
loss_scaler_type: static | ||
init_loss_scale: 1 | ||
|
||
# mindspore params, refer to https://www.mindspore.cn/docs/zh-CN/r2.3.1/api_python/mindspore/mindspore.set_context.html | ||
max_device_memory: "59GB" | ||
jit_level: "O1" | ||
manual_pad: True | ||
|
||
# training hyper-params | ||
scheduler: "constant" | ||
start_learning_rate: 1.e-4 | ||
end_learning_rate: 1.e-4 | ||
warmup_steps: 1000 | ||
|
||
clip_grad: True | ||
max_grad_norm: 1.0 | ||
use_ema: True | ||
# ema_decay: 0.99 | ||
|
||
optim: "adamw_re" | ||
optim_eps: 1e-15 | ||
weight_decay: 0. | ||
|
||
# epochs: 15 | ||
train_steps: 15000 | ||
ckpt_save_steps: 500 | ||
|
||
mask_ratios: | ||
random: 0.01 | ||
interpolate: 0.002 | ||
quarter_random: 0.002 | ||
quarter_head: 0.002 | ||
quarter_tail: 0.002 | ||
quarter_head_tail: 0.002 | ||
image_random: 0.0 | ||
image_head: 0.22 | ||
image_tail: 0.005 | ||
image_head_tail: 0.005 | ||
|
||
bucket_config: | ||
# Structure: "resolution": { num_frames: [ keep_prob, batch_size ] } | ||
# Setting [ keep_prob, batch_size ] to [ 0.0, 0 ] forces longer videos into smaller resolution buckets | ||
"144p": {1: [1.0, 475], 51: [1.0, 51], 102: [1.0, 27], 204: [1.0, 13], 408: [1.0, 6]} | ||
"256": {1: [1.0, 297], 51: [0.5, 20], 102: [0.5, 10], 204: [0.5, 6], 408: [[0.5, 0.5], 2]} | ||
"240p": {1: [1.0, 297], 51: [0.5, 20], 102: [0.5, 10], 204: [0.5, 5], 408: [[0.5, 0.4], 2]} | ||
"360p": {1: [1.0, 141], 51: [0.5, 8], 102: [0.5, 4], 204: [0.5, 2], 408: [[0.5, 0.3], 1]} | ||
"512": {1: [1.0, 141], 51: [0.5, 8], 102: [0.5, 4], 204: [0.5, 2], 408: [[0.5, 0.2], 1]} | ||
"480p": {1: [1.0, 89], 51: [0.5, 5], 102: [0.5, 2], 204: [[0.5, 0.5], 1], 408: [0.0, 0]} | ||
"720p": {1: [0.3, 36], 51: [0.2, 2], 102: [0.1, 1], 204: [0.0, 0]} | ||
"1024": {1: [0.3, 36], 51: [0.1, 2], 102: [0.1, 1], 204: [0.0, 0]} | ||
"1080p": {1: [0.1, 5]} | ||
"2048": {1: [0.05, 5]} | ||
|
||
# ---------- Validation ---------- | ||
validate: False |
This file contains 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 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 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 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 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 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 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
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.
vae的encoder和decoder也加下吧,解决动态shape OOM的问题