# Quantum Imperfect Cloning

Quantum Mechanics forbids you from taking an unknown quantum state and making a perfect copy of it. Period. End of story. Don’t even think about it. Fuggedaboutit. Please. Just. Stop.

the no-cloning theorem states that it is impossible to create an independent and identical copy of an arbitrary unknown quantum state

*source: **Wikipedia*

However, we are allowed to discover just enough about an unknown quantum state to make a reasonably-decent imperfect copy. The circuit above actually consolidates two distinct methods for doing this, both of which use the canonical SWAP Test to determine how close we get to recreating the original unknown state.

It is worth acknowledging that the circuit is intentionally not optimized. Rather, it is intended to showcase the methods with maximum clarity.

**Entanglement**

Neither method uses entanglement to recreate the unknown state, because entanglement does not create independent states.

**Arbitrary Unknown State**

One of my favorite ways to create arbitrary quantum states is to alternate Hadamard gates with rotations around the z axis. This particular implementation, alternating Hadamard gates and T gates (pi/4 rotations around the z axis) is explained rather thoroughly in the online Qiskit textbook, where I got the idea for it.

Because this circuit consolidates two different methods, the same arbitrary state is prepared twice. The SWAP Test is destructive enough that we can’t use the same qubit for two different comparisons.

**Quantum State Tomography**

Here is where we learn as much as we can about the unknown state — as much as quantum mechanics allows — using quantum state tomography. Using three ancilla qubits, we measure the unknown state in the z, x, and y bases, from left-to-right, respectively. In the end, we rotate back to the z basis so that the recreated state and the unknown state are compared in the same basis.

Normally, I would use only two ancilla qubits, because we can also measure the original qubit. However, with this algorithm, we need the original qubit to be undisturbed by measurement in order for the SWAP Test to work.

**Syndrome Bits**

The first method uses syndrome bits to recreate the unknown quantum state. The primary reason for this is simply because I prefer to use OpenQASM — not Python — for all things quantum computing.

The syndrome bits are essentially mimicking the control bits of CNOT gates and reversing the tomography process that we just completed. The circuit sections are identical, except that the CNOTs are reversed. The “clone” qubit is the target of these syndrome-NOT operations.

**SWAP Tests**

The U3 gate is on what I call the “cheat” qubit, because I performed the calculations externally. First, I needed to run this circuit to get the measurements from the unknown state’s ancilla qubits. Once we know the probabilities of measuring |0> in the z and x bases, we can use trigonometry to determine the angles θ (“theta”) and φ (“phi”) for the U3 gate:

*ground = .4 # prob. of meas. |0>adjacent = abs((ground - .5) * 2)angle = math.acos(adjacent)if (ground < .5): angle = math.pi - angle*

For the second run of this circuit, which included both methods to recreate the unknown state, I used θ =1.059 and φ = 1.5679 for the “cheat” qubit.

**Results**

The three rightmost bits are from the unknown state’s ancilla qubits, from which θ and φ are determined, so we’re looking at the leftmost two bits. The far left bit is from the “cheat” qubit.

Even just visually, we can see that the syndrome bit method — second from the left — measured more |0> than |1>. The SWAP Test measures |0> with a probability of 1 when states are identical and it measures |0> with a probability of 0.5 when states are maximally different (on opposite sides of the Bloch sphere). Furthermore, the result moves closer to 1 as states move closer together and closer to 0.5 as states move farther apart. Therefore, this result of approximately 0.7 is actually quite unimpressive.

However, the “cheat” method measured |0> with a probability of 0.997. This means that we did not perfectly clone the unknown state, as demanded by the no-cloning theorem, but we did get fairly close.

the “cheat” method measured |0> with a probability of 0.997

Sadly, the syndrome bit version had little hope of working. It uses only one measurement per basis and always ends up as either |0> or |1>, with no superposition. However, I included it in this circuit and in this article because I always strive to solve everything in OpenQASM.

Interestingly, Python doesn’t present a perfect solution, either. Yes, we can measure the ancilla qubits, process the results, and create imperfect clones for subsequent circuits, but we need to “cheat” at least a little bit if we want to compare the imperfect clone to the original.

**Summary**

Using syndrome bits allows us to recreate an arbitrary unknown state in only one circuit, therefore allowing us to compare the “clone” to the original using the canonical SWAP Test. However, this only works on a quantum computing simulator — I used the 32-qubit IBM Q Experience simulator — and the “clone” is so imperfect as to be worthless.

Using Python allows us to recreate a very close copy of an arbitrary unknown state, however two circuits are really required to do this. The first circuit gives us the information we need to create the copy, and the second and subsequent circuits allow us to use the copy or copies.

The imperfect cloning process, in short, is:

- Measure any arbitrary unknown quantum state in the z basis and one more basis (I usually use x, but y also works)
- Use the probabilities of measuring |0> to calculate the angles needed to rotate the “clone”
- Use these angles to rotate a ground state qubit around the y and z axes, which is why it is easier to use the x measurement
- Compare the “clone” to the original to see how close you got, or simply trust your calculations

**Future Work**

It could be interesting to determine how close an imperfect clone can get to an unknown state. The tomography step could be run multiple times to increase the counts from each measurement. From those counts, the probabilities of measuring |0> and the angles of the rotations could be calculated with higher precision; I only included several decimal places, but more we’re available.

However, a result of 0.997 already proves conceptually that imperfect clones can be made. Therefore, I’m more likely to play around with the syndrome bit version a bit more.