qiboteam / qibo

A framework for quantum computing
https://qibo.science
Apache License 2.0
287 stars 58 forks source link

Add `gates.CNOT` as a native gate in gate decomposition #1422

Closed csookim closed 1 month ago

csookim commented 1 month ago

This covers issue #1421.

Checklist:

csookim commented 1 month ago

Example

circ = Circuit(2)
circ.add(gates.H(0))
circ.add(gates.CNOT(0, 1))
circ.add(gates.SWAP(0, 1))
circ.add(gates.CZ(0, 1))
circ.add(gates.M(0, 1))

gate_list = [gates.GPI2, gates.RZ, gates.Z, gates.M, gates.CNOT]
native_gates = NativeGates(0).from_gatelist(gate_list)

custom_pipeline = Passes([Unroller(native_gates=native_gates)])
unrolled_circuit, _ = custom_pipeline(circ)

print(unrolled_circuit.draw(line_wrap=100))

Output

q0: ─Z─GPI2─o─o─X─o────────o────────M─
q1: ────────X─X─o─X─Z─GPI2─X─Z─GPI2─M─
alecandido commented 1 month ago

Btw, why are you deleting Codecov comments? Just out of curiosity (the checks in the workflows are still there; so it's just a different in appearance, but no substantial change, so it's even fine)

image
codecov[bot] commented 1 month ago

Codecov Report

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

Project coverage is 99.94%. Comparing base (8fb9af9) to head (3281871). Report is 24 commits behind head on master.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #1422 +/- ## ======================================= Coverage 99.94% 99.94% ======================================= Files 78 78 Lines 11297 11304 +7 ======================================= + Hits 11291 11298 +7 Misses 6 6 ``` | [Flag](https://app.codecov.io/gh/qiboteam/qibo/pull/1422/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiboteam) | Coverage Δ | | |---|---|---| | [unittests](https://app.codecov.io/gh/qiboteam/qibo/pull/1422/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiboteam) | `99.94% <100.00%> (+<0.01%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiboteam#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

csookim commented 1 month ago

Btw, why are you deleting Codecov comments? Just out of curiosity (the checks in the workflows are still there; so it's just a different in appearance, but no substantial change, so it's even fine)

image

I deleted it to avoid confusion, as the removed one was the coverage of the previous code. Will it be updated automatically?

alecandido commented 1 month ago

I deleted it to avoid confusion, as the removed one was the coverage of the previous code. Will it be updated automatically?

Indeed, if you leave it there it will edit the same comment, instead of adding a new one :)