-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Should we make circuit._prev_moment_available
given impact of CCOs ?
#4976
Comments
As a stretch goal, we should also find all existing usages of |
To my absolute surprise, we only have a single usage of >>> grep -RI 'prev_moment_operating_on' [^.]*/** | grep -v '_test.py'
cirq-core/cirq/circuits/circuit.py: * prev_moment_operating_on
cirq-core/cirq/circuits/circuit.py: def prev_moment_operating_on(
cirq-core/cirq/circuits/circuit.py: * prev_moment_operating_on
cirq-core/cirq/optimizers/synchronize_terminal_measurements.py: moment_index = cast(int, circuit.prev_moment_operating_on((qubit,)))
cirq-core/cirq/transformers/transformer_primitives.py: idx = ret_circuit.prev_moment_operating_on(tuple(op_qs))
cirq-core/cirq/transformers/transformer_primitives.py: idx = ret_circuit.prev_moment_operating_on(tuple(op_qs)) Filed #4977 to investigate and fix breakages in |
I like making |
Can you give an example where taking an operation as input might be too limiting? Circuits only support inserting operations and when asking the previous moment available for insertion, it seems natural to me to take an operation as input. |
This is a fair point - all cases I can come up with eventually want to add an operation anyways, so just using that operation for the check should be fine. The main reason I raised this is that an operation is strictly more information than the method needs. Taking an operation forces creating a dummy op (e.g. |
I agree. Maybe we can make this public as it is now and go through a deprecation cycle once we identify need for cases where an operation is not needed? |
Description of the issue
While editing circuits, we often used
circuit.prev_moment_operating_on(op.qubits, end_moment_index)
to identify the position after which operationop
can be inserted. This, however, is no longer correct and can lead to subtle errors, like the one came up during review of #4944For ex:
We should either update (add a flag?) to
prev_moment_operating_on
s.t. it takes care of CCOs or make_prev_moment_available
a public method.cc @95-martin-orion @daxfohl
Cirq version
0.14dev
The text was updated successfully, but these errors were encountered: