Open AlbertJP opened 2 years ago
FWIW: making a SummedOp (instead of TensoredOp) of a CircuitMeasurement and an OperatorMeasurement is not a problem.
Thanks for the report! Is there a reason you want to tensor the measurements instead of creating a measurement operator of the tensored operators (i.e. what you suggested in your second comment)?
Do you mean something like StateFn(op_1 ^ op_2, is_measurement=True)
?
This doesn't work either. If I replace line 20 by this:
state_fn = StateFn(StateFn(x0_circ) ^ StateFn(op), is_measurement=True) @ StateFn(state)
the same error appears.
I mean first construct the tensored operator and then convert it into a measurement by wrapping it with StateFn(..., is_measurement=True)
. So in your case this would be
state_fn = StateFn(CircuitOp(x0_circ) ^ op, is_measurement=True) @ StateFn(state)
🙂
Yes, that works. Thanks for the CircuitOp suggestion, that makes the difference here, it allows me to tensor both operators before creating the StateFn. Nevertheless, is it a bug that two measurements cannot be tensored or is this by design?
^ hit the wrong button by mistake, apologies
It seems to be a bug, because TensoredOp.eval
first calls self.to_matrix_op
, which will produce a TensoredOp
of matrices, and then calls eval
again. But since the type is still a TensoredOp
we call self.to_matrix_op
again and then eval
again.... and that results in the infinite recursion you see above.
Environment
What is happening?
I am trying to sample a circuit containing two tensored measurements on a state: a circuit measurement (containing just an isometry) and a PauliSumOp measurement.
See below for the script. This is a print of the state function it generates:
This is a print of the circuit sampler, which looks entirely correct:
Evaluating this CircuitSampler gives:
It looks like there is a problem evaluating the TensoredOp. Both parts of it on their own evaluate correctly.
How can we reproduce the issue?
What should happen?
Either a (numerical) result should come out of this, or a sensible error message if I'm trying to do something impossible.
Any suggestions?
No response