1. Home
  2. Explore
  3. Mathematics
  4. Graphs, Matrices, and Computation

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Graphs, Matrices, and Computation

Transcript

Congratulations. Thank you for having a birthday and giving us an occasion to get all of these wonderful people together in the same room. OK, is Jeremy here? I actually gave Jeremy his title back. I took the "there and back again" out of my title, so we can fight over it in the proceedings. But I'm going to talk about graphs and matrices. That's no surprise. I always talk about graphs and matrices. And in particular, how each has supported the other over the years, and in particular, with a focus on computation-- how each is focused-- how each has supported the other over the years in computational ways.

And then once you start talking about computation, you also have to talk about programming. How are you actually going to organize the computation, which, of course, is another subject that Alan has made tremendous contributions to. And so while most of this talk is retrospective-- there's not really anything new about graphs and matrices in this talk-- I'm going to finish up with a challenge about programming that I hope somebody will take me up on.

If I recall correctly, and Alan may be able to correct me, I'm pretty sure I met him for the first time when he was an assistant professor at Berkeley and I was in Palo Alto. The first time I actually remember, with a picture in my mind, was when Alan was giving a talk at RIACS at NASA in Mountain View, and I remember him explaining very clearly a round robin parallel algorithm for something, but I have no idea at this point what it was. [INAUDIBLE] That sounds that sounds exactly right. OK.

Alan remembers better than that. And since then, I couldn't make a list. I just feel like I've always known him. One other memory from those early days-- I guess Alex told us yesterday about the pithiness of Alan's emails. And I very clearly remember one email from 1996, which was-- I am absolutely certain it was the shortest recommendation letter I ever read for anybody, and it was also the most effective. And it was when Sivan Toledo was applying

for a postdoc at Xerox PARC, and of course Sivan got the postdoc. Alan and I maybe have interacted more intensely since the early 2000s, and that's because in the year 2002, I was ready to go back to academia after a dozen years or so at PARC. And Alan very generously invited me to come to MIT for a year on a sort of inter-job sabbatical, as it were. And [INAUDIBLE] [LAUGHTER] Well I thought it was-- it was exactly what I needed at the time to decompress from working for corporate America

and prepare for working for academia again. That year, 2002, changed my life in a lot of ways, Including how to think about parallel computing, how to think about parallel programming. A lot of it was this course, which has been mentioned before yesterday and today, which was Alan's 18.337 class in applied parallel computing, which I sat in on during one half of that year. Maybe I helped a little bit with it, probably not. And as it says here, it taught me

a lot about how to think about math and computer science and computation altogether. If you're going back into academia, you have to start designing courses, and so it formed the skeleton of the design for the new course that I did at Santa Barbara the next year. But also, I just remember Alan coming into that class and being absolutely fearless about demoing anything. He would fire up MATLAB and go off and look at the web and look for a description of something

and think for a minute and try it in MATLAB, and then explain off the top of his head to the class how it had worked. I thought that was great. Sometimes, it was something that had just occurred to him. Sometimes it was something he had stayed up all night the night before figuring out how to do. But it was just amazing. I in my lecturing was never able to be as fearless or as smooth as Alan And the other thing that I will say-- that one class, that 18337 class did-- was it

was the first time I met Jeremy Kepner. Jeremy Kepner, who was at Lincoln Labs already at that time, was sitting in on the class too. And I lectured once on sparse matrices in the class, and I remember Jeremy asking me very hard questions from the back row. [INAUDIBLE] I did. Alan remembers this better than I do. Right, that's right. I think I gave one week of three lectures on sparse matrices in that class.

It also turns out that during that year, I met my wife in New England, so changed my life in a lot of ways. One of the things that I remember about Alan-- that I've always known about Alan, that I've always admired about Alan-- is the way that he can think across disciplines. And so one of the specific memories that I remember from that applied parallel computing class was I knew how fast multigrid worked. I had explained it to people. I had read papers. I had never implemented it.

It's this huge cloud of ideas that just come from all different directions, like a video game or something. And Alan gave a gave a lecture in 18337 in which he explained that there's actually a three-dimensional orthogonal basis for this algorithm. And it consists of one vector in the direction of computer science algorithms and discrete data structures, one vector in the direction of approximation theory, Taylor series, Maclaurin series, and one vector in the direction

of programming, which is how you do arithmetic on multipole expansions, which you could call object-oriented programming or you could call generic programming or whatever. And as with so many things in linear algebra, once you have the basis right, it's easy to understand the algorithm. And, of course, programming. The quote, "A computational trick can also be a theoretical trick," is from Alan and from the title of this meeting, and Alan's programming language design of course,

goes back at least as far as MATLAB Star-P in 1999, which formed the basis for Star-P and the interactive supercomputing start-up and so forth, and eventually Julia. So I said I was going to talk about graphs and matrices, and I am. This is my favorite coffee mug. It's a graph. It's a matrix. Of course, mathematically, a graph and a matrix are, in some sense, the same object. And in theory, in mathematics, graphs and matrices have been applied to each other, to the understanding

of each other, for as long as both have existed, or maybe a little bit longer. But I want to talk specifically about computation on graphs and matrices, because when you want to compute with one of these objects, it's usually one or the other that you want to compute with. And surprisingly often, the other one is what you need in order to do that. This mug-- the other logo, the other slogan on this mug down there is from my colleague Phil Merkey, "Shut up and compute something," which is maybe

a little ruder than Alan would ever be, but I think is entirely consistent with his philosophy. OK, so I'm going to start with graphs for matrices, because graphs have been used to compute with matrices for many, many decades. In prehistory, I could go back to Seymour Parter in the early 1960s-- actually, 1959, I think, was when he first when he first described this. And he defined a one-person game on undirected graphs. It has very simple rules. It goes like this.

You pick a vertex and you mark it. You add edges to connect its unmarked neighbors, and you repeat. Those are all the rules. So I pick another vertex. That one has three unmarked neighbors. Two of them are already adjacent, so I have to add two more edges. I pick that vertex. It has only one-- no, it has two unmarked neighbors, but they're already adjacent, so no new edges. This one has only one unmarked neighbor, and that one, of course, has no unmarked neighbors. So that was the game--

kind of a boring game. Oh, what I forgot was to tell you how you score. The scoring for the game is that your goal is to end up with as few edges as possible. So knowing that, let's try again. Let's see. I can pick that vertex, and of course, there is only one unmarked neighbor, so no new edges. That one has only one unmarked neighbor, so no new edges. That one has two, but they're already adjacent, and so forth. So in fact, for this particular graph, I can play the game perfectly.

I can end up with no more edges than I started with. This game, which Parter defined, Don Rose called the vertex elimination game. There it is, just again. It's known that on a general graph, the best play is NP-complete. On that particular graph, you could end up with no extra edges. But if you think about a four cycle-- think about a cycle of four vertices-- whatever you mark first is going to add an edge, so you can't play perfectly on every graph. And in fact, on arbitrary graphs,

it's NP-hard to figure out what the best play is. The final graph, what one thing Don Rose proved, was that the final graph is always a chordal graph, which is an object that had been studied before this. A chordal graph is a graph in which every cycle of at least four vertices has a short cut edge, a chord, and it turns out that the final graph is always chordal, and you can play perfectly if and only if the graph-- the initial graph is chordal. Chordal graphs have a big theory.

Just for example, if I change the score from the fewest edges to the smallest complete subgraph in the graph, I get the notion of the graph's so-called treewidth, which is key to fixed parameter tractable algorithms, which are in vogue-- are something of something of a subject today. So what does this have to do with matrices? Well, this is a slide that Alan accuses me of showing so often that everybody's already seen it, and probably most of you have seen it already.

And maybe I did, actually, make it for your course, Alan. That may be. I know the example comes from Joseph Liu, but who knows. Anyway the-- I know [INAUDIBLE]. Yes, well I could-- I know the paper of Joseph's from the 1980s that this example comes from, but it may be me that did it in PowerPoint. Well, it was me that did it in PowerPoint, and it may have been in your class. Anyway, the point is that a symmetric graph-- an undirected graph is a symmetric matrix,

and a choice of an ordering of vertices is a symmetric permutation of the matrix. And then the graph, the chordal graph that you get by playing the game, is the non-zero structure of the Cholesky factor of the matrix. This is something that you actually know from yesterday, because Dan used it again in his talk. After all these years, I'm sort of amazed that-- that would take me too far afield, but I'm still amazed by that result, that just playing this game and dropping things

at random in a crafty way is so provably good. But anyway, so back in the 1970s, this was just how you did Cholesky factorization. And chordal graphs have a lot of theory and explain a lot about complexity and algorithms and design of algorithms for sparse factorization, which I'm not going to go into here. But for example, if I look at the vector-- this vector D that says, how many higher-numbered neighbors does each vertex have? In other words, how many unmarked vertices

were there when I eliminated each vertex? That's a vector of n numbers that always ends with a zero. The number of edges in the graph is the sum of those numbers, so is a first number, and that's the number of non-zeros in the Cholesky factor, so that's how much memory you need to do a Cholesky factorization. The amount of work to do it in flops turns out to be the sum of the squares of those numbers, so it's a second moment. And the amount of fast memory that you

