Bug in the Hello world noise simulation with large fake backends
URL to the relevant tutorial
URL: https://quantum.cloud.ibm.com/docs/en/tutorials/hello-world Section : Step 3. Execute using the quantum primitives Box: Alternative: run the example using a simulator
Select all that apply
- [ ] new content request
- [ ] typo
- [x] code bug
- [ ] out-of-date content
- [ ] broken link
- [x] other
Describe the fix or the content request.
As it stands, the code in the Hello world tutorial produces the following bug in the noise simulation section (Alternative: run the example using a simulator):
BasicProviderError: 'Number of qubits 156 is greater than maximum (24) for "basic_simulator".'
The issue in the code is that it is using a fake backend with more than 24 qubits. However, the actual problem in the tutorial is that it does not mention installing Qiskit Aer which would solve the bug without explicitly changing the code.
I suggest simply adding a box/statement that tells the user that Qiskit Aer is required for that section (specifically to run large fake backends).
For completeness, this has already been mentioned in the closed #1125 issue.
These are the relevant package versions I am using:
with bug
qiskit==2.2.1
qiskit-ibm-runtime==0.43.0
WITHOUT bug
qiskit==2.2.1
qiskit-ibm-runtime==0.43.0
qiskit-aer==0.17.2
For new content requests - if the request is accepted, do you want to write the content?
I will write (or already have written) a draft of the proposed content
Thank you for opening this issue @Belaloui! - we will notify here once it is fixed.
Closing, as it doesn't look like this is an actual issue. The code for running on a noisy simulator is related to the small scale example (and supposed to be executed with the corresponding circuit/observables). The large scale example doesn't have a corresponding noisy simulation example as you might expect.
@miamico, The issue is there with the small scale (2-qubit) example as well. Without Qiskit Aer installed, the following code--from Alternative: run the example using a simulator and directly following the small-scale example--doesn't work:
from qiskit import QuantumCircuit
from qiskit.quantum_info import SparsePauliOp
from qiskit.transpiler import generate_preset_pass_manager
from qiskit_ibm_runtime import EstimatorV2 as Estimator
from qiskit_ibm_runtime.fake_provider import FakeFez
# Two qubits example
qc = QuantumCircuit(2)
qc.h(0)
qc.cx(0, 1)
observables_labels = ["IZ", "IX", "ZI", "XI", "ZZ", "XX"]
observables = [SparsePauliOp(label) for label in observables_labels]
# Noisy simulation for the 2-qubit example
# From "Alternative: run the example using a simulator"
backend = FakeFez()
estimator = Estimator(backend)
pm = generate_preset_pass_manager(backend=backend, optimization_level=1)
isa_circuit = pm.run(qc)
mapped_observables = [
observable.apply_layout(isa_circuit.layout) for observable in observables
]
job = estimator.run([(isa_circuit, mapped_observables)])
result = job.result()
...
>>> BasicProviderError: 'Number of qubits 156 is greater than maximum (24) for "basic_simulator".'
This is using the same environment as stated above.
qiskit==2.2.1
qiskit-ibm-runtime==0.43.0
Fixing this is simply a matter of installing Qiskit Aer to handle the large number of qubits of the fake backend, with no changes to the example code.
I believe @kaelynj said she was going to take a look at this, as far as Aer goes - will reopen for now