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

New commutation passes #1500

Merged
merged 16 commits into from
Dec 19, 2018
Merged

New commutation passes #1500

merged 16 commits into from
Dec 19, 2018

Conversation

godott
Copy link
Contributor

@godott godott commented Dec 15, 2018

Summary

  1. A commutation analysis pass and a commutation transformation are added.
  2. Test cases for commutation passes are added.
  3. An example is added.

Details and comments

The commutation analysis pass figures out the commutation relations for gates in DAGCircuit, all the 1&2 qubit gates are supported now.

Here are some examples:

1. Test all the gates

Circuit:

gate_test_circuit

DAG before:

gate_test_before

DAG after:

gate_test_after

2. An example of Quantum Instantaneous Polynomial Time(all gates commute)

Circuit:

qipt_circuit

DAG_before:

qipt_before

DAG_after:

qipt_after

3. Circuits produced by Jordan-Wigner transformation

Circuit:

jw_circuit

DAG before:

jw_before

DAG after:

jw_after

@jaygambetta
Copy link
Member

is nice that we show the dag before and after but can we also show the circuit. It would also be nice to have the circuit in the example

@godott
Copy link
Contributor Author

godott commented Dec 19, 2018

is nice that we show the dag before and after but can we also show the circuit. It would also be nice to have the circuit in the example

For that, I think a DAG_to_circuit() method is needed. Right now, we have functions to convert DAG to openQASM and convert openQASM to QuantumCircuit, but the two functions don't work together.

@ajavadia
Copy link
Member

is nice that we show the dag before and after but can we also show the circuit. It would also be nice to have the circuit in the example

For that, I think a DAG_to_circuit() method is needed. Right now, we have functions to convert DAG to openQASM and convert openQASM to QuantumCircuit, but the two functions don't work together.

you can use

from qiskit.converters import dag_to_circuit
circuit = dag_to_circuit(dag)
circuit.draw()

but i don't think drawing the circuit shows much. this pass modifies DAG edges, to make them more amenable to scheduling, optimization, etc. The circuit drawer may just move some boxes around.

@jaygambetta
Copy link
Member

@ajavadia and @godott i have already done that i push a pr into your branch dealing with some linting.

@jaygambetta jaygambetta merged commit ded732e into Qiskit:master Dec 19, 2018
@godott godott deleted the new-commutation-pass branch December 19, 2018 20:02
lia-approves pushed a commit to edasgupta/qiskit-terra that referenced this pull request Jul 30, 2019
* Passes implemented and test cases added

* example added

* add support to u1,u2,u3, and rz,rx,ry

* fix support for 1 qubit gates

* fix test cases

* update example

* update code to master, some linting

* changelog

* test is just testing analysis, rename and clean

* add license to files

* more linting fixes

* fix commutation detecction issue with 2 cnots s on same 2 wires

* fixed a bug that misidentify the commutation relations between two alternating CNOTs

* Linting and fixing test

* final lint style
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants