Skip to content

Commit a2f02eb

Browse files
alancuckinv-kkudrynski
authored andcommitted
[FastPitch/PyT] Fix off-by-one in grad acc
1 parent 63cbbdc commit a2f02eb

5 files changed

Lines changed: 13 additions & 10 deletions

File tree

PyTorch/SpeechSynthesis/FastPitch/inference.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ def generate_audio(mel):
514514
audio[-fade_len:] *= fade_w.to(audio.device)
515515

516516
audio = audio / torch.max(torch.abs(audio))
517-
fname = b['output'][i] if 'output' in b else f'audio_{i}.wav'
517+
fname = b['output'][i] if 'output' in b else f'audio_{all_utterances + i}.wav'
518518
audio_path = Path(args.output, fname)
519519
write(audio_path, args.sampling_rate, audio.cpu().numpy())
520520

PyTorch/SpeechSynthesis/FastPitch/scripts/inference_benchmark.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22

33
set -a
44

5-
: ${PHRASES:="phrases/benchmark_8_128.tsv"}
6-
: ${OUTPUT_DIR:="./output/audio_$(basename ${PHRASES} .tsv)"}
5+
: ${FILELIST:="phrases/benchmark_8_128.tsv"}
6+
: ${OUTPUT_DIR:="./output/audio_$(basename ${FILELIST} .tsv)"}
77
: ${TORCHSCRIPT:=true}
8-
: ${REPEATS:=100}
98
: ${BS_SEQUENCE:="1 4 8"}
10-
: ${WARMUP:=100}
9+
: ${WARMUP:=64}
10+
: ${REPEATS:=500}
11+
: ${AMP:=false}
1112

1213
for BATCH_SIZE in $BS_SEQUENCE ; do
1314
LOG_FILE="$OUTPUT_DIR"/perf-infer_amp-${AMP}_bs${BATCH_SIZE}.json

PyTorch/SpeechSynthesis/FastPitch/scripts/inference_example.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env bash
22

3-
export CUDNN_V8_API_ENABLED=1
3+
export CUDNN_V8_API_ENABLED=1 # Keep the flag for older containers
4+
export TORCH_CUDNN_V8_API_ENABLED=1
45

56
: ${DATASET_DIR:="data/LJSpeech-1.1"}
67
: ${BATCH_SIZE:=32}
@@ -55,7 +56,7 @@ echo -e "\nAMP=$AMP, batch_size=$BATCH_SIZE\n"
5556

5657
ARGS=""
5758
ARGS+=" --cuda"
58-
ARGS+=" --cudnn-benchmark"
59+
# ARGS+=" --cudnn-benchmark" # Enable for benchmarking or long operation
5960
ARGS+=" --dataset-path $DATASET_DIR"
6061
ARGS+=" -i $FILELIST"
6162
ARGS+=" -o $OUTPUT_DIR"

PyTorch/SpeechSynthesis/FastPitch/scripts/train_benchmark.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ set -a
1111
for NUM_GPUS in $NUM_GPUS_SEQUENCE ; do
1212
GRAD_ACCUMULATION=$((256 / $BATCH_SIZE / $NUM_GPUS ))
1313
LOG_FILE=$OUTPUT_DIR/perf-train_amp-${AMP}_${NUM_GPUS}x${BATCH_SIZE}x${GRAD_ACCUMULATION}.json
14-
bash scripts/train.sh "$@"
14+
BMARK_EPOCHS=$((EPOCHS * 2 / 3 * $NUM_GPUS / 8)) # 2/3 of EPOCHS
15+
EPOCHS=$((EPOCHS * $NUM_GPUS / 8)) bash scripts/train.sh "$@" --benchmark-epochs-num $BMARK_EPOCHS
1516
rm -f $OUTPUT_DIR/FastPitch*.pt
1617
done

PyTorch/SpeechSynthesis/FastPitch/train.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -417,8 +417,8 @@ def main():
417417

418418
epoch_iter = 1
419419
for batch, accum_step in zip(train_loader,
420-
cycle(range(args.grad_accumulation))):
421-
if accum_step == 0:
420+
cycle(range(1, args.grad_accumulation + 1))):
421+
if accum_step == 1:
422422
adjust_learning_rate(total_iter, optimizer, args.learning_rate,
423423
args.warmup_steps)
424424

0 commit comments

Comments
 (0)