Skip to content
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

Refactor to support PyTorch 2.0 and Lightning 2.0 #72

Merged
merged 79 commits into from
Apr 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
7acf94f
Initial attempt to refactor lightning code
hrukalive Mar 22, 2023
a0c2445
Add hparams to yaml, successful checkpointing
hrukalive Mar 23, 2023
20ae2f3
Fix batch sampler and lr_scheduler step freq
hrukalive Mar 23, 2023
219b663
Checkpointing done
hrukalive Mar 24, 2023
7819e0b
Use pl rankzero utils to discriminate main proc
hrukalive Mar 24, 2023
311653a
use rank_zero_info
hrukalive Mar 24, 2023
9dda2eb
Clean indexed ds, add main proc check back to hparam
hrukalive Mar 24, 2023
b663b10
remove h5py compression and ncols in binarizer tqdm
hrukalive Mar 24, 2023
5652c43
Format tqdm
hrukalive Mar 24, 2023
ee67f81
Fix bug in val_check_interval, hide v_num
hrukalive Mar 25, 2023
7b2d23f
Cleanup dataset codes, rename custom callbacks
hrukalive Mar 25, 2023
4798f68
Bump requirement torch and pl version
hrukalive Mar 25, 2023
27753f6
binarizer joint aug bug fix
hrukalive Mar 25, 2023
1d7cd38
revert torch version
hrukalive Mar 25, 2023
97a52db
Remove py3.9 syntax
hrukalive Mar 25, 2023
3ac11f4
Add env for CUDNN API change, clean more codes
hrukalive Mar 25, 2023
ae2946c
Initial attempt to refactor lightning code
hrukalive Mar 22, 2023
6b15665
Add hparams to yaml, successful checkpointing
hrukalive Mar 23, 2023
705265f
Fix batch sampler and lr_scheduler step freq
hrukalive Mar 23, 2023
6bc26ed
Checkpointing done
hrukalive Mar 24, 2023
93e4627
Use pl rankzero utils to discriminate main proc
hrukalive Mar 24, 2023
6bb4cae
use rank_zero_info
hrukalive Mar 24, 2023
1dd369d
Clean indexed ds, add main proc check back to hparam
hrukalive Mar 24, 2023
f17263a
remove h5py compression and ncols in binarizer tqdm
hrukalive Mar 24, 2023
49e6271
Format tqdm
hrukalive Mar 24, 2023
5eb3d74
Fix bug in val_check_interval, hide v_num
hrukalive Mar 25, 2023
b2aa789
Cleanup dataset codes, rename custom callbacks
hrukalive Mar 25, 2023
bb3c637
Bump requirement torch and pl version
hrukalive Mar 25, 2023
a39a9fa
binarizer joint aug bug fix
hrukalive Mar 25, 2023
f745a6e
revert torch version
hrukalive Mar 25, 2023
7dae5aa
Remove py3.9 syntax
hrukalive Mar 25, 2023
2bbc42b
Add env for CUDNN API change, clean more codes
hrukalive Mar 25, 2023
e8430a7
Solve merge conflict
hrukalive Mar 25, 2023
287d31c
commit to pl rank_zero util
hrukalive Mar 25, 2023
7f983d9
Resolve merged changes
hrukalive Mar 25, 2023
0543914
Auto strategy choose, gloo backend by default
hrukalive Mar 26, 2023
1a2f2c9
Fix for reviews
hrukalive Mar 26, 2023
736013a
Temporary disable lock in indexed dataset builder
hrukalive Mar 26, 2023
b648b74
Default nccl backend
hrukalive Mar 26, 2023
a818b8b
Merge branch 'refactor-v2' into refactor-pl
hrukalive Mar 26, 2023
1977f53
Indexed dataset builder ext to .data
hrukalive Mar 26, 2023
c1ab92a
Revert back some small changes for diff
hrukalive Mar 26, 2023
8888fe7
Convert type to builtin
hrukalive Mar 26, 2023
b7dbe55
patch potential device mismatch for hifigan
hrukalive Mar 26, 2023
a25cfff
Fix for reviews
hrukalive Mar 26, 2023
e632dda
Merge branch 'refactor-v2' into refactor-pl
yqzhishen Mar 27, 2023
dbb6c05
Fix checkpointing
hrukalive Mar 27, 2023
0cc0fd6
Default PL configs to base.yaml
hrukalive Mar 28, 2023
5222dca
Fix validation dataloader
hrukalive Mar 28, 2023
c2ab411
Show num params once
hrukalive Mar 28, 2023
a3ec41c
Support csv in multi speaker preparation
hrukalive Mar 29, 2023
27411c8
Multispeaker compatible with old txt
hrukalive Mar 29, 2023
b0f1712
auto strategy fix for auto
hrukalive Mar 29, 2023
406279d
Not logging grad norm
hrukalive Mar 29, 2023
254a9a0
Show lr in prog bar
hrukalive Mar 29, 2023
048b459
Remove dependency on lightning during deployment
hrukalive Mar 29, 2023
fc43aff
Guard the sampler shuffle grid size
hrukalive Mar 29, 2023
49331dc
More meaningful grid size
hrukalive Mar 30, 2023
b1222e1
Separate log of lr on prog bar
hrukalive Mar 30, 2023
e065812
Prevent step in prog bar scientific notation
hrukalive Mar 30, 2023
312c810
Prevent distributed sampler padding
hrukalive Mar 30, 2023
331d1a2
Bump dependencies and simplify requirements
yqzhishen Mar 30, 2023
8aaaacd
Downgrade librosa version
yqzhishen Mar 30, 2023
aaf1f98
Merge pull request #1 from yqzhishen/simplify-deps
hrukalive Mar 30, 2023
4690210
Merge branch 'refactor-pl' of https://github.com/hrukalive/DiffSinger…
hrukalive Mar 30, 2023
77e9a04
Correct validation logging, sampler revamp, fix hparam print bug
hrukalive Mar 31, 2023
5f64a41
Batch shuffle order and fix bf16 type in vocoder
hrukalive Mar 31, 2023
947f841
Fix h5py pickle on windows
hrukalive Mar 31, 2023
78c279c
Make sure validation is in fp32
hrukalive Mar 31, 2023
77e1d3a
Remove unnecessary cast to float in vocoder
hrukalive Mar 31, 2023
78b2298
Metric manually to device
hrukalive Mar 31, 2023
5c0263e
Sampler padding and default not shuffle batch
hrukalive Apr 1, 2023
3c51a83
Verbose checkpointing
hrukalive Apr 1, 2023
6851b7f
Fix permanent checkpointing
hrukalive Apr 1, 2023
9d2fdac
Remove printing
hrukalive Apr 1, 2023
441c622
Fix checkpoint top-k config change behavior
hrukalive Apr 1, 2023
d457ace
Various fix for checkpointing
hrukalive Apr 1, 2023
76ef3c6
Permanent checkpointing
hrukalive Apr 3, 2023
b76cfcc
Fixes for lightning 2.0
hrukalive Apr 4, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions augmentation/spec_stretch.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,20 @@ def process_item(self, item: dict, key_shift=0., speed=1., replace_spk_id=None)
aug_item['wav_fn'], keyshift=key_shift, speed=speed
)

