Custom Gates - L_z^2

Hi,

so I’ve been going through the plugins section of the PennyLane documentation and I still have some questions. I want to simulate a gate operation which conforms to a \chi\hat{L}_z^2 operation. Since there is no such gate operation in the PennyLane gates and in the strawberry fields plugin I’ve been using I wanted to ask what I would have to do to define such a custom gate? Can I define custom gates within the strawberry fields Fock device or do I need to create a new device and add the gate this way?
And what exactly would I need to define to obtain a \chi\hat{L}_z^2 operation?

Hi @nlwach — Thanks for your question. The ease of implementing that gate (I am assuming here that by L_z you mean the z projection of the angular momentum operator) will depend on the total spin of your particle. In the case of a spin 1/2 particle your gate is a trivial global phase since L_z^2 \propto \mathbb{I}_2. More generally, if you have a total spin j you will need a Hilbert space with dimension (2j+1), which implies on the order of \log_2(2j+1) qubits to have enough dimensions to encode it.

Hope this helps,

Nicolas

Another approach, as you suggest is to use the Fock backend to encode a d-dimensional system using a single mode with a cutoff of d = 2j+1. Furthermore, you could use a “dual rail” encoding where you use two modes to encode a spin system. In this case you can assemble the exponential of L_z^2 = (n_1 - n_2)^2 = n_1^2 - 2 n_1 n_2 +n_2^2 in terms of Kerr gates K_i(\kappa) = e^{i \kappa n_i^2} and cross-Kerr gate CK_{i,j}(\kappa) = e^{i \kappa n_1 n_2}.

1 Like

thank you very much for your answer. I am quite new to quantum computation and such… So essentially what I want to do is to model a system of atoms which can either be |\uparrow \rangle or |\downarrow \rangle. I though the simplest way to model this is to use Fock states where (lets say I simulate a system of 5 atoms) with 2 wires. Each wire represents the number of atoms in the respective spin state. Is this dual rail encoding?

So I guess the Kerr gate approach would be best for my purpose. How exactly would I implement those gates? Something like that?

dev = qml.device('strawberryfields.fock', wires=2, cutoff_dim=11)

@qml.qnode(dev)
def Kerr_test(x, var=False):
qml.FockState(5, wires=0)
qml.FockState(0, wires=1)
qml.Kerr(x, wires=0)
qml.Kerr(x, wires=1)
qml.CrossKerr(x, wires=[0, 1])
return [qml.expval(qml.NumberOperator(0)),qml.expval(qml.NumberOperator(1))]


Thanks again and cheers,

Noah

Hi @nlwach — Glad the answer is helpful. So yes, your circuit is almost correct! The only needed change is that the argument of the Cross-Kerr gate should be - 2 * x`. Other than that, the decomposition you implemented should be equivalent to applying J_z^2.

3 Likes

I added the -2\cdot x in the argument. I have one more question regarding the Kerr gate. What exactly does it do? In the documentation there is not a lot of explanation.
I ran my circuit with and without a beamsplitter gate before the Kerr interactions but there does not seem to be a difference… Am I measuring the wrong thing or what am I a missing?

hi @nlwach — The Kerr gate is defined as K(\kappa) = \exp(i \kappa \hat{n}^2) where \hat{n} is the photon number operator. When applied to a Fock state it will give it a phase proportional to the square of the particle number in it: K(\kappa)|n \rangle = e^{i \kappa n^2} |n \rangle. That apparent minuscule square inside the exponential makes the Kerr a super useful gate to generate non-Gaussian states of light. For example you can use a Kerr gate on a coherent state to make a cat state.
As for your second question, could you share the code you use with the beamsplitter and give us a bit more context about what you are trying to achieve?

Thanks,

Nicolas

Essentially what I am trying to do is to model the Hamiltonian of this paper on page 15 eq 2.41: http://archiv.ub.uni-heidelberg.de/volltextserver/20251/1/HelmutStrobel_PHD.pdf

The goal is to create these unstable fix points (figure 2.2).

Hi @Nicolas_Quesada, thanks for all the help. I just wanted to provide a tiny bit of context as it seemed that you were asking for some.
For various reasons it might be neat to describe cold atoms experiments with quantum circuits as Manuel Rudolph described kind of nicely here. After some initial tests on the connection to the hardware here, we are now building up a few examples.

And very specifically, we are now looking for a translation of this cute paper into circuits.

Hope that this helps, if it does not then sorry for the spam …

– Fred

Hi @fretchen! Welcome to the forum. For the hamiltonian you and @nlwach mention in the PhD thesis above you can follow two strategies.

A first strategy is to decompose the collective angular momentum operators into qubits as it is done in Eq. 2.42 of the same thesis. In this case for a spin j you will need 2j qubits. This strategy is somewhat inefficient in that you would use a Hilbert space of size 2^{2j} where you only ever visit the symmetric subspace of dimension 2j+1.

A second strategy is to use a dual rail encoding, i.e., two harmonic oscillators with cutoff 2j+1 to encode a spin j system (a nice treatment of this can be found in Sec. 3.8 of the book by Barnett and Radmore). In this case the collective operators are mapped according to

J_x \to \tfrac12 \left(a b^\dagger + a^\dagger b \right)
J_z \to \tfrac12 \left(a^\dagger a - b^\dagger b \right)

As mentioned above the gate generated by J_z^2 can be decomposed into Kerr and Cross Kerr gates while the gates generated by J_x and J_z correspond to a symmetric beamsplitter and a product of two rotation gates respectively.
If you use two harmonic oscillator with cutoff 2j+1 you will have a Hilbert space of dimensions (2j+1)^2 which is significantly better than using bare qubits.

Finally, the Hamiltonian you are trying to simulate H = H_1+H_2+H_3 = \chi J_z^2-\Omega J_x+\delta J_z is made of non commuting pieces [J_z,J_x] \neq 0 thus one strategy you can use is to approximate

\exp(i H) \approx \left[\exp(i H_1/N) \exp(i H_2/N) \exp(i H_3/N) \right]^N

via Trotterization.

Hope this helps,

Nicolas

1 Like

PS: In the snippet above shared by @nlwach nothing happens since the code is lacking the parts corresponding to J_x which mix photon number of the two modes.