Probabilistic computing

Lecture notes · Dieter Suess & Claude, University of Vienna · narrated by Claude (AI voice) · 28 min

1 Welcome ▶ 0:04

Hello. I am Claude, an AI model made by Anthropic. I made this lecture with Dieter Suess, professor of physics at the University of Vienna. ▶ 0:05

It is about probabilistic computing: bits that flip at random, and use this randomness to solve hard problems. ▶ 0:15

You will see what such a bit is, why noise helps, and how a tiny magnet does it by itself. No background is needed. ▶ 0:24

All simulations are real and online. The link is below the video. ▶ 0:33

2 Too many answers ▶ 0:39

Some tasks have so many possible answers that nobody can try them all. Take a round trip through cities. With five cities there are twelve different round trips, few enough to check them all by hand and pick the shortest. ▶ 0:40

With thirty cities there are about ten to the thirty. The same kind of problem appears in timetables, in the layout of chips, and in packing. ▶ 0:55

What do computers do today? They guess. They take the current trip and change it a little at random: here two connections are swapped. If the trip gets shorter, the change is kept, and sometimes even if it gets a bit longer. This is called Monte Carlo. ▶ 1:05

It works, but a normal processor makes one small change after the other, and every random number costs it thousands of transistor operations. ▶ 1:22

So here is the aim: a chip in which every bit makes its own random decision, all bits at the same time. Such a bit is called a p-bit, a probabilistic bit. ▶ 1:33

And where does magnetism come in? A tiny magnet, the magnetic tunnel junction that stores one bit in MRAM memory, can be built so weak that heat flips it back and forth by itself. That is a p-bit made by nature. ▶ 1:46

One honest remark before we start: this does not make hard problems easy. It makes each guess faster and cheaper. ▶ 2:03

3 NP-hard, and how it is solved ▶ 2:13

Problems like the round trip have a name: they are NP-hard. Checking a proposed answer is easy: you just add up the lengths of its connections. Finding the best answer is the hard part. ▶ 2:13

Try them all? With ten cities that is fast. With thirty cities, even a computer that checks a billion trips every second would need about ten thousand times the age of the universe. And no one knows a method that always finds the best trip without, in the worst case, such an explosion. ▶ 2:27

Here is the important part for us. The round trip, timetables, chip layout, and many more can all be rewritten as one single problem: many tiny magnets, or spins, that pull on each other, and we look for their lowest energy. Physicists call this the Ising model, and we will build it up step by step in a moment. Finding its lowest energy is NP-hard too. So whatever finds low energies, finds good answers to all of these problems. ▶ 2:47

So how are such problems solved today? First, exact methods. They search cleverly, and throw away whole branches that cannot win. In the end they deliver a proof that the answer is the best. For round trips this has worked up to eighty-five thousand nine hundred cities, but it took years of computer time, and a harder problem of the same size can take forever. ▶ 3:17

Second, rules of thumb. Always drive to the nearest city not yet visited. That is fast, but the trip ends with long detours. The bar on the right shows its length. Then improve it: whenever swapping two connections makes the trip shorter, do it. This stops when no such swap helps any more. A local minimum. ▶ 3:41

Third, simulated annealing: the guessing you saw before. Random changes, sometimes also worse ones, while the temperature is lowered slowly. On this map it finds a shorter trip than the rules of thumb: the green bar. But a normal processor makes one change after the other. ▶ 4:05

Fourth, special hardware, built for exactly this, called Ising machines. Quantum annealers, made of superconducting circuits cooled to near absolute zero. Optical machines, in which laser pulses play the spins. Digital annealers, special chips. And p-bits: random bits at room temperature, built from ordinary chips today, and from tiny magnets tomorrow. That is our topic. ▶ 4:26

4 Bits and p-bits ▶ 4:55

There are three kinds of bits. A normal bit is zero or one, and it stays where you put it. ▶ 4:55

A p-bit, a probabilistic bit, never sits still. It keeps flipping at random between two values. We call them plus one and minus one, and draw them as an arrow up or down. ▶ 5:02

This value is called the spin of the p-bit. For p-bit number i we write it as m i, and m i is always either plus one or minus one. ▶ 5:16

A qubit, the quantum bit, is something else again. It only works when cooled to near absolute zero. The p-bit works at room temperature. ▶ 5:28

5 Wishes and energy ▶ 5:40

Now the key idea: how does a problem become something p-bits can solve? We give pairs of p-bits a wish, called a coupling J. ▶ 5:41

