Twist Promises Easier Quantum Programming

We keep trying to learn more about quantum computers. But the truth is, the way we program quantum computers — or their simulators — today will probably not have much in common with how we program them in the future. Think about it. Programming your PC is nothing like programming the ENIAC. So we expect we’ll see more and more abstractions over the “bare metal” quantum computer. The latest of these is Twist, from MIT.

According to the paper (and the video, below), Twist expresses entangled data and processes in a way that traditional programmers can understand. The key concept is known as “purity” of expressions which helps the compiler determine if data is actually entangled with another piece of data or if any potential entanglement is extraneous. A pure expression only depends on qubits it owns, while a mixed expression may use qubits owned by other expressions.

Here’s an example of a teleportation program in Twist:

This may seem strange, but discarding a qubit has the same effect as measuring it, so discarding an intermediate result can affect an entangled result that doesn’t immediately seem related. This is similar to how, in conventional programming, you might free memory used by two different pointers. Discarding memory containing, say, an employee record while holding another pointer to the same record will cause problems if you reuse that memory later. However, with Twist, you can promise the compiler that there are no entanglements between pure expressions.

There is plenty more, of course, so read the paper. If you need a refresher on basic quantum computing principles, check out our series or watch a video.

17 thoughts on “Twist Promises Easier Quantum Programming

  1. Pardon if I interject here, but how is it teleportation if I force two entangled particles into a defined state by measuring one of them? There is a probability for either outcome. So I might measure up/down or 0/1. But what I will measure I do not know until the measurement took place.

    So back to the problem:
    How is it teleportation? Which in my Sci-fi knowledge is creating a truthful copy whilst destroying the original.

    If I missed it or it does indeed to real quantum teleportation. Please explain how.

    1. AS I Recall, even Einstein was aware of spooky events at a distance.
      Even more puzzling, no matter the distance apart of the particles, they change state instantly, or as they say on Star Trek, “Faster than the speed of light”.

    2. By definition, quantum teleportation is collapsing the wavefunction of an entangled pair by measuring one. The teleportation bit happens when the entangled particles are physically distant. The distant particle collapses to one state at *exactly* the same instant that you measure the other.

      This isn’t physical teleportation in the classical sense, this is teleporting *information* faster than light.

      1. This is the part I never understood; why is the assumption that measuring the particle has any effect?

        If I put the same secret message in two envelopes and send them across the globe. No one else knows what is in either envelope until one is opened. And as soon as one is opened, you instantly know what is in the other envelope. However there is no information exchanged between them. Is this not a comparable analogy?

        1. It’s not. What you’re talking about is equivalent to a “hidden variable” hypothesis — there’s something there (“the secret”) that we just don’t know yet.

          The big deal with Bell’s theorem is that it rules these out. I can’t think of a good analogy that’ll work with your messages — maybe that’s already a sign! — because what’s really going on is the non-independence of two experiments that you’d really think are independent, in the statistical sense of “independent”.

          Normal statistics is linear — probabilities of mutually exclusive events add up, and the probability of one independent event doesn’t change if you know what happens to the other one. The physics of things like light polarization or electron spin has a non-linear component to it — the amount of polarized light passing through a polarizer is proportional to the cosine of the angle between the light’s polarization and the polarizer.

          So if the quantum phenomenon were as simple as measuring a (hidden) property of the particles, the probabilities would work like normal statistics, but they don’t. They work as though the two measurements were part of a single experiment, with the result depending non-linearly on the cosines of the angles, even though they’re separated by time and space.

          That’s really strange, but it’s also not. If you think of the whole experiment being the generation of the linked pair at the beginning, their undisturbed transport to the two endpoints, and their measurement there, well, everything’s in order. It’s only if you think that the two experiments at the end are separate from each other, and should behave like statistics predicts instead of like quantum mechanics, then you run into trouble.

          At least that’s how I manage to get to sleep at night.

          1. “So if the quantum phenomenon were as simple as measuring a (hidden) property of the particles”

            The key problem here is thinking of the particles as free states, which is what you’re implying later. If you don’t think of the experiments as separate, but think of everything *together*, it’s fine.

            The entirety of the complication comes from believing that an electron is a “thing,” like the original poster’s envelope with messages inside it detailing its features (position, momentum, etc.).

            You can get rid of that entirely by just thinking of it as an excitation of a field. What you think of as a “free” electron is really an “average” excitation. Just like a hydrogen atom isn’t actually a “ball” – it’s really an electron whipping back and forth in a straight line (how would it circle? it has no angular momentum). It’s just that the orientation of the line’s random, and over many measurements, you get a ball. A “free” electron is just the average excitation, not any single one.

            So when you create a Bell pair, you’re not actually creating free particles. Their excitations aren’t “average free electron” excitations. But the only way you can discover that is by mapping the combined phase space of the two, because there’s no way to actually “measure” the excitation itself.

            What you’re doing is taking one (indivisible) bit of information and encoding it in the *field* as a coupled excitation. The idea that there are two particles that “affect” each other is intuitively super-confusing, which is why it causes such problems.

            It’s better just to get rid of the idea of everything being a free particle entirely, and just focus on the *entire* apparatus, like you’re saying. That gets rid of all of the “spooky action at a distance” entirely.

      2. It’s not teleporting information faster. That’s impossible, even for quantum computation.

        You’re producing an entangled pair (bell_pair) and coupling it with the desired state. You then measure one of the two, which tells you the state of the other *once you have that information*.

        The measurement *allows* you to duplicate the state, and the measurement can be done as far away as you want, but you need the result of that measurement.

        A *very* crude and limited analog is to imagine commanding Mars rovers. You find out some piece of hardware is malfunctioning in the command transmit so you don’t know what you just sent. You can’t take it apart (make up a reason) but you can replicate it. So you replicate the command on an Earth copy of the rover, and *instantly* you know where the rover is on Mars.

        It’s not faster than light. It’s just your knowledge updating.

        1. Uh no…not at all. The truth of quantum physics is that there is NOT a single state until you inject your self into the system by trying to measure it. That is a very fundamental rule. They are both in all states at varying probabilities of being found in a particular state when measured. Weird stuff quantum physics and any time you attempt to come up with a classical analogy it is probably false.

          Your Mars rover analogy does not work either. It would be more like this. The rover on Mars malfunctions and simultaneously your rover here on earth malfunctions in exactly the same way and at the same time. You would not have to send commands to Mars because commanding your rover here on earth will simultaneously set your Mars rover into the same exact state. Of course that would require perfect long lasting entanglement of every single particle in each machine.

          1. Oh and by the way. The faster than light thing only applies if something has mass. No one knows if the mechanism for entanglement requires any mass at all so it is not known if it applies to the light speed limit. There is also the expansion and contraction of space time itself which is not subject to light speed limits. That is why galaxies can move away from us at what is apparently more than light speed. The space itself is expanding between us.

          2. Good point, it’s not about just state, but state coupled with time in measurement (state+time is absolutely unique), hence the information is teleported.

          3. “Uh no…not at all. The truth of quantum physics is that there is NOT a single state”

            Yes. That’s right. There’s a coupled state.

            “Weird stuff quantum physics and any time you attempt to come up with a classical analogy”

            The weird stuff is because you’re thinking of the two coupled particles as being the same as free particles. That’s the trick with Bell’s theorem. You either have to give up the idea of nonlocality or give up the idea of the concept (say, spin) being “real” at all.

            “You would not have to send commands to Mars because commanding your rover here on earth will simultaneously set your Mars rover into the same exact state.”

            No, it doesn’t. It collapses the coupled state. This is a huge difference. The “teleportation” part is that if you send the information you’ve gotten about the *first* measurement, you can *reconstruct* the original state.

            The whole “classical analogies fail!” thing is always because you have to add weird requirements to the classical analogies, because, well, classically, systems contain buckets of redundant state information. Quantum mechanically, they *don’t*.

            Basically, when I create a Bell pair, I’m taking a bit (literal bit) of information and splitting it in two. Which you might say “wait, that’s not possible” – and that’s true. You can’t – so you *encode* it into a larger space (the two particle system).

            Now if I want to transport that information somewhere else, you separate the system without disturbing it (which is fine, the system doesn’t even know what distance is). I can then measure one part of the system, and then with that knowledge, *along with the other particle*, I can recover the original bit of information.

            But you need *both things* – both the measurement, plus the undisturbed particle. There’s no faster than light anything unless you impose the unphysical idea that each “particle” is a real thing (which doesn’t allow you to *do* anything anyway). They’re not. A coupled system by definition has less degrees of freedom than two individual ones.

      3. There are different interpretations of quantum mechanics. Wave function collapse is required in the Copenhagen interpretation (a number of other interpretations also require it).

        Information can’t be transferred faster than the speed of light. It’s the speed of causality.

        Moving two entangled particles away from each other is also moving their information with them. The “spooky action at a distance’ is that when one of these two is measured, the other now has properties that are known to this observer. Information still has to be conveyed to the second observer for them to conclude that anything occured.

    3. Theres a video on YouTube from Qiskit’s summer school, first lecture, that explains this algorithm. Just to breifly explain. Alice and Bob share an entangled Bell state (this is q2 and q3). Alice also want to send a random superposed state to Bob (q1). She is not measuring it, merely sending it over. To do this she applies a Bell measurement to q1 and q2 (her entangled qubit with q3). A Bell measurement reverses the creation of an entangled pair but notice she applies this to q1 and q2, her qubits that are not entangled together. This weird phenomenon allows Alice to measure q1 and q2, which collapses to 0 or 1 each. She sends the measurement to Bob who has q3 (still entagled with q2) and Bob can apply a series of gates to q3 according to Alice’s measurement, and retrieve information from q1. Still very strange indeed but this shows you can only teleport information by first destroying the state you want to send over (Alice’s q1) by creating a Bell measurement with the state and a qubit that is entangled with a third (Bob’s separate qubit)

  2. For any given starting state S quantum computers cannot determine the final state F of data that has had rewrite system R applied to it iteratively until time step T any faster than a traditional computer. Y/N?

  3. “Quantum computers are error-prone and difficult to program. By introducing and reasoning about the ‘purity’ of program code, Twist takes a big step towards making quantum programming easier by guaranteeing that the quantum bits in a pure piece of code cannot be altered by bits not in that code,” says Fred Chong, the Seymour Goodman Professor of Computer Science at the University of Chicago and chief scientist at Super.tech.

    At this time it seems to me a big problem with quantum computing is a lack of robust quantum error correction. This is mentioned in this very approachable article:

    * What Makes Quantum Computing So Hard to Explain?

    To understand what quantum computers can do — and what they can’t — avoid falling for overly simple explanations.

    Scott Aaronson, Contributing Columnist, June 8, 2021

    https://www.quantamagazine.org/why-is-quantum-computing-so-hard-to-explain-20210608/

    And for more fun, see this on the subject of quantum error correction:

    * How Quantum Computers Will Correct Their Errors

    Katie McCormick, Contributing Writer, November 16, 2021

    https://www.quantamagazine.org/how-quantum-computers-will-correct-their-errors-20211116/

Leave a Reply to Steven Naslund Cancel reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.