need to do this with what's called the multifrontal algorithm, which I won't describe, but you can think about trying to keep things local and just page them in when you need them. The amount of fast memory that you need scales as the square of the largest element, so it's an infinity moment, and that infinity moment is also the treewidth. 1960 wasn't actually when this started.

Harry Markowitz, economist, is credited with thinking up-- with being the first one to call a sparse matrix sparse matrix. This was in the 1950s, when he was at Rand Corporation inventing portfolio theory and laying the groundwork for, as far as I know, the only Nobel Prize that's been given yet for sparse matrix work, which was the 1990 Nobel Prize. We heard this morning about a Nobel Prize that has to do with numerical linear algebra and C-matrices, but this is the only sparse matrix Nobel Prize that I know about.

But this is what I think of as the canonical example of combinatorics in the service of linear algebra. And since then, by the early 2010s, many, many, many graph algorithms had been used and invented and implemented at large scale for sparse matrix computation. And in fact, as of then-- as of 2005, as of the early 2000s-- the largest computations on graphs that had ever been done in the world were in the service of scientific computing in general and sparse matrix computation in particular.

If you were a graph theorist, you might or might not be interested in numerical linear algebra, but if you were a graph supercomputing guy, you were working on numerical linear algebra, almost surely. Since then, however, as Jeremy talked about this morning, the pendulum has sort of swung back because since the early 2000s, since 2010 or so, graphs have increasingly become interesting objects-- worthwhile, important objects of computation in their own right,

graphs coming from anything from financial transactions to protein interactions to social networks to 10 other applications, easily. And so we have found that-- well, the graph people found started finding that all of this technology-- who knows about implementing big graphs in parallel, as of 2010? Well, it's the sparse matrix people. So the pendulum sort of started swinging back. And in fact, computational numerical linear algebra, all of the techniques that were developed there,

are starting to repay a debt of about 60 years or so to graph algorithms. So again, Jeremy this morning showed a picture of our book, which is one of the things that kicked it off. Jeremy ran a study at Lincoln in 2006 trying to build graph algorithms in the language of linear algebra, and we published an edited collection, which we dedicated to Dennis Healy, which is another good story that I don't have time to tell, which eventually culminated in the GraphBLAS, which

I think the C API was 2017. Is that right, Tim? Jeremy? I'm not-- [INAUDIBLE] Anyway, so the GraphBLAS are doing-- Jeremy explained it. I don't need to explain it. Using linear algebra to do graph computations, but typically, linear algebra over other semirings besides the real field or the complex field-- max plot. Min-plus gives you shortest paths. Boolean algebra gives you connectivity. More exotic things give you more complicated algorithms.

But in general, the idea is that the ring of values, the semiring of values, is attributes that live on vertices and edges. The addition operation is, in some sense, aggregating data at vertices, and the multiplication operation is, in some sense, processing data that's crossing edges. And what exactly that means depends on what algorithm you're doing. So in 2017 or so, the graph law C API was promulgated. It's a wonderful, precise API. It's a complicated API, and it looks a little messy in C, because doing--

I won't call it generic programming, but trying to do generic programming kinds of things in C is inherently messy. But the best thing about it is that there is a magnificent implementation, which is due to Tim-- due to Tim Davis-- which I don't have nearly time to describe in detail, but it's wonderful if you haven't seen the SuiteSparse GraphBLAS, you should read about it. You should look at Tim's talks online. Jeremy talked about hyper-sparse matrices.

You can have matrices of dimension 2 to the 60 by 2 to the 60 in SuiteSparse GraphBLAS. It lives underneath RedisGraph and all sorts of things. OK-- graphs, matrices, and programming. So I want to spend the last few minutes talking about the programming part. In particular, if you're going to do all this stuff-- all this high-performance programming on graphs and matrices and so forth-- what do you need in a way of a language? What language are you going to use?

And, well, what language do you want to use? Well, for what, you have to say. And what I mean for what is three things, which are all a little bit different from each other. One is developing algorithms on irregular structures. I'll call them graph and matrix algorithms. One is experimenting with them, because you don't know unless you try, at sort of medium scale but also maybe at fairly large scale, because things change as you scale them. And every now and then, you find out

that there's one that you actually want to use in anger at the very largest scale. You want to use the largest machines in the world to do something, and so want to implement some of these at really big scale. So what do you want to use? Well, when I got started in this business, we used Fortran 77. I wrote graph algorithms in 1477. It was better than nothing. A few years later, C became popular. It was better than Fortran 77. Let's see-- the breakthrough, though, I think,

