Skip to main content

Aer - High performance simulators for Qiskit

Project description

Aer - high performance quantum circuit simulation for Qiskit

License Build Tests

Aer is a high performance simulator for quantum circuits written in Qiskit, that includes realistic noise models.

Installation

We encourage installing Aer via the pip tool (a python package manager):

pip install qiskit-aer

Pip will handle all dependencies automatically for us, and you will always install the latest (and well-tested) version.

To install from source, follow the instructions in the contribution guidelines.

Installing GPU support

In order to install and run the GPU supported simulators on Linux, you need CUDA® 11.2 or newer previously installed. CUDA® itself would require a set of specific GPU drivers. Please follow CUDA® installation procedure in the NVIDIA® web.

If you want to install our GPU supported simulators, you have to install this other package:

pip install qiskit-aer-gpu

The package above is for CUDA&reg 12, so if your system has CUDA® 11 installed, install separate package:

pip install qiskit-aer-gpu-cu11

This will overwrite your current qiskit-aer package installation giving you the same functionality found in the canonical qiskit-aer package, plus the ability to run the GPU supported simulators: statevector, density matrix, and unitary.

Note: This package is only available on x86_64 Linux. For other platforms that have CUDA support, you will have to build from source. You can refer to the contributing guide for instructions on doing this.

Simulating your first Qiskit circuit with Aer

Now that you have Aer installed, you can start simulating quantum circuits using primitives and noise models. Here is a basic example:

$ python
from qiskit import transpile
from qiskit.circuit.library import RealAmplitudes
from qiskit.quantum_info import SparsePauliOp
from qiskit_aer import AerSimulator

sim = AerSimulator()
# --------------------------
# Simulating using estimator
#---------------------------
from qiskit_aer.primitives import EstimatorV2

psi1 = transpile(RealAmplitudes(num_qubits=2, reps=2), sim, optimization_level=0)
psi2 = transpile(RealAmplitudes(num_qubits=2, reps=3), sim, optimization_level=0)

H1 = SparsePauliOp.from_list([("II", 1), ("IZ", 2), ("XI", 3)])
H2 = SparsePauliOp.from_list([("IZ", 1)])
H3 = SparsePauliOp.from_list([("ZI", 1), ("ZZ", 1)])

theta1 = [0, 1, 1, 2, 3, 5]
theta2 = [0, 1, 1, 2, 3, 5, 8, 13]
theta3 = [1, 2, 3, 4, 5, 6]

estimator = EstimatorV2()

# calculate [ [<psi1(theta1)|H1|psi1(theta1)>,
#              <psi1(theta3)|H3|psi1(theta3)>],
#             [<psi2(theta2)|H2|psi2(theta2)>] ]
job = estimator.run(
    [
        (psi1, [H1, H3], [theta1, theta3]),
        (psi2, H2, theta2)
    ],
    precision=0.01
)
result = job.result()
print(f"expectation values : psi1 = {result[0].data.evs}, psi2 = {result[1].data.evs}")

# --------------------------
# Simulating using sampler
# --------------------------
from qiskit_aer.primitives import SamplerV2
from qiskit import QuantumCircuit

# create a Bell circuit
bell = QuantumCircuit(2)
bell.h(0)
bell.cx(0, 1)
bell.measure_all()

# create two parameterized circuits
pqc = RealAmplitudes(num_qubits=2, reps=2)
pqc.measure_all()
pqc = transpile(pqc, sim, optimization_level=0)
pqc2 = RealAmplitudes(num_qubits=2, reps=3)
pqc2.measure_all()
pqc2 = transpile(pqc2, sim, optimization_level=0)

theta1 = [0, 1, 1, 2, 3, 5]
theta2 = [0, 1, 2, 3, 4, 5, 6, 7]

# initialization of the sampler
sampler = SamplerV2()

# collect 128 shots from the Bell circuit
job = sampler.run([bell], shots=128)
job_result = job.result()
print(f"counts for Bell circuit : {job_result[0].data.meas.get_counts()}")
 
# run a sampler job on the parameterized circuits
job2 = sampler.run([(pqc, theta1), (pqc2, theta2)])
job_result = job2.result()
print(f"counts for parameterized circuit : {job_result[0].data.meas.get_counts()}")

# --------------------------------------------------
# Simulating with noise model from actual hardware
# --------------------------------------------------
from qiskit_ibm_runtime import QiskitRuntimeService
provider = QiskitRuntimeService(channel='ibm_quantum', token="set your own token here")
backend = provider.get_backend("ibm_kyoto")

