Closed teaguetomesh closed 1 year ago
It's been quite some time since looking at this -- the ParameterizedUnitaryGate I made to allow us to parameterize CVCircuits is a bit of a workaround/hack to force Qiskit UnitaryGate to be parameterized. Out of the box, I don't believe Qiskit's UnitaryGate are parameterizable -- they need all parameter values to create their unitary matrices in _define()
, which sounds like it needs to happen when serializing. The same problem has arised in #79 -- there the Qiskit Machine Learning package uses parameters that aren't bound during a transpile step where _define()
is called.
If this is still needed, I can look to see if there's a way for us to custom serialize ParameterizedUnitaryGate to prevent it from calling _define()
.
@teaguetomesh -- The test case at https://github.com/C2QA/bosonic-qiskit/blob/main/tests/test_circuit.py#L130-L149 now passes after I added code to avoid the serialization error. I haven't tested the change any further than that. Are there ways you have availavle to test with the new changes?
With the test case provided passing, I'll close this ticket. If it is still a problem please do let us know.
Firstly - the changes made to resolve #39 have been working great - thank you!
I'm attempting to use Qiskit Runtime to simulate large bosonic-vqe circuits, and I have a working implementation (locally). I believe that it should also work remotely within Qiskit's Runtime - however, I am running into an issue when I attempt to submit a parameterized
CVCircuit
to the Runtime program. The issue appears to be occurring during the json serialization, and at some pointParameterizedUnitaryGate._define()
is called and the code attempts to cast the unbound parameter as complex which results in the error.Code to reproduce the error:
The weird part is that unbound Parameters are serializable in
QuantumCircuits
but notCVCircuits
. I tried tracking down how Qiskit handles this and started with a RXGate. It looks like the unbound Parameter object is simply passed all the way through the definition.I'm not sure if the same can be done for
ParameterizedUnitaryGate
because it inherits fromUnitaryGate
which doesn't take any parameters as inputCC @kevincsmith who I've been slacking about this issue