When using a fixed parametrization on categorical layers the output of MixingLayer is NaN for some combination of the inputs.
The issue seems to be related to the sum layer itself and particularly on the sum parameters.
By fixing the sum parameters to be unitary and picking the LSE-sum semiring, the result is wrong when both variables have zero value, but it is ok when either one of them has a non-zero.
Minimale code:
changing the random seed changes the results (e.g. with random seed 1 only the first evaluation is NaN) and the same happens when fixing the sum parameters by replacing
I tracked down the error and it appears to be in cirkit.backend.torch.semiring.LSESumSemiring in the method apply_reduce: when both inputs are 0s the variable xs is (tensor([[[[-inf]], [[-inf]]]]),). In line 375 the subtraction between two -inf results in an undefined operation.
When using a fixed parametrization on categorical layers the output of MixingLayer is NaN for some combination of the inputs. The issue seems to be related to the sum layer itself and particularly on the sum parameters.
By fixing the sum parameters to be unitary and picking the LSE-sum semiring, the result is wrong when both variables have zero value, but it is ok when either one of them has a non-zero. Minimale code:
changing the random seed changes the results (e.g. with random seed 1 only the first evaluation is NaN) and the same happens when fixing the sum parameters by replacing
with
I tracked down the error and it appears to be in cirkit.backend.torch.semiring.LSESumSemiring in the method apply_reduce: when both inputs are 0s the variable
xs
is(tensor([[[[-inf]], [[-inf]]]]),)
. In line 375 the subtraction between two-inf
results in an undefined operation.