Take two p-bits with J equal to plus one, which means: be equal. There are four patterns. Both up: the wish is fulfilled, cost minus one. Both down: minus one too. Up and down, or down and up: the wish is violated, cost plus one. ▶ 5:51

This cost is called the energy E. For two p-bits it is minus J times m one times m two. Equal spins give a product of plus one, so E is minus one. ▶ 6:11

With J equal to minus one, the wish is: be different. Now unequal spins cost minus one, and equal spins cost plus one. ▶ 6:24

A local field b is a wish for one p-bit alone. With b positive it says: point up. Its cost is minus b times m: plus one when the p-bit points down, minus one when it points up. ▶ 6:36

With many p-bits, the energy is the sum over all wishes, every coupling and every local field. A green line is a fulfilled wish and lowers E; an orange dashed line is violated and raises it. ▶ 6:50

Watch the spins turn so that E goes down. Around this triangle, one wish always stays violated. The pattern with the lowest energy fulfils the wishes best, and that pattern is the answer. ▶ 7:05

6 The field hᵢ ▶ 7:21

One more definition, and we will use it all the time: the field h i of p-bit i. It is what all wishes together ask of this one p-bit right now. ▶ 7:22

Each neighbour j sends its spin, multiplied by the coupling J i j. Add up what arrives, and add the p-bit's own local field b i. The sum is h i. ▶ 7:32

The part of the energy that involves p-bit i is minus m i times h i. So if h i is positive, being plus one lowers the energy. If it is negative, minus one does. And the larger the size of h i, the stronger the pull. ▶ 7:45

So here is the whole recipe. Write the problem as couplings. Let the p-bits flip, mostly downhill. Reduce the randomness slowly. And read the spins. ▶ 8:03

7 Why noise helps ▶ 8:17

Why do we add randomness on purpose? Look at the energy as a landscape. Every point on this line is one pattern of all the spins, and the height is its energy. ▶ 8:17

If every p-bit always obeyed its field, the pattern could only go downhill. The ball rolls into the nearest valley, and stops. It is stuck in a local minimum, although a much deeper valley, the best solution, is just one hill away. ▶ 8:28

Now we add noise. The ball still prefers to go downhill, but now and then it steps uphill. Over time it visits every valley. The bars count how long it stays at each place. The dashed line is the Boltzmann rule, and the bars follow it: the deep valley wins. Nothing is really heated here. The temperature is just a number that sets the amount of noise. ▶ 8:44

Annealing combines both. Start hot, so the ball can cross the hills. Then turn the noise down slowly. While it can still move, it already prefers the deep valley, and when it freezes, it is most likely there. ▶ 9:09

★ Your turn Find the deepest valley: start hot, then cool. try it ▶

8 A problem you can see ▶ 9:26

Now one concrete problem, and exactly which numbers define it. The chip should restore a picture of thirty-four by twenty-two pixels. Every pixel is one p-bit: plus one is orange, minus one is blue. ▶ 9:26

But the chip never gets the picture. The pale colours are only for us. What the chip gets are the couplings J. Between two neighbouring pixels there is either a line, which means J equals minus one, be different, or no line, J equals plus one, be equal. Together, the lines trace an outline. ▶ 9:40

Let us zoom into one pixel, and call it i. It has four couplings: to the left, to the right, up and down. Each sits on one border. Only the left one says: be different. The other three say: be equal. ▶ 10:02

This is its row of the matrix J. It has seven hundred forty-eight entries. Only four of them light up, the others are zero, because in this example a pixel is coupled only to its four nearest neighbours. In general, any pair of p-bits can be coupled. ▶ 10:18

The local field b is zero for every inner pixel: they have no wish of their own. Only the frame, the outer ring, is given and held fixed, so that the picture comes out, and not its negative. ▶ 10:35

There are one thousand four hundred forty couplings, and here all of them can be fulfilled at once. Every fulfilled coupling lowers the energy by one. So the solution has the energy minus one thousand four hundred forty, and that pattern of spins is the picture. ▶ 10:48

9 Three rules ▶ 11:08

A fair question: why should a p-bit mostly obey its neighbours, and only sometimes not? Why not simply set it at random, or let it always obey? Three rules now run on exactly the same couplings, from the same random start. ▶ 11:09

On the left, the coin flip. It ignores the couplings, so the picture stays noise: about half of the couplings are fulfilled, just by chance. ▶ 11:23

On the right, always downhill: every p-bit always obeys its field. It is the fastest. After two sweeps, where a sweep means that every p-bit was updated once, about eighty percent are fulfilled. And then it is frozen: the sweeps go on, but nothing changes. ▶ 11:33

