Commit 343819f9 authored by Alexei Baevski's avatar Alexei Baevski Committed by Myle Ott
Browse files

dont send dummy batch when reloading from checkpoint

also don't crash if param does not recieve grads
parent b9956a6a
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -271,8 +271,10 @@ class Trainer(object):
            if not p.requires_grad:
                continue
            if p.grad is None:
                raise RuntimeError('Model parameter did not receive gradient: ' + name + '. '
                                   'Use the param in the forward pass or set requires_grad=False')
                print('WARNING: model parameter did not receive gradient: ' + name + '. '
                      'Check that you\'re using the param in the forward pass or set requires_grad=False')
                grads.append(p.new_zeros(p.shape))
            else:
                grads.append(p.grad.data)
        return grads

+3 −2
Original line number Diff line number Diff line
@@ -71,8 +71,7 @@ def main(args):
    )

    # Load the latest checkpoint if one is available
    load_checkpoint(args, trainer, epoch_itr)

    if not load_checkpoint(args, trainer, epoch_itr):
        # Send a dummy batch to warm the caching allocator
        dummy_batch = task.dataset('train').get_dummy_batch(args.max_tokens, max_positions)
        trainer.dummy_train_step(dummy_batch)
@@ -319,6 +318,8 @@ def load_checkpoint(args, trainer, epoch_itr):
            trainer.lr_step_update(trainer.get_num_updates())
            if 'best' in extra_state:
                save_checkpoint.best = extra_state['best']
        return True
    return False


def load_dataset_splits(task, splits):