Skip to content

Conversation

@rubenciranni
Copy link

Convolution was previously working and tested only for groups=1. When using other values for groups this gave incorrect results, for example testing Clifford 1d group convolution with g = [-1] against complex group convolution gave different results.

The issue was caused by the data layout.
Let's consider a 1d convolution for simplicity. Then the weight for this convolution has shape:
weight.shape =[number_of_blades, output_channels, input_channels / groups, kernel_size]
The corresponding clifford kernel has shape:
kernel.shape = [number_of_blades * output_channels, number_of_blades * input_channels / groups, kernel_size]
The shape of the output of the convolution is:
output.shape = [batch_size, number_of_blades * output_channels, output_length]
Where it is expected that output[:output_channels] is the first blade and output[output_channels:2 * output_channels] is the second blade. However this is not what is happening, since each filter has number_of_blades * input_channels / groups channels and:

  • In the first half of the filters the first half is the scalar part of the weight, the second half is the e1 part multiplied by g[0] (those are the filters expected to generate the scalar part of the output)
  • In the second half of the filters the first half is the e1 part of the weight, the second half is the scalar part (those are the filters expected to generate the e1 part of the output)

In grouped convolution with 2 groups, the first half of the filters is assigned to the first half of the input channels, while the second half of the filters is assigned to the second half of the input channels. Each filter always expect the first half of its input channels to be the scalar part and the second part to be the e1 part, however it happens that all of its input channels are actually either all scalar or all e1!

To make group convolution work correctly, scalar and e1 channels should be interleaved to match the kernel. This reasoning can be generalised for all the other clifford algebras, and this was implemented in the last commit. Moreover a test was added to test Clifford group convolution with g = [-1] against complex group convolution. This test now passes, while it was previously failing. All the other tests are still passing as before.

@rubenciranni
Copy link
Author

@microsoft-github-policy-service agree

@Flecart
Copy link

Flecart commented Jul 31, 2025

@rejuvyesh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants