Closed mikeevmm closed 3 years ago
Additionally: calling tfq.get_supported_gates()
errors out, the function is under utils
, so the call should be tfq.utils.get_supported_gates()
.
Hi @mikeevmm , thanks for raising the issue. You are using a gate that isn't supported by TFQ. Any Cirq gate that has been turned into a controlled gate with .controlled_by
was never supported anywhere in TFQ. If you recalled using controlled Rz operations before, perhaps they were in the form of a CZPowGate
, which is supported since it doesn't use controlled_by
?
Either way, it looks like the underlying issue here is that the error strings presented to a user that does not use a supported gate are misleading. Should be a quick fix :)
@mikeevmm if you are still interested we have just closed #422 which adds support for controlled_by
on all of our gates, so the above snippet should now work on tfq-nightly
.
Environment
Using Linux Mint 20, python 3.8.5, and a virtual environment with
tensorflow-quantum==0.4.0
,tensorflow==2.3.1
.Problem
Creating a new parameterized quantum circuit (
tfq.layers.PQC
) fails with raisedValueError
and message:with traceback (cleaned up to remove references to my setup):
MWE
Further Comments
ValueError
message has a.format
call, but no{}
in the text; these are likely missing at the end of the string.cirq.Z.on(qubit).controlled_by(control)
), I get a different error message1, that seems to relate to #200 . Is something like that happening here, but not being caught before_symbols_in_op
is called?op found in tfq.get_supported_gates
meant I should calltfq.get_supported_gates
to see a list of what's supported; this may be just me, but please consider actually displaying the supported gates, or being more explicit about this ("calltfq.get_supported_gates
to see supported gates").1
ValueError: Cannot serialize op cirq.Z(cirq.GridQubit(0, 0)).controlled_by(cirq.GridQubit(0, 1)) of type <class 'cirq.ops.controlled_gate.ControlledGate'>
Cheers