Quantum Computing Asked on March 20, 2021
I am trying to evolve a quantum state through a PauliTrotterEvolution
in aqua and I’m trying to do so by initializing a random state, by using random_statevector
from qiskit.quantum_info
.
My code:
op=get_hamiltonian(-1,h) # a 4 qubit operator
evo_op=(t*op).exp_i()
evo_op=evo_op
trotter_op=PauliTrotterEvolution(trotter_mode=Suzuki(reps=10,order=1)).convert(evo_op)
qinstance=QuantumInstance(backend=Aer.get_backend("qasm_simulator"), shots=2048)
sampler=CircuitSampler(qinstance)
trotter_op=trotter_op @ StateFn(state)
results1=sampler.convert(trotter_op).primitive
The error
this returns the following error: ValueError: Qiskit circuit Initializer cannot handle non-positive statevectors.
however, by the source code, the Initializer
comes from qiskit.extensions
which I believe is from this .py file (file) whose docstring states:
"""Complex amplitude initialization.
Class that implements the (complex amplitude) initialization of some
flexible collection of qubit registers (assuming the qubits are in the
zero state).
Note that Initialize is an Instruction and not a Gate since it contains a reset instruction,
which is not unitary.
"""
what am I missing?
This seems to be a bug on the Circuit_state_fn
. I added a Issue on the aqua github repo: https://github.com/Qiskit/qiskit-aqua/issues/1276, thus in order to solve the problem you should pass the if statement on circuit_state_fn.py:
if not np.all(np.abs(statevector) == statevector):
# TODO maybe switch to Isometry?
raise ValueError('Qiskit circuit Initializer cannot handle non-positive statevectors.')
Correct answer by Nahum on March 20, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP