Closed mstechly closed 1 month ago
I did some investigation on this and it seems there's a couple of failure modes that could be investigated separately.
To test it I changed test_compile
in the following way:
def test_compile(routine, expected_routine):
compiled_routine = compile_routine(routine)
compiled_routine = compile_routine(compiled_routine)
assert compiled_routine == expected_routine
This change to some test cases passing and some other failing, as described below. Numbering of the test cases starts from 0 – all the test cases which have not been mentioned pass.
Test 2:
bartiq.errors.BartiqCompilationError: Variable list contains repeated symbol; found [IndependentVariable(a.x), IndependentVariable(a.y), IndependentVariable(b.x), IndependentVariable(b.y), IndependentVariable(x), IndependentVariable(y), IndependentVariable(a.x), IndependentVariable(a.y), IndependentVariable(b.x), IndependentVariable(b.y)]
Reason: after compilation input_params
contains also children params [x, y, a.x, a.y, b.x, b.y]
. Most likely during the second compilation, it doesn't check if children params are already added and adds them again, which causes compilation to fail.
Seems that test cases 3 and 6 also have similar issue.
Test 4: Second compilation works, but then the assertion fails – this might or might not be intended behaviour, requires further investigation.
Same for test cases: 9, 10 and 13.
Test 5: Fails with:
E bartiq.errors.BartiqCompilationError: Expressions must not contain unknown variables.
E Expression: z = 2*N + x_aa + x_ab + y_aa + y_ab
E Known variables: {'y_ab', 'y_aa', 'x_aa', 'x_ab'}
E Unknown variables: {'N'}.
routine.children['a']
has input port with size None
, while compiled_routine.children['a']
has port with size N
, which apparently causes some issues.
Seems that test cases 12 and 14 also have similar issue.
The next step for this would be to investigate these 3 cases separately and see whether the behaviour in each case is expected and whether we need to introduce any changes or not.
Closing as is no longer valid in the new compilation engine.
Right now, if we try to compile a routine that has been already compiled, we get an error. I think this is very counter-intuitive and we should fix it. Perhaps we could throw a warning in such case, but we shouldn't fail.