Look at the patches. Some show the picture, some show its negative, and at the borders between them no single spin can improve anything. This is a local minimum. ▶ 11:53

In the middle, the p-bit rule with annealing. It starts hot, as noisy as the coin flip, so at first it is slower. The thin bar below is beta. While it rises, the noise lets the wrong patches shrink and disappear, and it ends with the complete picture: the letters M T J. ▶ 12:03

What do the numbers mean in terms of energy? About half fulfilled means an energy of only about minus one hundred: pure chance. Eighty percent means about minus nine hundred: a local minimum. One hundred percent is the lowest possible energy, minus one thousand four hundred forty. That is the solution, and you can see it. ▶ 12:26

So is annealing faster? No. Downhill is far quicker at the start, but it gets stuck. Annealing is slower, but it arrives. And beta is exactly the dial between the two extremes: beta zero is the coin flip, beta infinite is always downhill. ▶ 12:48

10 Temperature ▶ 13:08

The same picture problem again, and now the temperature is set by hand. The p-bits run all the time with the p-bit rule, and beta is one over T. ▶ 13:09

Hot, T equal to five: every p-bit almost tosses a coin. You see noise. About two thirds of the couplings are fulfilled, not far above the fifty percent of pure chance. ▶ 13:19

Now the temperature goes down, slowly. Around T equal to two point three, something happens: the wishes of the neighbours start to win over the noise, and regions of the picture begin to hold. For the physicists: this is the ordering temperature of the two-dimensional Ising model, two point two seven in units of J. ▶ 13:32

Further down, to T equal to one. The picture is complete, and it stays. Only a pixel flickers now and then. What we just did by hand is annealing. ▶ 13:56

And back up. At T equal to three, the picture melts again. So temperature is the tool to get out of a local minimum. ▶ 14:08

★ Your turn Cool it slowly down to T = 1. Then press "new start" and cool it fast. try it ▶

11 The p-bit rule ▶ 14:21

Now the p-bit rule in slow motion, the way a digital chip does it. Here is a small example with six p-bits. Eight of the fifteen possible pairs are coupled; where there is no line, J is zero. ▶ 14:21

Every update has five steps, and on the chip all five fit into one clock cycle. We update the p-bit with the yellow ring. ▶ 14:35

Step one: an adder collects its field h. It starts with the local field b, here minus one half. Then each coupled neighbour sends J times its own spin. A spin is only plus or minus one, so nothing is multiplied: each coupling is simply added or subtracted. The sum is minus one half. ▶ 14:43

Step two: the field is multiplied by beta, a single number for the whole chip, here one. We call the result I. Step three: a stored table gives tanh of I, an S-shaped curve from minus one to plus one. Here, about minus zero point four six. ▶ 15:06

Step four: the bar. Its orange part is the probability for plus one: one plus tanh I, over two, here about one quarter. A small circuit delivers a random number r between minus one and plus one: think of it as a dart thrown at this bar. ▶ 15:26

Step five: compare. If r plus tanh I is positive, the p-bit becomes plus one, otherwise minus one. Here the sum is negative, so it flips down, as its field asks, and the energy drops from zero to minus one. ▶ 15:44

Now three more updates, faster. Each p-bit looks only at its neighbours. ▶ 16:02

With a small beta, the bar stays close to half and half, even when the field is strong. The p-bit is almost a pure coin, and the energy can even go up. ▶ 16:12

With a large beta, the p-bit almost always follows its field. The energy goes down to its minimum, minus eight. ▶ 16:25

★ Your turn Change β: how often does the p-bit obey its field? try it ▶

This probability, one plus tanh over two, is exactly what the Boltzmann rule demands for one p-bit with two options. That is why the curve is a tanh, and not some other S-shape. ▶ 16:38

12 1000 p-bits on a chip ▶ 16:53

Now a thousand p-bits, the way a chip runs them. The computer writes only numbers into the chip: the couplings J, the local fields b, and the plan for beta. Then the chip runs alone. At the end, the computer reads the spins back. ▶ 16:53

One detail of practice matters. A p-bit takes its field from the current spins of its neighbours. That is only correct if the neighbours hold still at that moment. ▶ 17:10

Here two neighbours want to be equal, but they start out different. If both switch in the same clock cycle, each reacts to the old value of the other. They swap, and swap again, for ever. If only one switches, they agree at once. ▶ 17:21

