ASR optimizer state lost when restoring from checkpoint
Hi,
I'm continuing training from my previous checkpoint using Quartznet and I notice the loss and WER jumping significantly (WER by about 10%). Am I missing something, or is this because the optimizer state is not restored? Is anyone working on this, or shall I have a go at it? Thanks.
Are you using CheckpointCallback https://github.com/NVIDIA/NeMo/blob/master/examples/asr/quartznet.py#L189 ? It should be saving a trainer state like trainer-* in addition to your moduls' snapshots
Yup, I'm using it. It definitely loads the weights correctly since the first step has the same WER and loss as when saving. But then WER jumps significantly suggesting that the optimizer state isn't restored. The loss doesn't come down to earlier levels for a few days. In fact, if I don't lower the learning rate, WER jumps by 30% after the first few steps.
have you looked at learning rate plots? If you are using some schedule, that can be conditioned on epoch/step number
Thanks. I tried removing warm-up altogether, but that made no difference. Anything else I should look at? I am using cosine annealing.
I could get the loss/WER down by not using any policy. This is probably not the ideal setting, but I'm closing this for now.
Hello!
I am having the same problem, WER starting to grow with every step of fine tuning (even with --warmup_steps=0 --lr=0 --optimizer=sgd --lr_policy=None) WER grows 1% each step.
Do you know how with learning rate set to 0 weights still can change?
I am using NeMo v0.9.0 (in docker container), trying to fine-tune QuartzNet model using quartznet.py script in examples. Using pretrained quartznet15x5 as a starting point.
Each step gets a different batch of data, so that's why WER changes even when the weights stay the same. I got so paranoid that I removed the policy part from the training script altogether. Also, try the Novograd optimiser with a small learning rate (higher than zero though!)
Each step gets a different batch of data, so that's why WER changes even when the weights stay the same. I got so paranoid that I removed the policy part from the training script altogether. Also, try the Novograd optimiser with a small learning rate (higher than zero though!)
No, I mean I set --eval_freq=1 and evaluating after every train step on full separate evaluation set and I see WER growing (on this evaluation set).
I found suggestions that it can be due to batch norm layers and their running averages.
I am trying to fine tune quartznet15x5 on LibriSpeech-test-clean (that I obtained using /NeMo/scripts/get_librispeech_data.py).
Initially, I evaluate pre-trained nvidia quartznet on my evaluation set and get 26% WER.
Setting --warmup_steps=0 --lr=0.0001 and training for just 150 steps gives me WER of 80% on the same validation set.
I think that such WER change is odd (I am expecting it to slowly go down or up, not jump to such high value after 150 steps).
Maybe you can suggest parameters you used for fine tuning (LR, etc.)?
What's your batch size?
Can we try breaking it down, so we can understand what's happening? I understand you are using the quartznet.py script with the following, right?
neural_factory.train(
tensors_to_optimize=[train_loss],
callbacks=callbacks,
lr_policy=CosineAnnealing(args.num_epochs * steps_per_epoch, warmup_steps=args.warmup_steps),
optimizer=args.optimizer,
optimization_params={
"num_epochs": args.num_epochs,
"lr": args.lr,
"betas": (args.beta1, args.beta2),
"weight_decay": args.weight_decay,
"grad_norm_clip": None,
},
batches_per_step=args.iter_per_step,
synced_batchnorm=args.synced_bn,
synced_batchnorm_groupsize=args.synced_bn_groupsize,
)
What happens when you simplify it to the following?
neural_factory.train(
tensors_to_optimize=[loss],
callbacks= callbacks,
optimizer="novograd",
optimization_params={
"num_epochs": 100, "lr": 0.0001, "weight_decay": 1e-5
}
)
If the loss and WER start to decrease, you can try a bigger learning rate or weight decay. Of course this depends on your batch size
My batch size is 16
neural_factory.train( tensors_to_optimize=[loss], callbacks= callbacks, optimizer="novograd", optimization_params={ "num_epochs": 100, "lr": 0.0001, "weight_decay": 1e-5 } )
With the above train settings, WER jumps to 69% after 150 steps and then goes down to 27% at step 2250.
Let me know if it continues to go down. "weight_decay": 1e-4 might work better if training WER and validation WER diverge
Lowest WER I got was 24% which is better than the starting point (26%).
But I still think there's something wrong with this initial WER jump (I get it even with SGD optimizer and 0 learning rate).
I will try to change BatchNorm momentum to 0 and see if WER stops changing with 0 learning rate.
Thanks for your help, btw!
No worries. Btw what's your hardware? Remember that they took 5 days with 8 x V100 and 400 epochs for the model to converge. You may want to give it a few days.
Yep, it was BatchNorm. It's momentum=0.1 was hardcoded in JasperBlock.
When I set it to 0, WER stopped changing from step to step (when LR=0).
I guess I will try to set the momentum to something smaller like 0.01 as my batch size is small.
I'm training on one GeForce RTX 2080Ti (11GB mem). The maximum batch size I can fit is 16.
Good catch!