-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Environment
python version 3.10.11
What is happening?
I'm trying to give RXXGate
a parameter phi
when I encounter this error:
ParameterExpression with unbound parameters ({Parameter(a)}) cannot be cast to a float.
Here is my codes:
phi = Parameter('a')
qc = QuantumCircuit(4)
a = RXXGate(phi).control(2)
qc = qc.compose(a)
qc.draw()
However, it's interesting that everything works fine if the control
method isn't used:
phi_1 = Parameter('a')
qc = QuantumCircuit(4)
a = RXXGate(theta = phi_1)
qc = qc.compose(a, [2, 3])
qc.draw()
which can give the result:
q_0: ───────────
q_1: ───────────
┌─────────┐
q_2: ┤0 ├
│ Rxx(a) │
q_3: ┤1 ├
└─────────┘
I'm wondering what I've done wrong and how to fix it?
Besides, is it possible for me to make this parameter trainable for optimization tasks like using gradient descend?
How can we reproduce the issue?
Perhaps making the Parameter class more flexible can help.
What should happen?
I suppose the gate should take this parameter and give it a random(or zero) initialization.
Any suggestions?
No response
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working