Hi,
The documentation states that both in_channels and out_channels should be divisible by groups.
Does your second and third example not throws errors?
Regarding the working of groups, essentially the in_channels is divided into sets, each containing in_channels / groups channels. Convolution is applied independently to these sets. You can think of it as having seperate convolution layers each seeing only part of the input channels. For each set the number of output channels is equal to out_channels / groups. The output of each of the sets is concatenated so that the final number of output channels is out_channels.
I tried to depict this as a diagram here: https://docs.google.com/presentation/d/163NU5vYkuqZKUYSYtWg8Hd9zrviuldh0q3P4WYXKjTg/edit?usp=sharing 31