♨️
Qiskit Aer 0.7.0からbackend_optionsの指定方法が変わったので,その対策
backend_options
使っていたのですが,
DeprecationWarning: Using `backend_options` kwarg has been deprecated as of qiskit-aer 0.7.0 and will be removed no earlier than 3 months from that release date. Runtime backend options should now be added directly using kwargs for each option.
と怒られていたのを放置してたら,ついに使えなくなってしまいました. added directly
ってどうすればいいのかわからなかったので,対策を調べました.
結論
使える指定方法と使えないようになった指定方法を載せます.
StatevectorSimulator
はQasmSimulator
など,好きなSimulatorに変更してください.
-
StatevectorSimulator
:
https://qiskit.org/documentation/stubs/qiskit.providers.aer.StatevectorSimulator.html#qiskit.providers.aer.StatevectorSimulator -
QasmSimulaotr
:
https://qiskit.org/documentation/stubs/qiskit.providers.aer.QasmSimulator.html#qiskit.providers.aer.QasmSimulator
import qiskit
from qiskit import QuantumRegister, QuantumCircuit, ClassicalRegister, Aer
from qiskit.providers.aer import QasmSimulator, StatevectorSimulator
q = QuantumRegister(2)
circ = QuantumCircuit(q)
#使える
job = qiskit.execute(circ, StatevectorSimulator(backend_options={"method": "statevector_gpu"}))
#使える
# job = qiskit.execute(circ, StatevectorSimulator())
#使えなくなった!!
# job = qiskit.execute(circ, Aer.get_backend('statevector_simulator'), backend_options={"method": "statevector_gpu"})
#使える
# job = qiskit.execute(circ, Aer.get_backend('statevector_simulator'))
result = job.result()
state = result.get_statevector(circ, decimals=5)
state
Discussion