I see. If you have a function (say in numpy or scipy) that performs this periodic padding for you, you could somewhat easily write an autograd Function that perform this operation.
That will require writing the backward for this operation, but that can be performed by using index_add function.
Something like (warning: untested)
from autograd import Function
class PeriodicPadding2d(Function):
    @staticmethod
    def forward(ctx, input, pad):
        output = np.periodicpad(input, pad)  # find the function that performs what you want
        ctx.pad = pad
        ctx.size = input.size()
        ctx.numel = input.numel()
        return output

    @once_differentiable
    @staticmethod
    def backward(ctx, grad_output):
        pad = ctx.pad
        idx = grad_output.new(ctx.size)
        torch.arange(0, ctx.numel, out=idx)
        idx = np.periodicpad(idx, pad)  # or whatever is the function
        grad_input = grad_output.new(ctx.numel).zero_()
        grad_input.index_add_(0, idx, grad_output.view(-1))
        return grad_input.view(ctx.size)