for the exploratory computing side of this business, was MATLAB, the first breakthrough in the 1980s-- interactive, fast turnaround, very expressive within its domain, and was very useful for exploring matrices at sort of smallish scale. And then a few years later, when MATLAB got sparse matrices sort of invisibly under the hood, it became useful at sort of medium scale for exploring graphs if you were willing to write your graph algorithms in the language of linear algebra.

And this actually was what first convinced me that this was a useful way to think about graph algorithms, because it was the only way you could do them in MATLAB in the 1990s. That chain of development, I think, logically leads to Julia, which does write a lot of the things that people have been struggling to do all along. And so people use Julia for exploring, well, graphs and matrices and lots of other things at small scale to large scale. But I haven't talked about the third bullet yet, the implementing at very large scale.

Because there, I'm talking about irregular algorithms, lots of communication, blah, blah, blah. Parallelism for high performance and scale brings in issues of scheduling and, in particular, of locality-- of reducing communication. And so this isn't a history of parallel programming languages. That's a different lecture. But the MATLAB Star-P development, for example, handled those issues by raising the level of the primitives to a level where you could hide them underneath.

And that works great as long as you can live in the world of those primitives. For me in the early 2000s and even early 2010s, my favorite approach, my most productive approach for me and my colleagues, was what's called PGAS languages-- Partitioned Global Address Space languages, like Universal Parallel C, UPC. And to finish off in the last couple of minutes here, I'm going to borrow a couple of slides from a different talk with my colleague Jason [? Deveny ?] from IDA

on a thing called [? Bail, ?] which is motivated by Partitioned Global Address Space not being good enough anymore. So in PGAS, you get the illusion of shared memory, but you know what's local and what's not. And so to get high performance, you try to keep as much as you can local. And if you occasionally have to go off and look at a priority queue on somebody else's processor, as long as you don't do it too much, you don't worry about it. You don't sweat it. You use fine-grained communication.

And that works great if you take a little bit of care and if your machine is not too bad at fine-grained global communication. My two favorite parallel supercomputers were the Cray T3E and the Cray X1 in the 1990s-- in the early 2000s. But the trouble is that this fine-grained communication doesn't work anymore with the kinds of parallel computers that we've got now. Now we've lost our T3Es and our X1s, and so you can't just go off and talk to somebody else.

You have to be willing to bundle up messages and send them back and forth and before you know it, you're back in programming in MPI again. We didn't want to do that, so we wrote a library, which we called [? xStack, ?] but I'll get to that. We wrote a library, and here's what happened. So this is a UPC. These two lines here are UPC for a very simple computation. It's sort of an indexed gather. Bigtable is a distributed array, and I am sitting here with my own local index and destination,

and I am picking things out and putting them into my basket. Random lookouts for a distributed table. Here's what it looks like in our aggregation library, [? xStack, ?] in, essentially, UPC. Wait-- I'm not going to go into it. But you're putting things on queues, and you have a library underneath you that's keeping you from-- anyway, it's not beautiful. What have we done? Well, for the applications we were looking at for these big graphs, the [? xStack ?] code is wicked fast.

That's not a technical statement, but it's very efficient in terms of-- in particular bandwidth measures. It essentially uses all it can of the machine's bisection bandwidth and injection bandwidth, but it looks awful. It's worse than Fortran 77. So not knowing the answer to that, and this is where I'm going to stop, we released a thing called [? Bail, ?] which is a plea for help. What Bail is-- well, it has our aggregation library, [? xStack, ?] and also Conveyors,

which is the current, slightly more user-friendly version of it. And it has these nine mini applications, including this indexed gather, and it's intended as a vehicle for discussion of how you should do productive large-scale distributed parallel programming on irregular objects. And what we are doing with it is trying to get other people to write, in their own languages, something with aggregation in it that can do the apps in [? Bail. ?] So here's one that Bill Carlson did with Rust--

with a Rust implementation of [? Conveyors. ?] Here are two different versions in C++, in different styles. Here's one that's a C library from Hewlett Packard enterprises. Here's one in Chapel, which actually hides so much that you can't even see what it's doing. But the idea is that we want to make parallel programming easier and more productive. We think that this notion of aggregation under the covers is going to be a necessary part of thinking about the largest parallel programs in the future. And we certainly don't want to be writing Conveyor codes in 10 years. So please help. As far as I know, nobody's ever written an aggregation library for distributed memory in Julia. Somebody should. I'll stop. Happy birthday, Alan. Thank you for having us here.

Ask anything

We've read this whole study set, so questions about it get the best answers.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent