Open mho291 opened 4 weeks ago
.parameters
is a property bound to an instance. If you take the class, there is no way you can access parameters
[ins] In [1]: from qibo.gates import RX
[ins] In [2]: g = RX(0, 1.23)
[ins] In [3]: g.parameters
Out[3]: (1.23,)
[ins] In [4]: RX.parameters
Out[4]: <property at 0x121d0e160>
[ins] In [5]: g.__class__
Out[5]: qibo.gates.gates.RX
I.e. an instance is a container of its state (its attributes). If you take the class, you're extracting some information about the type, but the state is completely lost.
If you are interested in the content of the instance (e.g. the .parameters
property, generated from the underlying attributes), you should keep the whole instance, not just its type.
Thanks for the explanation @alecandido, it confirms my suspicions. GST
works as is, but only for non-parameterized gates. We'll need to tweak it, by keeping whole instances of the gates, for parameterized gates.
In this current version of gate set tomography, it seems like only non-parameterized gates can be passed into GST.
There are two ways that I generate non-parameterized gates:
or
Then we pass them into
GST
:In lines 288-300 of
gate_set_tomography.py
, which is this:it only extracts which qubits the gate acts on. I've tried to extract the
parameters
from the gates ingate_set
but it always returns something like this `<property object at 0x123456789>, i.e.Looking back at our input for
gate_set
, it turns out that it's difficult to extractparameters
from each of the gates ingate_set
.I realise that if we can extract the parameters from the
target_gates
.Hence, for GST, is there another way of inputting the gates instead of doing
gate_set = [g.__class__ for g in target_gates]
?