Skip to content
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

[WIP] Commutation function and commutation DAG #1446

Closed
wants to merge 8 commits into from

Conversation

rmoyard
Copy link
Contributor

@rmoyard rmoyard commented Jul 2, 2021

Context:

This PR adds a commutation (pairwise) representation of quantum circuits. This is useful for applying different optimization algorithms (template matching, peephole optimization) that need commutation structure of the circuits.

Paper More details about the DAG in section 2.2

Description of the Change:

This PR adds a

  1. Function is_commuting checks if two operations commute, it does not use matrices multiplications but a truth table. Each operations has now attributes is_controlled and target_operation. Each operation has also functions that return control wires and target wires control_wires() target_wires(). Those new attributes and functions are useful for determining commutation between operations.
  2. [WIP] A DAG that represents the pairwise commutation structure of the quantum circuit.
x = np.array([0.1, 0.2])

dev = qml.device('default.qubit', wires=2)
@qml.qnode(dev)
def circuit(x):
    qml.RX(x[0], wires=0)
    qml.CNOT(wires=(0,1))
    qml.RX(x[1], wires=0)
    return qml.probs(wires=(0,1))

qml.commutation_dag(circuit)(x)

Benefits:
A commutation function that does not use matrices multiplication and takes any two operations as inputs. A new DAG that represents the commutation structure of quantum circuits and is useful for quantum circuits optimization.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WIP 🚧 Work-in-progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant