PennyLaneAI / catalyst

A JIT compiler for hybrid quantum programs in PennyLane
https://docs.pennylane.ai/projects/catalyst
Apache License 2.0
142 stars 36 forks source link

`catalyst.cond` does not accept `MeasurementValue` type as input conditional #1237

Open willjmax opened 4 weeks ago

willjmax commented 4 weeks ago

In PennyLane qml.cond(conditional, true_fn) can take either a MeasurementValue or a boolean for the conditional argument. However, catalyst.cond only accepts a boolean for the conditional argument. This prevents some PennyLane operations, such as iterative_qpe, from being compatible with QJIT.

josh146 commented 4 weeks ago

Thanks for opening this issue @willjmax!

I would say that this is less an issue re: allowing catalyst.cond to take MeasurementValue objects --- MeaurementValue's are not supported with catalyst or the new program capture.

Instead, the root of the issue here is that qml.measure (which returns a MeasurementValue) does not (yet) dispatch to catalyst.measure (which returns a tracer).

As soon as we are able to make qml.measure dispatch to catalyst.measure, this will be resolved. In the meantime, the best way around this is to use qml.compiler.active to branch between qml.measure and catalyst.measure as needed.