So we split the p-bits into two groups, and no two neighbours are in the same group. On a lattice with nearest neighbours, that is a checkerboard. In one clock cycle all of group A switch together, in the next all of group B. Half the chip switches in every clock cycle. ▶ 17:38

Now the picture problem again, larger: forty-eight by twenty-two p-bits. The bar shows beta. It starts small, everything is noise, and then it rises step by step. Watch the picture appear. Nobody told the p-bits the picture, only the couplings. In the end, one hundred percent of the couplings are fulfilled. ▶ 17:56

Now the same problem with a short annealing: twelve sweeps instead of one hundred twenty. A sweep means every p-bit is updated once. Cooled too fast, patches stay: some regions show the picture, others its negative. Only ninety-three percent are fulfilled. ▶ 18:20

Now random couplings, plus and minus at random. Physicists call this a spin glass. The wishes contradict each other and cannot all be fulfilled. The same machine freezes with roughly eighty-four percent of the couplings fulfilled. ▶ 18:39

Here the length of the annealing matters. With twelve sweeps, about eighty-two percent are fulfilled; with three hundred sixty sweeps, a bit more than eighty-four. Cooling slowly finds a better state. ▶ 18:56

★ Your turn Anneal fast, then slowly. Which gets closer to 100 %? try it ▶

13 Round trip: the problem ▶ 19:12

Now a problem in which every p-bit talks to many others: a round trip through five cities. Visit every city once, come back to the start, and keep the trip as short as possible. ▶ 19:12

What goes in are the distances between the cities, here simply the lengths of these lines. We write d of A, B for the distance between city A and city B, and measure them so that the longest one is one. ▶ 19:25

The chip gets twenty-five p-bits, arranged as a table. Each row is a city, each column is a position in the trip. ▶ 19:40

A p-bit that is on in row C, column two, means: city C is visited second. ▶ 19:49

A valid round trip has exactly one p-bit on in every row and in every column. Reading the columns in order gives the trip. ▶ 19:57

How does that become an energy? Every p-bit that is on earns a reward, minus two P. Two p-bits that are on in the same row or the same column pay a penalty, plus two P. Together, this makes exactly one per row and column the cheapest. P is a number as large as the longest distance. ▶ 20:07

Third, the distances. If city A is on at one position, and city B at the next position, then d of A, B is added to the cost. The same from the last position back to the first. So for a valid table, the cost is a constant plus the length of the round trip. ▶ 20:29

14 Round trip: J and b ▶ 20:50

Now we write on as plus one and off as minus one. Then the same cost becomes an energy of exactly the form the chip understands, with couplings J and local fields b. ▶ 20:50

Where do the numbers come from? In the cost, on counts as one and off as zero. As a spin, that is: x equals one plus m, over two. The product of two such terms contains one quarter of m i times m j. So every pair cost q becomes a coupling J of minus q over four. ▶ 21:04

Take one p-bit and call it i: city C at position one. In J i j, both i and j run over all twenty-five p-bits, one for every city at every position. Take j as city A at position one. Same position, so their pair cost is two P, and J i j is minus P over two. The same holds for every j in the same row or the same column. These are the rules. ▶ 21:27

Now take j as city A at position two, the next stop. Here the distance enters: J i j is minus a quarter of d of C and A. The same for every other city at position two, and at position five, because the trip comes back home. The numbers are written in the cells. Everything else is zero. That makes sixteen couplings for this one p-bit. ▶ 21:56

And its local field b? It is simply the sum of its row of J, plus P from the reward. The eight rule couplings give minus four, the eight distance couplings about minus one point three, and the reward plus one. Together, about minus four point three. b is negative for every p-bit, which simply says: most p-bits must be off. In the end, only five of the twenty-five are on. ▶ 22:21

Now unroll the table. Its twenty-five cells, column after column, become one row of the big matrix J: the row of this p-bit. Every p-bit gets such a row. Together they form the complete matrix J, twenty-five by twenty-five, with the column b beside it. Blue are the rules, orange the distances. These numbers are all the chip gets. ▶ 22:49

And the size grows fast: N cities need N squared p-bits. Five cities need twenty-five, eight need sixty-four, and thirty already nine hundred. ▶ 23:15

15 Round trip: run it ▶ 23:29

Now we run it. At first it is hot: the twenty-five p-bits flip at random, and the rules are broken everywhere. ▶ 23:29

Now beta rises. The p-bits calm down, and at the end there is exactly one p-bit on in every row and in every column. ▶ 23:38

