Update
Qiskit 0.35 introduced a new gate XXPlusYYGate
.
$$\newcommand{\th}{\frac{\theta}{2}}\\\begin{split}R_{XX+YY}(\theta, \beta)\ q_0, q_1 =
\begin{pmatrix}
1 & 0 & 0 & 0 \\
0 & \cos(\th) & i\sin(\th)e^{i\beta} & 0 \\
0 & i\sin(\th)e^{-i\beta} & \cos(\th) & 0 \\
0 & 0 & 0 & 1
\end{pmatrix}\end{split}$$
So, you can now add parameterized $\text{XY}$ to your circuit as follows:
theta = Parameter('θ')
circ.append(XXPlusYYGate(theta, 0), [0, 1])
Original Answer
For the first part of your question, we have
$$XY(\theta) = exp(-i {\frac{\theta}{2}} (X{\otimes}X + Y{\otimes}Y))$$
And since $X{\otimes}X$ and $Y{\otimes}Y$ commute, we can write it as
$$XY(\theta) = exp(-i {\frac{\theta}{2}} X{\otimes}X) exp(-i {\frac{\theta}{2}} Y{\otimes}Y)$$
Qiskit already has these two gates:
$$R_{XX}(\theta) = exp(-i {\frac{\theta}{2}} X{\otimes}X)$$
And,
$$R_{YY}(\theta) = exp(-i {\frac{\theta}{2}} Y{\otimes}Y)$$
Hence, the implementation of $XY(\theta)$ as a parameterized gate in Qiskit will be as simple as
from qiskit import QuantumCircuit
from qiskit.circuit import Parameter
theta = Parameter('θ')
circuit = QuantumCircuit(2)
circuit.rxx(theta, 0, 1)
circuit.ryy(theta, 0, 1)
param_iswap = circuit.to_gate()
Another Solution
If you want to use more basic gates than rxx
and ryy
, you can use Qiskit's Operator Flow:
H = 0.5 * ((X^X) + (Y^Y))
theta = Parameter('θ')
evolution_op = (theta * H).exp_i() # exp(-iθH)
trotterized_op = PauliTrotterEvolution(trotter_mode = Suzuki(order = 1, reps = 1)).convert(evolution_op)
circuit = trotterized_op.to_circuit()
circuit.draw('mpl')
The composition:
And as before
param_iswap = circuit.to_gate()
For the second part of your question, I think the best answer you can have is the one mentioned in the comments by @epelaaez, as it is recent and from a member of Qiskit's development team.