PsiQ / bartiq

Bartiq
https://psiq.github.io/bartiq/
Apache License 2.0
31 stars 9 forks source link

Make sure `compile_routine` does not change input object #45

Closed mstechly closed 1 month ago

mstechly commented 5 months ago

Currently compile_routine method modifies "in-place" the input. We want to make sure it does not happen.

It can be seen in the basic tutorial – after running compile_routine(uncompiled_routine) , the uncompiled_routine gets a new resources: T_gates, which most likely comes from precompilation.

We'd need to ensure that the public methods do not mutating their inputs, as it can lead to very nasty and hard to debug behavior.

mstechly commented 5 months ago

After looking a bit more into how precompilation works, it's definitely (but not necessarily exclusively) matter of precompilation, as all the precompilation stages change the routine in-place.