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

Add support for ECR gate to MPS #2137

Merged
merged 8 commits into from
May 29, 2024
Merged

Add support for ECR gate to MPS #2137

merged 8 commits into from
May 29, 2024

Conversation

doichanj
Copy link
Collaborator

@doichanj doichanj commented May 13, 2024

Summary

Fixes #2118

Details and comments

  • Add native support of ECR gate in MPS and extended_stabilizer methods
  • (Also added for tensor_network method that was supported but not in basis_gates)
  • Add check of basis_gates passed to backend options if there is unsupported gate for the method
  • Fix test case for ECR gate

@doichanj doichanj added stable-backport-potential The issue or PR might be minimal and/or import enough to backport to stable Changelog: New Feature Include in the Added section of the changelog Changelog: Bugfix Include in the Fixed section of the changelog labels May 13, 2024
@doichanj doichanj requested a review from hhorii May 13, 2024 06:55
@@ -85,6 +86,7 @@ const AER::stringmap_t<Gatetypes> gate_types_ = {
{"cx", Gatetypes::clifford}, // Controlled-X gate (CNOT)
{"cz", Gatetypes::clifford}, // Controlled-Z gate
{"swap", Gatetypes::clifford}, // SWAP gate
{"ecr", Gatetypes::clifford}, // ECR Gate
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, I am a junior in the realm of Quantum, Just out of curiosity, Is ECR gate a clifford gate ?

BaseState::qreg_.apply_h(op.qubits[1], rank);
BaseState::qreg_.apply_cx(op.qubits[0], op.qubits[1], rank);
BaseState::qreg_.apply_x(op.qubits[0], rank);
BaseState::qreg_.apply_x(op.qubits[1], rank);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This implementation differs to ecr by a -pi/4 global phase. is it generally ok ?

Copy link
Contributor

@enum-class enum-class May 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I am not mistaken this one doesn't have phase difference

qc.h(1)
qc.cx(0, 1)
qc.t(1)
qc.cx(0, 1)
qc.x(0)
qc.cx(0, 1)
qc.tdg(1)
qc.cx(0, 1)
qc.h(1)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I coped from stabilizer

case Gates::ecr:
BaseState::qreg_.append_h(op.qubits[1]);
BaseState::qreg_.append_s(op.qubits[0]);
BaseState::qreg_.append_z(op.qubits[1]); // sdg(1)
BaseState::qreg_.append_s(op.qubits[1]); // sdg(1)
BaseState::qreg_.append_h(op.qubits[1]);
BaseState::qreg_.append_cx(op.qubits[0], op.qubits[1]);
BaseState::qreg_.append_x(op.qubits[0]);
BaseState::qreg_.append_x(op.qubits[1]);

But it seems it was not correct, ad I get correct circuit by using transpiler

from qiskit import transpile
from qiskit import QuantumCircuit
from qiskit_aer import AerSimulator
sim = AerSimulator(basis_gates = ["h", "cx", "x", "s", "z"])
qc = QuantumCircuit(2)
qc.ecr(0, 1)
qc = transpile(qc,backend=sim,optimization_level=0)
qc.draw('mpl')

image

I will fix by using this circuit

@doichanj doichanj mentioned this pull request May 23, 2024
hhorii
hhorii previously approved these changes May 24, 2024
@doichanj doichanj merged commit 0e7d658 into Qiskit:main May 29, 2024
38 checks passed
@zlatko-minev
Copy link

Great thank you

doichanj added a commit to doichanj/qiskit-aer that referenced this pull request May 30, 2024
* Add support for ECR gate

* replace is not to !=

* fix release note

* Fix ecr implementation for stabilizer/extended-stabilizer
doichanj added a commit that referenced this pull request May 31, 2024
* release 0.14.2

* Disable test shot_branching on MacOS (#2143)

* remove test_shot_branching

* disable sho_branching tests on MacOS

* fix test

* fix test

* format

* fix test_shot_branching

* fix test_runtime_parameterization

* fix tests for the latest Qiskit (#2138)

* Remove qiskit aer translation stage (#2142)

This commit removes the qiskit aer translation plugin. This was added as
a workaround for a Qiskit/qiskit#11351. This has been fixed in Qiskit
since 0.45.2 and is no longer necessary. The mechanism by which the
workaround worked was unsound in practice as it was mutating the target
and also explicitly using private attributes of the Target. This is
causing real issues now as it only worked by assuming the target wasn't
shared between passmanagers which is never guaranteed. Similarly the
reliance on internal private attributes of the Target class will cause
issues in the future when the target internals change (see
Qiskit/qiskit#12292). This commit opts to remove the plugin in its
entirity as it's no longer necessary and actively causing issues with
Qiskit 1.1 and transpiling targeting aer backends with >1 circuit. As
it's private internal detail there isn't a release note.

Fixes Qiskit/qiskit#12425
Fixes #2141

* Fix issue 2084 again (#2119)

* Fix issue 2084 again

* format

* fix test

* fix test

* Always hook omp functions in Mac (#2128)

* always hook omp functions in Mac

* fix recent test failures with the latest qiskit

---------

Co-authored-by: Jun Doi <[email protected]>

* Add simulator_metadata in metadata of SamplerV2 (#2109)

Co-authored-by: Hiroshi Horii <[email protected]>

* Fix cuStateVec_enable option (#2146)

* Fix cuStateVec_enable option

* fix function name

* Add support for rotation gates (#2147)

* add rotation gates

* add cr* gates to operations.hpp

* fix test for stabilkize/extended-stabilizer

* fix test again

* Fix deterministic measure of stabilizer (#2132)

* Fix deterministic measure of stabilizer

* fix accumulation in loop

* format

---------

Co-authored-by: Hiroshi Horii <[email protected]>

* Fix init of EstimatorV2 and SamplerV2 (#2120)

* fix init of EstimatorV2 and SamplerV2 to handle method

* add release note

* fix from_backend and example in README

* remove setting density_matrix

* Fix deploy.yml (#2110)

Co-authored-by: Hiroshi Horii <[email protected]>
Co-authored-by: Luciano Bello <[email protected]>

* Add support for ECR gate to MPS (#2137)

* Add support for ECR gate

* replace is not to !=

* fix release note

* Fix ecr implementation for stabilizer/extended-stabilizer

* Handle gates with ctrl_stete=0 (#2148)

* handle cx gate with ctrl_stete=0

* add handling *_o0, add test for cx_o0

* format

* fix test

* fix test

* fix test cx

* fix to handle multiple control states

* fix ctrl_state

* format

* resolve conflict again

* fix aer_compiler

* fix random seed (#2151)

Co-authored-by: Hiroshi Horii <[email protected]>

* Move delay gate to custom instructions (#2153)

---------

Co-authored-by: Matthew Treinish <[email protected]>
Co-authored-by: Hiroshi Horii <[email protected]>
Co-authored-by: Luciano Bello <[email protected]>
Co-authored-by: Takashi Imamichi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: Bugfix Include in the Fixed section of the changelog Changelog: New Feature Include in the Added section of the changelog stable-backport-potential The issue or PR might be minimal and/or import enough to backport to stable
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Kernel dies when ECR in basis gate set for MPS
4 participants