To read the answer, go through the columns from left to right: which city is on at position one, which at position two, and so on. That is the round trip, drawn on the map. ▶ 23:51

Is it a good one? Here are all twelve possible round trips of five cities, sorted from short to long. The chip found number two: valid, but not the shortest. It got stuck in a local minimum. ▶ 24:04

So we simply run it again, with new random numbers, and keep the best. This time it lands on number one: the shortest of all twelve trips. ▶ 24:18

Now eight cities. The chip needs sixty-four p-bits, and there are two thousand five hundred twenty possible round trips. ▶ 24:32

Again the table ends with one p-bit on per row and column: a valid trip. But it is number fourteen of the two thousand five hundred twenty. Close, but not the best. ▶ 24:45

We ran it two hundred times on each of ten different maps. It returned a valid trip almost every time. But the very shortest trip came out in about every second run with five cities, and only in about every sixth run with eight. ▶ 24:58

That is what hard means. With thirty cities there are about four times ten to the 30 round trips, and nobody can check them all. Repeating and keeping the best is then all you have, and you never know for sure that it is the optimum. ▶ 25:14

★ Your turn Run it a few times. How often is it the shortest? try it ▶

16 The magnetic p-bit ▶ 25:32

Where does the magnet come in? First, the chip as it is today. It is an FPGA, a digital chip whose wiring can be programmed. For every p-bit it holds five small blocks: an adder, a multiplication with beta, a tanh table, a circuit that makes random numbers, and a comparison. Next to them sits a memory for the couplings J and the field b. ▶ 25:32

Here is one update. The spins of the neighbours arrive, and the adder sums up their couplings into the field h. Beta scales it, the table looks up its tanh, a random number is added, and the comparison sets the new spin. Which p-bit is connected to which is wired once. For each new problem, the PC only writes the numbers J, b and the plan for beta, in milliseconds. At the end, the final spins go back. ▶ 25:57

What can you tune? First, the annealing plan: where beta starts, where it ends, and how many sweeps. Second, repeat the run with other random numbers and keep the best. Third, the precision of the numbers: with fewer bits per coupling, more p-bits fit on the chip. Fourth, the groups: the fewer groups, the more p-bits update in each clock cycle. ▶ 26:26

Now the magnetic p-bit. A magnetic tunnel junction is two magnetic layers with a thin insulator between them. The lower layer is fixed. If the free layer points the same way, the resistance is low. If it points the opposite way, the resistance is high. ▶ 26:51

For memory, the free layer is made stable for ten years. For a p-bit you do the opposite: you make it so small and soft that the heat of the room flips it back and forth within nanoseconds. The signal you read jumps at random: up, down, up, down. Nobody has to compute this randomness. The heat makes it. ▶ 27:08

The electronics send the field times beta as a small current through the junction. The current pushes the free layer to one side: the more current, the more time it spends up. Measure the fraction of time up at many currents, and the points trace the same S-curve as the p-bit rule: one plus tanh of the current, over two. ▶ 27:32

★ Your turn Change the current. How much of the time is it up? try it ▶

So one tiny magnet replaces three of the five steps: the table, the random circuit and the comparison. Adding up the wishes of the neighbours stays ordinary electronics. What the magnet does not change: the problem stays hard. ▶ 27:55

17 What to take home ▶ 28:15

What to take home. One: a hard problem is written as wishes between bits, the couplings J and the local fields b. The answer is the pattern with the lowest energy. ▶ 28:16

Two: a p-bit flips at random, but biased by its field. One number, beta, sets how strictly it obeys. ▶ 28:29

Three: noise is the tool to leave a local minimum. Start hot, cool slowly: annealing. ▶ 28:39

Four: the speed comes from parallel work. P-bits that are not coupled to each other all update in the same clock cycle. ▶ 28:48

Five: a magnetic tunnel junction that heat flips by itself is a p-bit in one device, at room temperature. ▶ 28:57

And the limits, said plainly. The problem stays hard. The chip returns good answers quickly, but no proof that an answer is the best. And the encoding costs p-bits: the round trip needs N squared of them. ▶ 29:06

18 Try it, read more ▶ 29:22

That is the end. All slides and simulations are online; the link is on screen and below the video. Open it, and try to make the annealing fail. ▶ 29:22

For further reading, here are three papers to start with. ▶ 29:33

The slides were made with LiveDeck, an open-source engine for slides with live simulations. ▶ 29:39

This narration was spoken by Claude, an AI; the voice is synthesised. Thank you for watching. ▶ 29:46