-
Notifications
You must be signed in to change notification settings - Fork 188
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adjusting UI for measurement on several modes #403
Comments
Also worth mentioning that while this is unintuitive, it is also expected behaviour; the backend API was designed such that after a measurement operation, the mode is always traced out and replaced with the vacuum state. This allows the state to be re-used without needing to add additional modes to the system, which might be costly. I propose that we simply modify the compilers such that terminal measurements of a program (e.g, those that are 'dangling' nodes of the DAG with no other operations depending on them) are compiled into a single measurement result. That is, Sgate(0.5) | q[0]
MeasureX | q[0]
S2gate(q[0].par) | (q[0], q[1])
MeasureFock() | q[0]
Xgate(0.5) | q[2]
MeasureFock() | q[1]
MeasureX | q[2] would be compiled to give Sgate(0.5) | q[0]
MeasureX | q[0]
S2gate(q[0].par) | (q[0], q[1])
Xgate(0.5) | q[2]
MeasureFock() | (q[0], q[1])
MeasureX | q[2] where the two terminal fock measurements are combined, but the non-terminal |
Hi @antalszava and @josh146 ! I would like to work on this issue 🤗 |
Hi @felipeoyarce, nice! Feel free to open a WIP PR, and ask any questions as they arise :) |
Issue description
Strawberry Fields allows having multi-mode measurements in a
Program
by having measurement operators targetting several registers that reference the modes to be measured.Within the definition of a program, this means having
MeasurementOperator | (q[0], q[1], q[2], ...)
, whereq[0], q[1], ...
refer to the registers of the modes to be measured.Intuitively, one could want to define the same measurement by having consecutive measurement operators targetting a single register in the following fashion:
Specific example
Let's have a look at a specific example, where it is expected to see correlation between the outcomes for each mode
can result in an output like:
Program
definition:which can result in an output like:
With the second example, mode
q[0]
gets reinitialized to the vacuum state after being measured.Expected behavior:
The previous two code snippets both output samples where the samples for each run of the program are correlated.
Actual behavior:
There is a correlation between samples of the two modes for each run of the program only for the first code example.
Reproduces how often:
Each time.
System information:
Additional information
This would most likely include a change in how compilers handle measurement operators and introduce logic so that compilers will automatically group measurements that are terminal.
The text was updated successfully, but these errors were encountered: