This error is raised due to the expand call in kn, if you want to calculate gradients for the kernels.
You could use repeat instead or call .contiguous() on kn:
conv1.weight = nn.Parameter(kn.expand(6, 3, -1, -1).contiguous())