BasicAer fails when shots requested exceeds a threshold
See original GitHub issueEnvironment
- Qiskit Terra version: 371a2bc2171c6b610c7aa56d60b51f45a0fa7bad
- Python version: 3.9.10
- Operating system: Arch Linux
What is happening?
The BasicAer simulator is failing when the number of shots exceeds some threshold.
How can we reproduce the issue?
from qiskit import BasicAer, QuantumCircuit
backend = BasicAer.get_backend('statevector_simulator')
circuit = QuantumCircuit(1)
circuit.x(0)
backend.run(circuit, shots=100000)
Output:
---------------------------------------------------------------------------
QiskitError Traceback (most recent call last)
Input In [1], in <module>
4 circuit = QuantumCircuit(1)
5 circuit.x(0)
----> 6 backend.run(circuit, shots=100000)
File ~/projects/qiskit-terra/qiskit/providers/basicaer/qasm_simulator.py:409, in QasmSimulatorPy.run(self, qobj, **backend_options)
407 else:
408 out_options[key] = backend_options[key]
--> 409 qobj = assemble(qobj, self, **out_options)
410 qobj_options = qobj.config
411 else:
File ~/projects/qiskit-terra/qiskit/compiler/assembler.py:172, in assemble(experiments, backend, qobj_id, qobj_header, shots, memory, max_credits, seed_simulator, qubit_lo_freq, meas_lo_freq, qubit_lo_range, meas_lo_range, schedule_los, meas_level, meas_return, meas_map, memory_slot_size, rep_time, rep_delay, parameter_binds, parametric_pulses, init_qubits, **run_config)
170 experiments = experiments if isinstance(experiments, list) else [experiments]
171 pulse_qobj = any(isinstance(exp, (ScheduleBlock, Schedule, Instruction)) for exp in experiments)
--> 172 qobj_id, qobj_header, run_config_common_dict = _parse_common_args(
173 backend,
174 qobj_id,
175 qobj_header,
176 shots,
177 memory,
178 max_credits,
179 seed_simulator,
180 init_qubits,
181 rep_delay,
182 qubit_lo_freq,
183 meas_lo_freq,
184 qubit_lo_range,
185 meas_lo_range,
186 schedule_los,
187 pulse_qobj=pulse_qobj,
188 **run_config,
189 )
191 # assemble either circuits or schedules
192 if all(isinstance(exp, QuantumCircuit) for exp in experiments):
File ~/projects/qiskit-terra/qiskit/compiler/assembler.py:327, in _parse_common_args(backend, qobj_id, qobj_header, shots, memory, max_credits, seed_simulator, init_qubits, rep_delay, qubit_lo_freq, meas_lo_freq, qubit_lo_range, meas_lo_range, schedule_los, pulse_qobj, **run_config)
325 raise QiskitError("Argument 'shots' should be of type 'int'")
326 elif max_shots and max_shots < shots:
--> 327 raise QiskitError(
328 "Number of shots specified: %s exceeds max_shots property of the "
329 "backend: %s." % (shots, max_shots)
330 )
332 dynamic_reprate_enabled = getattr(backend_config, "dynamic_reprate_enabled", False)
333 if dynamic_reprate_enabled:
QiskitError: 'Number of shots specified: 100000 exceeds max_shots property of the backend: 65536.'
What should happen?
BasicAer should not have a shot limit.
Any suggestions?
No response
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Source code for qiskit.providers.basicaer.qasm_simulator
Source code for qiskit.providers.basicaer.qasm_simulator ... contain a 'memory' data field, which is a result of measurements for each shot.
Read more >Maximum number of qubits supported by the Qasm simulator
basicaer.exceptions.BasicAerError: 'Number of qubits 40 is greater than maximum (24) for "qasm_simulator'.
Read more >Release 0.17.1 Tech Team @ Unitary Fund
Mitiq is a Python toolkit for implementing error mitigation techniques on quantum computers. Current quantum computers are noisy due to ...
Read more >A Comprehensive Study of Bug Fixes in Quantum Programs
poor performance when a threshold level of performance ... from qiskit import execute, IBMQ, BasicAer ... required to fix it.
Read more >FAQs | NSF Cash Management
to submit cash requests and adjustments to open and closed awards on a grant ... the net total of your ACM$ transaction must...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
In backendv2 you don’t have to define a limit, it’s validated in the
Options
object’s validators when you try to update the value. If you don’t set a validator it doesn’t check anything and any value can be used. But yeah in BackendV1 it is a required integer field in theBackendConfiguration
It should be fixed by https://github.com/Qiskit/qiskit-terra/pull/7801. @alejomonbar please add the line “Fixes #7634” to the opening post there.