I am doing a VQE in Cirq, but sometimes I get this error while running steps of the classical optimization loop: State_vector is not normalized instead had norm 1.0000000010132789 And therefore the program interrupts.

Is there anything I can do to avoid this? Because my state should be normalized the way I constructed the circuit.

  • 1
    $\begingroup$ Is there anything preventing you from calling something like state_vector = state_vector / np.linalg.norm(state_vector) in your feedback loop? Also this question is probably better suited for the cirq github or gitter site: gitter.im/cirqdev $\endgroup$
    – forky40
    Commented Apr 21, 2021 at 19:48
  • $\begingroup$ @forky40 Speaking as a cirq dev, quantum stack exchange is an excellent place for this type of question. $\endgroup$ Commented Apr 22, 2021 at 17:32
  • 1
    $\begingroup$ What method are you calling that throws the exception? VQE normally only works with gates and samples, no state vectors, so I'm not sure if you're specifying an initial state or analyzing a returned state. In both cases, manually normalizing the state should work but I want to be sure there's not something more serious hiding. $\endgroup$ Commented Apr 22, 2021 at 17:34
  • $\begingroup$ @CraigGidney I guess. This feels like it falls in the grey area of a question about a software implementation not behaving in the expected way where the root of the problem and its resolution only involve domain knowledge of qc in a tangential way. But I haven't found any community consensus on such questions so i could be wrong. $\endgroup$
    – forky40
    Commented Apr 22, 2021 at 19:26
  • 1
    $\begingroup$ @forky40 It's a question about how to use software for simulating quantum computations. That seems right on topic to me. $\endgroup$ Commented Apr 22, 2021 at 19:51


Your Answer

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

Browse other questions tagged or ask your own question.