PennyLane is a cross-platform Python library for quantum computing, quantum machine learning, and quantum chemistry. Train a quantum computer the same way as a neural network.
The qml.cond function is used as part of the mid-circuit meausurement functionality in PennyLane. Currently, the signature is qml.cond(condition, true_fn, false_fn), where true_fn and false_fn are quantum functions.
We would like qml.cond to accept operations in addition to quantum functions. The quantum function style can be useful in some cases, but having to then callqml.cond can feel a little counter-intuitive - instead the user might just want to pass the operation directly.
Closing this as we have decided that it is not such a good idea - it would be introducing a UI that is not compatible with cond-like functions in other libraries.
Feature details
The
qml.cond
function is used as part of the mid-circuit meausurement functionality in PennyLane. Currently, the signature isqml.cond(condition, true_fn, false_fn)
, wheretrue_fn
andfalse_fn
are quantum functions.We would like
qml.cond
to accept operations in addition to quantum functions. The quantum function style can be useful in some cases, but having to then callqml.cond
can feel a little counter-intuitive - instead the user might just want to pass the operation directly.Implementation
We would like it to be possible to do:
qml.RY
andqml.RX
are not directly queued, just contained within theqml.cond
conditionaltrue_fn
andfalse_fn
argument names in the signature ofqml.cond
toif_true
andif_false
, respectively (since_fn
no longer always applies)if_false
operation remains optionalif_false
is passed, it must match the type ofif_true
, i.e., function-function or operation-operation.qml.cond
. Note that the example itself doesn't need to be updated.How important would you say this feature is?
1: Not important. Would be nice to have.
Additional information
Similar functionality is supported in
qml.adjoint
.