# create sampler from the actual backend
sampler = SamplerV2.from_backend(backend)

# run a sampler job on the parameterized circuits with noise model of the actual hardware
bell_t = transpile(bell, AerSimulator(basis_gates=["ecr", "id", "rz", "sx"]), optimization_level=0)
job3 = sampler.run([bell_t], shots=128)
job_result = job3.result()
print(f"counts for Bell circuit w/noise: {job_result[0].data.meas.get_counts()}")

Contribution Guidelines

If you'd like to contribute to Aer, please take a look at our contribution guidelines. This project adheres to Qiskit's code of conduct. By participating, you are expected to uphold this code.

We use GitHub issues for tracking requests and bugs. Please use our slack for discussion and simple questions. To join our Slack community use the link. For questions that are more suited for a forum, we use the Qiskit tag in the Stack Exchange.

Next Steps

Now you're set up and ready to check out some of the other examples from the Aer documentation.

Authors and Citation

Aer is the work of many people who contribute to the project at different levels. If you use Qiskit, please cite as per the included BibTeX file.

License

Apache License 2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

qiskit_aer_gpu_cu11-0.17.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (18.1 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

qiskit_aer_gpu_cu11-0.17.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (18.1 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

qiskit_aer_gpu_cu11-0.17.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (18.1 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

qiskit_aer_gpu_cu11-0.17.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (18.1 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

qiskit_aer_gpu_cu11-0.17.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (18.1 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

File details

Details for the file qiskit_aer_gpu_cu11-0.17.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for qiskit_aer_gpu_cu11-0.17.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2684a4bf8dc719157ba24046a22d749842abdfe1a9f30a3d9b47b732aedf2892
MD5 6a1f9276e3b43b86b9201b64f2cdae2f
BLAKE2b-256 0ab59d1ffd28eeb2c7993d773467a776826cad52f1174dd97c7782c235de990a

See more details on using hashes here.

Provenance

The following attestation bundles were made for qiskit_aer_gpu_cu11-0.17.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: deploy.yml on Qiskit/qiskit-aer

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file qiskit_aer_gpu_cu11-0.17.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for qiskit_aer_gpu_cu11-0.17.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3f716884f326f2a6fdcd37e212358bc77b74c797cc36a84045a79f7cc7263f5d
MD5 fe04e88f8ac001fc86bb5a1ba93e55de
BLAKE2b-256 99182c545d628f5c1999cdcecbdf85d6185d552934b7026acce3d7621165c872

See more details on using hashes here.

Provenance

The following attestation bundles were made for qiskit_aer_gpu_cu11-0.17.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: deploy.yml on Qiskit/qiskit-aer

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file qiskit_aer_gpu_cu11-0.17.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for qiskit_aer_gpu_cu11-0.17.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 19533ea3366d386eed91f240ebb34358fa6d7c22602d7975597ce72fd0bf3c3c
MD5 fc5d13d2e1bd3a06c5c206bc02e67464
BLAKE2b-256 b29ce5d246172e8309ca798d37890def202b02b0602a45b5a74a413398048d97

See more details on using hashes here.

Provenance

The following attestation bundles were made for qiskit_aer_gpu_cu11-0.17.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: deploy.yml on Qiskit/qiskit-aer

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file qiskit_aer_gpu_cu11-0.17.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for qiskit_aer_gpu_cu11-0.17.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a50ebd49e320d78d0e816a7c22d2a4e0bb4f8bdb01a10f10352833e93b86e7a9
MD5 ebaf3d180759e1043d294badf06c2af1
BLAKE2b-256 12f820889776ccad4cb930e2cd19ef767099f77f2831613f0344d6e21dc27909

See more details on using hashes here.

Provenance

The following attestation bundles were made for qiskit_aer_gpu_cu11-0.17.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: deploy.yml on Qiskit/qiskit-aer

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file qiskit_aer_gpu_cu11-0.17.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for qiskit_aer_gpu_cu11-0.17.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8ff58c9f8ebcbe62f8a462f0282e00370859e495a1fe2cfae7b522b4ec2e0e3f
MD5 b939d7795534228b87c43a88f5db87cb
BLAKE2b-256 86187f6af558de9527fbc85086b8f97ce99ff53cb64bc7c00a161f3f5532160f

See more details on using hashes here.

Provenance

The following attestation bundles were made for qiskit_aer_gpu_cu11-0.17.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: deploy.yml on Qiskit/qiskit-aer

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page