aug_item['mel'] = torch.from_numpy(mel)
aug_item['mel'] = mel

if speed != 1. or hparams.get('use_speed_embed', False):
aug_item['length'] = mel.shape[0]
aug_item['speed'] = int(np.round(hparams['hop_size'] * speed)) / hparams['hop_size'] # real speed
aug_item['seconds'] /= aug_item['speed']
aug_item['ph_dur'] /= aug_item['speed']
aug_item['mel2ph'] = get_mel2ph_torch(
self.lr, aug_item['ph_dur'], aug_item['length'], hparams, device=self.device
)
self.lr, torch.from_numpy(aug_item['ph_dur']), aug_item['length'], hparams, device=self.device
).cpu().numpy()
f0, _, _ = get_pitch_parselmouth(
wav, aug_item['length'], hparams, speed=speed, interp_uv=hparams['interp_uv']
)
aug_item['f0'] = torch.from_numpy(f0)
aug_item['f0'] = f0.astype(np.float32)

if key_shift != 0. or hparams.get('use_key_shift_embed', False):
aug_item['key_shift'] = key_shift
Expand Down
27 changes: 3 additions & 24 deletions basics/base_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,9 @@
class BaseDataset(Dataset):
'''
Base class for datasets.
1. *ordered_indices*:
if self.shuffle == True, shuffle the indices;
if self.sort_by_len == True, sort data by length;
2. *sizes*:
1. *sizes*:
clipped length if "max_frames" is set;
3. *num_tokens*:
2. *num_tokens*:
unclipped length.

Subclasses should define:
Expand All @@ -23,11 +20,9 @@ class BaseDataset(Dataset):
2. *__getitem__*:
the index function.
'''
def __init__(self, shuffle):
def __init__(self):
super().__init__()
self.hparams = hparams
self.shuffle = shuffle
self.sort_by_len = hparams['sort_by_len']
self.sizes = None

@property
Expand All @@ -50,19 +45,3 @@ def size(self, index):
"""Return an example's size as a float or tuple. This value is used when
filtering a dataset with ``--max-positions``."""
return self._sizes[index]

def ordered_indices(self):
"""Return an ordered list of indices. Batches will be constructed based
on this order."""
if self.shuffle:
indices = np.random.permutation(len(self))
if self.sort_by_len:
indices = indices[np.argsort(np.array(self._sizes)[indices], kind='mergesort')]
# 先random, 然后稳定排序, 保证排序后同长度的数据顺序是依照random permutation的 (被其随机打乱).
else:
indices = np.arange(len(self))
return indices

@property
def num_workers(self):
return int(hparams.get('ds_workers', os.getenv('NUM_WORKERS', 0)))
Loading