XanaduAI / MrMustard

A differentiable bridge between phase space and Fock space
https://mrmustard.readthedocs.io/
Apache License 2.0
78 stars 25 forks source link

Adding classical wires #456

Closed apchytr closed 1 month ago

apchytr commented 1 month ago

Context: It is apparent that Mr Mustard requires some notion of 'classical wire' to support both the new poly exp ansatz as well as measurements. Here, I introduce classical_output and classical_input (or some other name we can agree upon) into Wires that is meant to fill this role. The idea is that Wires will keep track of the modes that contain this classical information (associating it with an index and unique ID) and the representation will do the rest (in a followup PR).

Description of the Change: Wires now accepts classical_output and classical_input meant to fill the role of non-quantum wires. The behaviour (within Wires) is identical to bra and ket.

Benefits: We will now be able to link classical information between circuit components. This approach avoids the need to introduce several new Wires classes.

Possible Drawbacks: It's possible there are some use cases that may require us to reconsider this approach? Maybe it turns out we really do need separate classes (i.e ClassicalWire, QuantumWire, PolyWire).

codecov[bot] commented 1 month ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 89.12%. Comparing base (3842246) to head (1f5954f). Report is 1 commits behind head on develop.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## develop #456 +/- ## =========================================== + Coverage 89.10% 89.12% +0.01% =========================================== Files 101 101 Lines 7051 7059 +8 =========================================== + Hits 6283 6291 +8 Misses 768 768 ``` | [Files](https://app.codecov.io/gh/XanaduAI/MrMustard/pull/456?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=XanaduAI) | Coverage Δ | | |---|---|---| | [mrmustard/lab\_dev/wires.py](https://app.codecov.io/gh/XanaduAI/MrMustard/pull/456?src=pr&el=tree&filepath=mrmustard%2Flab_dev%2Fwires.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=XanaduAI#diff-bXJtdXN0YXJkL2xhYl9kZXYvd2lyZXMucHk=) | `99.18% <100.00%> (+0.05%)` | :arrow_up: | ------ [Continue to review full report in Codecov by Sentry](https://app.codecov.io/gh/XanaduAI/MrMustard/pull/456?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=XanaduAI). > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=XanaduAI) > `Δ = absolute (impact)`, `ø = not affected`, `? = missing data` > Powered by [Codecov](https://app.codecov.io/gh/XanaduAI/MrMustard/pull/456?dropdown=coverage&src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=XanaduAI). Last update [3842246...1f5954f](https://app.codecov.io/gh/XanaduAI/MrMustard/pull/456?dropdown=coverage&src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=XanaduAI). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=XanaduAI).
timmysilv commented 1 month ago

I'm a bit late to the game here, but widgets.wires() should probably be updated to draw the classical wires as well - it can be done in another PR, not a big deal