qiskit icon indicating copy to clipboard operation
qiskit copied to clipboard

Circuit contains invalid instructions {"gates": {sx}} for "extended_stabilizer" method

Open Yucheng-He opened this issue 3 years ago • 2 comments

Environment

  • Qiskit Terra version: 0.21.1
  • Python version: 3.8.11
  • Operating system: MacOS m1

What is happening?

When Running Clifford circuit, use extended_stabilizer. Simulation failed and returned the following error message: ERROR: [Experiment 0] Circuit contains invalid instructions {"gates": {sx}} for "extended_stabilizer" method.

When I try to place a barrier between Y gates, no error happens again. However, I wish to simulate Random Clifford circuit, with large depth. It will be too troublesome to insert barriers among so many gates.

image image

How can we reproduce the issue?

Here is my code: c = QuantumCircuit(4) c.h(range(4)) c.y([0]) c.barrier() c.y([0]) c.s([0]) c.draw()

extended_stabilizer_simulator = AerSimulator(method='extended_stabilizer') tc = transpile(c, extended_stabilizer_simulator) extended_stabilizer_result = extended_stabilizer_simulator.run(tc, shots=1).result() print('This succeeded?: {}'.format(extended_stabilizer_result.success))

What should happen?

The simulator should include sx gate to simulate any kind of Clifford circuits.

Any suggestions?

No response

Yucheng-He avatar Aug 08 '22 04:08 Yucheng-He

I have checked your code without the barrier and it seems to work. Here is the printout of the transpiled circuit tc: image Perhaps you should upgrade qiskit-aer?

ShellyGarion avatar Aug 08 '22 11:08 ShellyGarion

BTW, for running Clifford circuits you can use the stabilizer simulator, and don't need to use the extended_stabilizer simulator.

ShellyGarion avatar Aug 08 '22 11:08 ShellyGarion

The code works verbatim for me with and without the barrier with a recent Aer. Looks like Aer before 0.9 may have had a bug in extended_stabilizer that falsely lost the sx gate from the execution set, even though it was still listed as a basis gate (see Qiskit/qiskit-aer#1326 for the fix, even if that was a side-effect).

Hopefully updating your version of qiskit-aer to the most recent (0.10.4) should fix this. If not, please open an issue on Aer, since it would be a bug there.

jakelishman avatar Aug 16 '22 17:08 jakelishman