5353import warnings
5454from pathlib import Path
5555from shutil import copyfile
56- from typing import Any , Dict , Optional , Tuple , Union
56+ from typing import Any , Dict , Iterator , Optional , Tuple , Union
5757
5858import k2
5959import optim
@@ -753,7 +753,7 @@ def train_one_epoch(
753753 scheduler : LRSchedulerType ,
754754 sp : spm .SentencePieceProcessor ,
755755 train_dl : torch .utils .data .DataLoader ,
756- giga_train_dl : torch . utils . data . DataLoader ,
756+ iter_giga : Iterator ,
757757 valid_dl : torch .utils .data .DataLoader ,
758758 rng : random .Random ,
759759 scaler : "GradScaler" ,
@@ -806,7 +806,6 @@ def train_one_epoch(
806806 dl_weights = [1 - params .giga_prob , params .giga_prob ]
807807
808808 iter_libri = iter (train_dl )
809- iter_giga = iter (giga_train_dl )
810809
811810 batch_idx = 0
812811
@@ -950,9 +949,9 @@ def remove_short_and_long_utt(c: Cut):
950949 # an utterance duration distribution for your dataset to select
951950 # the threshold
952951 if c .duration < 1.0 or c .duration > 20.0 :
953- logging .warning (
954- f"Exclude cut with ID { c .id } from training. Duration: { c .duration } "
955- )
952+ # logging.warning(
953+ # f"Exclude cut with ID {c.id} from training. Duration: {c.duration}"
954+ # )
956955 return False
957956
958957 # In pruned RNN-T, we require that T >= S
@@ -965,14 +964,14 @@ def remove_short_and_long_utt(c: Cut):
965964 tokens = sp .encode (c .supervisions [0 ].text , out_type = str )
966965
967966 if T < len (tokens ):
968- logging .warning (
969- f"Exclude cut with ID { c .id } from training. "
970- f"Number of frames (before subsampling): { c .num_frames } . "
971- f"Number of frames (after subsampling): { T } . "
972- f"Text: { c .supervisions [0 ].text } . "
973- f"Tokens: { tokens } . "
974- f"Number of tokens: { len (tokens )} "
975- )
967+ # logging.warning(
968+ # f"Exclude cut with ID {c.id} from training. "
969+ # f"Number of frames (before subsampling): {c.num_frames}. "
970+ # f"Number of frames (after subsampling): {T}. "
971+ # f"Text: {c.supervisions[0].text}. "
972+ # f"Tokens: {tokens}. "
973+ # f"Number of tokens: {len(tokens)}"
974+ # )
976975 return False
977976
978977 return True
@@ -1117,6 +1116,8 @@ def run(rank, world_size, args):
11171116 # It's time consuming to include `giga_train_dl` here
11181117 # for dl in [train_dl, giga_train_dl]:
11191118 for dl in [train_dl ]:
1119+ # You can skip scan_pessimistic_batches_for_oom() if you are sure
1120+ # your selected params won't cause OOM
11201121 if params .start_batch <= 0 :
11211122 scan_pessimistic_batches_for_oom (
11221123 model = model ,
@@ -1127,6 +1128,8 @@ def run(rank, world_size, args):
11271128 warmup = 0.0 if params .start_epoch == 0 else 1.0 ,
11281129 )
11291130
1131+ iter_giga = iter (giga_train_dl )
1132+
11301133 scaler = create_grad_scaler (enabled = params .use_fp16 )
11311134 if checkpoints and "grad_scaler" in checkpoints :
11321135 logging .info ("Loading grad scaler state dict" )
@@ -1149,7 +1152,7 @@ def run(rank, world_size, args):
11491152 scheduler = scheduler ,
11501153 sp = sp ,
11511154 train_dl = train_dl ,
1152- giga_train_dl = giga_train_dl ,
1155+ iter_giga = iter_giga ,
11531156 valid_dl = valid_dl ,
11541157 rng = rng ,
11551158 scaler = scaler ,
0 commit comments