TeamGraphix / graphix

measurement-based quantum computing (MBQC) compiler and simulator
https://graphix.readthedocs.io
Apache License 2.0
55 stars 20 forks source link

Allow empty output nodes and measures at circuit level #125

Closed thierry-martinez closed 2 months ago

thierry-martinez commented 3 months ago

This pull request enables measures to be expressed at circuit level, in order to be able to consider circuits with classical outputs. Patterns are now allowed to measure all their nodes, and have an empty output node set, to enable to consider patterns where only classical outputs are considered.

Transpiled circuits can now have "measure" gates, introduced with the circ.m(qubit, plane, angle) method. The measured qubit cannot be used in any subsequent gate. The transpiler now returns a TranspileResult dataclass: the pattern is available in the pattern field, and the field classical_outputs contains the index where the classical measures can be found in the results array of the simulator.

shinich1 commented 2 months ago

example and docs bits can be done on my side as well, I will approve as soon as there's test for TN backend.

thierry-martinez commented 2 months ago

Could you also add appropriate lines to docs (e.g. generator.rst) so they show up in module references? also it might be good to illustrate the use of this feature in examples - perhaps simple example like rotation.py?

I tried to improve the documentation in 1e97cdc. Thanks!

thierry-martinez commented 2 months ago

Thanks! Merged.