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

Initialize with an integer parameter is not compatible with AerSimulator #1821

Closed
Cryoris opened this issue May 22, 2023 · 1 comment · Fixed by #1841
Closed

Initialize with an integer parameter is not compatible with AerSimulator #1821

Cryoris opened this issue May 22, 2023 · 1 comment · Fixed by #1841
Labels
bug Something isn't working
Milestone

Comments

@Cryoris
Copy link
Contributor

Cryoris commented May 22, 2023

Environment

  • Qiskit Terra version: main @ bedecbdce563f4e83acc11c7ec5ca6878a36a4b7
  • Python version: 3.10
  • Operating system: macOS

What is happening?

As reported in https://quantumcomputing.stackexchange.com/questions/32681/nonsensical-projection-of-initialized-qubits-in-qiskit, using the AerSimulator to run a circuit containing an Initialize instruction with an integer as parameter breaks, due to

Simulation failed and returned the following error message:
ERROR: Failed to load qobj: Invalid qobj "initialize" instruction ("params" is incorrect length).

How can we reproduce the issue?

from qiskit import QuantumCircuit, Aer, transpile

qc = QuantumCircuit(1)
qc(1, [0])  # initialize to integer 1     

backend = Aer.get_backend("aer_simulator")
tqc = transpile(fivequbitcircuit, backend)
job = backend.run(tqc, shots=1000)
result = job.result()

What should happen?

The Initialize instruction should be supported by Aer.

Any suggestions?

Not sure if this is something we should fix on the Terra side, as indeed the .params attribute it a list of length 1, which might be a bit confusing, or if this should be handled in Aer. The cleanest solution might be to convert the integer to a label in Terra's class, as that's already happening under the hood (and that's handled correctly by Aer).

@Cryoris Cryoris added the bug Something isn't working label May 22, 2023
@jakelishman
Copy link
Member

Officially this is a problem for Aer to deal with, but Terra really doesn't make it easy to support the Initialize operation for simulators. There's like 3 completely different forms that the params could be, which all have very different semantics.

@jakelishman jakelishman transferred this issue from Qiskit/qiskit May 23, 2023
@hhorii hhorii added this to the Aer 0.12.1 milestone May 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants