As far as I understand (vocab_size +1) is the maximum unique element for embedding. Your input size does not have to be the vocab_size.
When you use padding_idx=vocab_size you are saying that input will always have the size of your vocabulary and this is not the case.
There can be 2 solutions:

You can give padding_idx the size of your input after padding ( max_len + 1)

You can add zero at the beginning of each sentence with padding_idx=0. After embedding, remove the first embedded element and give it as input to the next layer.

I hope it is clear.
This is an example (I create my input by adding zero(my padding) at the beginning ) but you can use cat like this:
input = torch.tensor([[8, 1, 2, 5],[9, 6, 0, 0]])
zeros = torch.zeros(2, 1).long()
input = torch.cat((zeros,input), 1)
print(input)
emb = nn.Embedding(10,3,padding_idx=0)
embedded = emb(input)[:,1:]
print(embedded)

output:
tensor([[0, 8, 1, 2, 5],
        [0, 9, 6, 0, 0]])
tensor([[[ 1.5745, -2.3024, -0.5964],
         [-1.5407,  0.8915, -1.3858],
         [-1.2728,  1.5402,  0.7473],
         [ 0.1958,  0.4828,  0.5091]],

        [[-0.1123, -0.3911,  0.4758],
         [ 0.0876, -0.6896,  0.0802],
         [ 0.0000,  0.0000,  0.0000],
         [ 0.0000,  0.0000,  0.0000]]], grad_fn=<SliceBackward>)