Yes, you will have to pad your input sequences to implement minibatch training.
Essentially, the way minibatch works is to pack a bunch of input tensors into another tensor of a higher dimension for computational efficiency. As an example, three separate input tensors of size 10 can be stacked together as a minibatch into another tensor of size 3 x 10 Since tensors of different lengths cannot be stacked together, you need to pad all input tensors to be of the same length. Notice that this a requirement for minibatch technique, and not of the RNN per se - so this doesn’t defeat the purpose.
Also notice that the sequences have to be of the same length across a particular mini-batch, not across the whole dataset. So let’s say if you have 10 input examples of the following sizes [10, 10, 59, 60, 28, 30, 97, 100, 3, 5] , you can split them into 5 batches of different sizes [10, 60, 30, 100, 5]. I guess you should be more convinced now.
For the implementation, see http://pytorch.org/docs/master/nn.html#torch.nn.utils.rnn.pad_sequence 360 and the related discussion at https://github.com/pytorch/pytorch/issues/1128 155 .