Question on last tasks on "Modeling the toric code on a quantum computer" demo

Hi,

At the end of notebook Modeling the toric code on a quantum computer | PennyLane Demos, there are these tasks which I’m trying to do.

Note
I encourage dedicated readers to calculate the phase accumulated by exchanging:
1. A Z Group excitation and a Z Group Excitation
2. An X Group excitation and an X Group Excitation
3. A combination  Ψ particle and an X Group excitation
4. A combination  Ψ particle and a Z Group excitation
5. A combination  Ψ particle with another  Ψ particle

The combination particle should behave like a standard fermion. You can create and move combination particles by applying PauliY operations.

For task 1, i.e. A Z Group excitation and a Z Group Excitation, this is my code

prep1 = [(1, 1), (2, 1)]
prep2 = [(1, 3)]
loop1 = [(1,2),(2,2),(3,2),(3,1),(2,1),(2,2)]

# WITHOUT LOOPING

expvals = excitations(prep1 + prep2, [])
x_expvals, z_expvals = separate_expvals(expvals)

fig, ax = excitation_plot(x_expvals, z_expvals)

ax.plot(*zip(*(prep1)), color="maroon", linewidth=10)
ax.plot(*zip(*(prep2)), color="maroon", linewidth=10)

display(plt.show())
z_around_z = hadamard_test(prep1 + prep2, [], [], [])
print("WITHOUT LOOPING - Mutual exchange statistics - Move z excitation around z excitation: ", z_around_z)

# WITH LOOPING
expvals = excitations(prep1 + prep2 + loop1, [])
x_expvals, z_expvals = separate_expvals(expvals)

fig, ax = excitation_plot(x_expvals, z_expvals)

ax.plot(*zip(*(prep1)), color="maroon", linewidth=10)
ax.plot(*zip(*(prep2 + loop1)), color="maroon", linewidth=10)

display(plt.show())
z_around_z = hadamard_test(prep1 + prep2, [], loop1, [])
print("WITH LOOPING - Mutual exchange statistics - Move z excitation around z excitation: ", z_around_z)

I did with and without looping to compare the output of the layout and hadamard test.

Question 1: Without any looping, I’m getting +1 from the Hadamard test and 0.0 with looping. Can I know which one is the correct output? Is my looping path correct since I see some “extra” excitations in my loop path?

Question 2: I modified the excitation and Hadamard test code to work with combination Ψ particle using PauliY operator. Then, I did the task 3, i.e. A combination Ψ particle and an X Group excitation. The output is as below (with and without looping). Similar to the previous question’s observations, without looping, I’m getting +1 from Hadamard test and 0.0 with looping. Can I know which one is the correct output? Is my looping path correct since I see some “extra” excitations in my loop path?

Thank you.

Hi @jag , thanks for your questions!

I’m checking with the team. We’ll get back to you as soon as we have capacity. We may need a couple of days since we’re working on a new PennyLane version that will be released tomorrow! :smiling_face_with_sunglasses:

1 Like

Hi @CatalinaAlbornoz , thank you for looking into my questions. I’m learning a lot from Pennylane especially the tutorials. Looking forward to the new Pennylane release too. :slight_smile:

1 Like

Thanks for the question @jag .

When we are calculating the statistics, we need to make sure to bring the particles back to the same spot. If the excitations are in a different place, we are in a completely different state. When we bring the excitations back to the same spot, we still have the same probability distribution but the state just has a different phase.

Since the excitations are in completely different places, the hadamard test gives us 0 because there’s no overlap.

With this set of prep and loop:


prep1 = [(1, 1), (2, 1), (0,2)]
prep2 = [(1, 3)]
loop1 = [(2,3), (3,3), (4,2), (4,1), (3,0), (2,0), (1,1), (1,2)]

We keep the excitations in exactly the same locations at the end, but one of the excitations made a full circuit around the other.

In this case, we can see that the hadamard test gives us a relative phase offset of 0, as cos(phi) = 1. The X and Z excitations on their own are bosonic. It’s only when they interact that things get interesting.

A similar approach needs to be taken for the composite particle too.