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

qinstance=QuantumInstance(backend=Aer.get_backend("qasm_simulator"), shots=2048)

trotter_op=trotter_op @ StateFn(state)

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?


1 Answer 1


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.')   

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.