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

Performance difference for generating the unitary of a circuit using AerSimulator vs quantum_info.Operator #2170

Open
ACE07-Sev opened this issue Jun 9, 2024 · 3 comments

Comments

@ACE07-Sev
Copy link

Informations

  • Qiskit AER version: 0.14.2
  • Operating system: WSL : Ubuntu

Greetings there,

Hope all are well. I had a quick question I was hoping to ask. I understand there are two ways we can generate the unitary of a circuit. One is using qiskit.quantum_info.Operator, and the other is using AerSimulator like so:

# Construct quantum circuit without measure
circ = QuantumCircuit(2)
circ.h(0)
circ.cx(0, 1)
circ.save_unitary()

# Transpile for simulator
simulator = AerSimulator(method = 'unitary')
circ = transpile(circ, simulator)

# Run and get unitary
result = simulator.run(circ).result()
unitary = result.get_unitary(circ)
print("Circuit unitary:\n", np.asarray(unitary).round(5))

I was wondering what the main difference between the two approaches is, and if someone wants to generate the unitary (which is admittedly an expensive operation as we have to contract all the gates together) if they can do so using GPU (and whether this is then only doable with AerSimulator and thus the difference).

@doichanj
Copy link
Collaborator

I think it is better to use qiskit.quantum_info for smaller number of qubits, but Aer is suitable to make large unitary matrix, because Aer has some overheads. I think if you want to make > 7qubits unitary matrix, Aer will be faster

@ACE07-Sev
Copy link
Author

I see. Would I be able to get the unitary matrix using GPU as a device when using Aer?

@doichanj
Copy link
Collaborator

Yes, you can use GPU by setting option device=GPU

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

No branches or pull requests

2 participants