Latest / Talk Python To Me / #207: Parallelizing computation with Dask
Transcript
- 0:00What if you could write standard NumPy and Pandas code, but have it run on a distributed
- 0:04computing grid for incredible parallel processing right from Python? How about just splitting the
- 0:09work across multi-processing to escape the limitations of the GIL right on your local
- 0:13machine? That's what Dask was built to do. On this episode, you'll meet Matthew Rockland to
- 0:17talk about its origins, use cases, and a whole bunch of other interesting topics.
- 0:21This is Talk Python To Me, episode 207, recorded February 20th, 2019.
- 0:27Welcome to Talk Python To Me, a weekly podcast on Python, the language, the libraries, the
- 0:44ecosystem, and the personalities. This is your host, Michael Kennedy. Follow me on Twitter
- 0:49where I'm @mkennedy. Keep up with the show and listen to past episodes at talkpython.fm
- 0:54and follow the show on Twitter via at Talk Python.
- 0:56Hey folks, a quick announcement before we get to our conversation with Matthew. People
- 1:01have been enjoying the courses over at Talk Python Training for years now, but one shortcoming
- 1:06we've been looking to address is to give you offline access to your content while you're
- 1:10traveling or if you're just in a location with spotty internet speeds. We also want to
- 1:14make taking our courses on your mobile devices the best they can be. That's why I'm thrilled
- 1:19to tell you about our new apps, which solve both of these problems at once. Just visit
- 1:23training. talkpython.fm/apps and download the Android version right now. The iOS version
- 1:28is just around the corner. Should be out in a week or so. You'll have access to all of your
- 1:33existing courses. But we've also added a single tap feature to allow you to join our two free
- 1:38courses, the Responder Web Framework mini course and the MongoDB quick start course. So log in,
- 1:44tap the free course, and you'll be right in there. Please check out the apps and try one of the
- 1:48free courses today. Now, let's talk Dask with Matthew. Matthew, welcome to Talk Python To Me.
- 1:54Thanks, Michael. I've listened to the show a lot. It's really an honor to be here. Thank you for
- 1:57having me. It's an honor to have you as well. You've done so much cool work in the distributed
- 2:02computing space, in the data science and computation space. It's going to be super fun to dig into all
- 2:08that and especially dig into Dask. But before we get to that, of course, let's start with your story.
- 2:13How'd you get into programming in Python?
- 2:14Yeah. So I got into programming originally actually on a TI basic calculator. So I was in math class,
- 2:20plugging along, spent my few thousand hours not being a good programmer there. Picked up some C++
- 2:25in high school, did some MATLAB and IDL and C# in college, did some engineering jobs,
- 2:32did some science. And then in grad school, just tried out Python on a whim. I found it was all of
- 2:37those things at the same time. So it was fun to work in object-oriented mode, like with C#.
- 2:43It was fun to do data analytics, like with MATLAB. It was fun to do some science work that I was doing
- 2:48in astronomy at the time, like with IDL. So it was sort of all things to all people.
- 2:51And eventually I was in a computer science department and I found that Python was a good
- 2:55enough language that computer scientists were happy with it, but also usable enough language that actual
- 3:00scientists were happy with it. I think it's probably where Python gets a lot of its excitement,
- 3:04at least on the sort of numeric Python side.
- 3:07I think that's a really nice insight. And it sounds like a cool way you got into programming.
- 3:12I feel like one of Python's superpowers is it is kind of what I think of as a full spectrum
- 3:17language. You can make it what you need it to be at the beginning. But like you said, professional
- 3:22developers and scientists can use it as well. And you kind of touched on that, right? Like you can
- 3:27use it like C# or you can use it like MATLAB or you can kind of be what you need it to be.
- 3:32But if you need more, it's not like, well, now you go right in C++. It's just like,
- 3:36we'll now use these other features.
- 3:38Yeah, definitely. I'd also say it has a lot of different parts to it. Like there,
- 3:41before there was like the web programming community and it was a community that used it kind of like
- 3:45Bash, like a sysops community. And there was the, you know, scientific community. I know those are
- 3:49all kind of the same and it's really cool to see all those groups come together and use each other's
- 3:53stuff. You see people using scikit-learn inside of a Flask app deployed with some other Python thing.
- 3:59Ansible or something, right? Yeah, for sure.
- 4:01And the fact that all those things were around makes it sort of the cool state that it's in today.
- 4:04Yeah, it's just getting better, right?
- 4:06But it was already good. It's just like connecting all the good parts.
- 4:08Exactly. It's the interconnections are building a little bit stronger across these disciplines,
- 4:12which it's kind of rare, right? There's not that many languages and ecosystems where that happens,
- 4:18right? Like think of Swift for iOS, right? Swift is a pretty cool language. It has some issues that
- 4:23I could take with it, but it's pretty cool. But it's not also used for data science and for DevOps,
- 4:27right? It's just not.
- 4:28Right.
- 4:28Yeah.
- 4:29That's pretty cool. Also, you said you did some IDL. It sounds like you were doing astronomy before,
- 4:34right?
- 4:34Yeah. This is just an undergrad. I was taking some astronomy courses. It was fun though,
- 4:38because I knew how to program and I was just really productive as a scientist because I was
- 4:43fluent in programming. That ability to get more productive was really good. It took me away from
- 4:48science and towards computer science, but in service of science. So that was my experience.
- 4:53Now you're building these platforms where legitimate world-class science is happening.
- 4:58Yeah. No, it's cool.
- 4:59Right? You must be really proud, right? To think of what people are doing with some of the software
- 5:04you're building and you're collaborating on.
- 5:05Yeah, the software that all of us build. And yeah, it's definitely very cool. It's very satisfying to
- 5:10have that kind of impact, not just in one domain, but across domains. And I get to work with lots of
- 5:15different kinds of people every day that are solving, I think, high impact problems. And yeah,
- 5:19that's definitely a strong motivator for me.
- 5:20Yeah, I'm sure it is. Programming is fun, but it's really not fun to work on a project and have
- 5:26nobody use it. But to see it thrive and being used, it really is a gratifying experience.
- 5:31Yeah. I'll go so far as to that. Programming is no longer fun. It's just the way we get things done
- 5:36and seeing them done, as you're saying, is really where a lot of the satisfaction comes from.
- 5:39Yeah, that's cool. So how about today? What are you up to these days?
- 5:42You were, to put it past tense, you were doing a lot of stuff with Anaconda Inc.,
- 5:48previously named Continuum, but same company, but recently you've made a change, right?
- 5:52Yeah. So I like to say it's the same job, just a different employer. Yeah. So I guess my job today
- 5:57is a few things. I work in the open source numeric Python ecosystem. So this is usually
- 6:03called like SciPy or PyData. And I mostly think about how that system scales out to work with
- 6:10multi-core machines or with distributed clusters. I usually do that with a project called Dask.
- 6:14That's maybe like the flagship project that I help maintain, but I'm just generally active
- 6:18throughout the ecosystem. So I talk to the NumPy developers, the Pandas developers,
- 6:22scikit-learn and Jupyter developers. I think about file formats and protocols and conventions.
- 6:27There are a few of us- Networking. Networking. Yeah. Lots of things. So generally in service
- 6:31of those science use cases or in business use cases, there's tons of things that go wrong. And
- 6:36I tend to think about whatever it is needs to get handled. But generally I tend to focus on Dask,
- 6:40which I suspect we'll talk about more today. Yeah. A tiny bit. So speaking of Dask, let's set the
- 6:46stage, talk a little bit about, you know, why does Dask exist and so on. And I guess maybe start with a
- 6:53statement that you made at PyCon, which I thought was pretty interesting. And you said that Python has
- 6:59a strong analytical computation landscape and it's really, really powerful, like Pandas and NumPy and
- 7:05so on. But it's mostly focused on single core computation and importantly, data that fits into RAM.
- 7:11You want to elaborate on that a little? Sure. So everything you just said, so all of those libraries,
- 7:17so NumPy and Pandas and scikit-learn are loved today by data scientists because the APIs are,
- 7:23they do everything they want them to do. They seem to be well tailored to their use cases.
- 7:26And they're also decently fast, right? So they're not written in pure Python. They're written in C,
- 7:30Fortran, C++, Cython, LLVM, whatever. Right. And so much of the interaction is like,
- 7:36I have the data in Python. I just pass it off. Or maybe I don't even have it in Python. I have like
- 7:41a NumPy array, which is a pointer to a data down in C level, which I then pass that off to another
- 7:46part. And then internally down in C, it cranks on it and gives it back like five or something,
- 7:51right? Like, so it's not, it's a whole, I think the whole story around performance and is Python
- 7:58slow, is Python fast? Like it gets really interesting really quick because of those types of things.
- 8:04Yeah. So we're, we have really nice usable Python APIs, which are kind of like the front end to a
- 8:08data scientist. And that's hitting a backend, which is C++ Fortran code, which is very fast.
- 8:13And that combination is really useful. Those libraries also have like now decades of expertise,
- 8:19PhD theses thrown into them, just tons of work to make them fit. And people seem to like them a lot.
- 8:25And it's also not just those packages. There's hundreds of packages on top of NumPy Pandas
- 8:29scikit-learn, which do biology or do signals processing or do time series forecasting or do whatever.
- 8:35And there's this ecosystem of thousands of packages, but that code, that code that's very
- 8:41powerful, it's really just powerful on a single core, usually on data that fits in RAM. So as sort
- 8:46of big data comes up or as these clusters become more available, the whole PyData SciPy stack starts
- 8:51to look more and more antiquated. And so the goal that I was working on for a number of years and
- 8:56continue to work on is how do we elevate all of those packages, you know, NumPyPanda,
- 9:00scikit-learn, but also everything that depends on them to run well on distributed machines,
- 9:04to run well on new architectures, to run well on large data sets? How do we sort of refactor an
- 9:09ecosystem? That's a really hard problem.
- 9:11You know, that's a super hard problem. And it's, I think, one of the challenges that PyPy,
- 9:16P-Y-P-Y, the JIT compiled alternative to CPython has such, I think that would have really taken off
- 9:24had it not been for, yes, we can do it this other way, but you have to lose NumPy,
- 9:30or you have to lose this C library, or you lose the C speedups for SQLAlchemy, or whatever, right?
- 9:36You're trying to balance this problem of like, I want to make this distributed and fast and parallel,
- 9:40but it has to come along as is, right?
- 9:43Right. Yeah, we're not going to rewrite the ecosystem. That's not a feasible project today.
- 9:47Right. I mean, theoretically, you could write some alternate NumPy, but people trust NumPy.
- 9:53And like you said, it's got so much polish, it's insane to try to recreate it.
- 9:57Yeah. It also has, even if you recreated it, there's a lot of weight on it. A lot of other
- 10:02packages depend on NumPy in very arcane ways, and you would have a hard time reproducing all of those.
- 10:06Right. Yeah. It's like boiling the ocean, or trying to boil the ocean, pretty much. Okay. And then,
- 10:13so that's the problem is like, we have problems that are too big for one machine. We have great
- 10:20libraries that we can run on one machine. How do you take that ecosystem and elevate it in a way
- 10:26that's roughly the same API, right? We had certain things like that, right? Like Spark,
- 10:32for example, is one where you can do kind of distributed computation, and there's Python
- 10:37interactions with Spark, right?
- 10:38Yeah, definitely. But Spark is again, going down that rewrite path, right? Spark is not using NumPy
- 10:43or Pandas. They're rewriting everything in Scala, and that's just a huge undertaking. Now,
- 10:46they've done a great job. Spark is a fantastic project. If Spark works for you, you should use
- 10:50it. But if you're used to Pandas, it's awkward to move over. Most good Python Pandas devs that I know
- 10:55who moved to Spark eventually move to Scala. They eventually give up the ecosystem,
- 10:58they move over. And that makes sense, given how things work.
- 11:01Right.
- 11:01But if you wanted to say...
- 11:02Because if you're going to work there, you might as well be native in that space, right?
- 11:05But if you wanted to say use NumPy, there is no Spark NumPy, nor is there a Spark SciPy,
- 11:09nor is there a Spark time series prediction.
- 11:12Everything built on it.
- 11:13Yeah. So Spark really handled sort of the Pandas use case to a certain extent,
- 11:18and like a little bit of the scikit-learn use case. But there's this other sort of 90%
- 11:22ecosystem that's not handled. And that's where Dask tends to be a bit more shiny.
- 11:26Right. And isn't... I don't do much with Spark, so you'll have to keep me honest here. But isn't
- 11:32Spark very like MapReduce-y? It has a few types of operations and pipelines you can build,
- 11:38but you can't just run arbitrary code on it, right?
- 11:40Yes and no. So yes, underneath the hood, from a distributed assistance point of view,
- 11:45Spark implements sort of the same abstraction as MapReduce, but it's much more efficient and it's
- 11:49much more usable. The APIs around it are much nicer. So if you do something like a group
- 11:53bi-aggregation, that is sort of a mapping and then a production under the hood. And so as long as you
- 11:59sort of stay within the set of algorithms that you can represent well with MapReduce, Spark is a good fit.
- 12:04Not everything in the sort of the PyData SciPy stack looks like that, it turns out. And so we looked at
- 12:08Spark early on and, hey, can we sort of use the underlying system to paralyze out PyData? The answer
- 12:12came back pretty quickly, no. It's just not flexible enough.
- 12:15Yeah. And you know, it's, I love that this format is audio, but for this little part, I wish we could
- 12:21show some of the pictures that you've had and some of your presentations and stuff, because
- 12:26the graphs of how all the data flows together is super, super interesting and complicated and
- 12:31sort of self-referential and all sorts of stuff.
- 12:33Yeah, no, those visuals are really nice and it's nice that they're built in. You get a good sense of
- 12:37what's going on.
- 12:37Yeah, it's cool. All right. So let's talk about Dask. You've mentioned it a couple of times.
- 12:42Dask is a distributed computation framework focused on parallelizing and distributing the data science
- 12:51stack of Python, right?
- 12:52Yeah. So let me describe it maybe from a 10,000 foot view first, and then I'll dive in a little bit.
- 12:57So from a 10,000 foot view, the tagline is that Dask scales PyData. Dask was designed to parallelize
- 13:02the existing ecosystem of libraries like NumPy, Pandas, and scikit-learn, either on a single machine,
- 13:07scaling out from memory to disk using all of your cores, or across a cluster of machines.
- 13:11So what that means is if you like Pandas, you like NumPy, and you want to scale those up to
- 13:16many terabytes of data, you should maybe investigate Dask. So diving in a little bit, Dask is kind of
- 13:22two different levels. I'll describe it Dask at a low level first, and then a high level. So at a low
- 13:26level, Dask is a generic Python library for parallel computing. Just think of it like the threading
- 13:31module or like multiprocessing, but just more. There's more sophistication in there, it's more
- 13:36more complex. It handles things like parallelism, like task scheduling, load balancing, deployment,
- 13:42resilience, node fallover, that kind of stuff. Now using that very general purpose library,
- 13:47we've built up a bunch of libraries that look a lot like PyData equivalents. So if you sort of take
- 13:54Dask and NumPy and smash them together, you get DaskArray, which is a large scalable array
- 13:59implementation. If you take Dask and Pandas and squash them together, you get DasDataFrame,
- 14:03which uses many PandasDataFrames across a cluster, but then can sort of give you the same Pandas API.
- 14:08So it looks and feels a lot like underlying sort of normal libraries, NumPyrePandas, but it scales
- 14:14out. So today when people talk about Dask, they often mean DasDataFrame or DaskArray.
- 14:20Yeah. So just to give people a sense, like this, when you interact with one of these, say,
- 14:25DaskArrays, it looks like a NumPyArray. You treat it like a NumPyArray mostly. But what may
- 14:32actually be happening is you might have 10 different machines in a cluster. And on each
- 14:38of those machines, you might have some subset of that data in a true NumPy array, right? And that's,
- 14:43they know how to coordinate operations. So if you do like a dot product on that with some other bit,
- 14:48it can figure out the coordination and communication across all the different
- 14:51machines in the cluster to compute that answer in a parallel way. But you think of it as like,
- 14:57well, I just do a dot product on this array and we're good, right? Just like you would in NumPy.
- 15:01That's exactly correct. Yeah. So Dask is like a very efficient secretary. It's doing all the
- 15:05coordination work. NumPy is doing all the work on every node. And then we've written a lot of
- 15:09parallel algorithms around NumPy that teach you how to do a big matrix multiply with a lot of small
- 15:13matrix multiplies. Or on the pandas side, you know, a big join with a lot of smaller joins.
- 15:17That sounds like a lot of coordination and a challenging problem to do in the general sense.
- 15:23Yeah, it's super fun.
- 15:24The general solution of that. Yeah, I bet it is. A lot of linear algebra and other types of stuff in
- 15:30there, I'm guessing.
- 15:30Sure. Or a lot of pandas work or a lot of machine learning work.
- 15:32Yeah, yeah.
- 15:34Or a lot of other work. So I want to point out here that the lower level Dask library,
- 15:38the thing that just does that coordination, is also used separately from NumPy and pandas. And I'm
- 15:42sure we'll get to that in the future. But so Dask is sort of this core library that handles parallelism.
- 15:46You can use it for anything. There's also like a few big uses of it for the major PyTadet libraries.
- 15:52Yeah. We have Dask Array and we have Dask DataFrame and so on. And these are really cool. And
- 15:57we said the API is really similar, but there's one significant difference. And that is that
- 16:04everything is lazy, right? Like a good programmer?
- 16:07Sure. So Dask Array and Dask DataFrame do both do lazy operations. And so yeah, so at the end of your,
- 16:13you know, you do DataFrame, you do, you know, read parquet, filter out some rows,
- 16:17do a group aggregation, get out some small results. You then call .compute. At the end of that,
- 16:22there's a method on your Das DataFrame object. And that will then ship off the sort of recipe for
- 16:27your computation off to a scheduler, which will then execute that and give you back a result,
- 16:31probably as a pandas DataFrame.
- 16:33There's two major parts here. One is the data structures that you talked about. And the other
- 16:37is the scheduler idea, right? And those are almost two separate independent things that make up Dask.
- 16:42Two separate code bases even.
- 16:43Okay.
- 16:46This portion of Talk Python To Me is brought to you by Linode. Are you looking for hosting that's
- 16:51fast, simple, and incredibly affordable? Well, look past that bookstore and check out Linode at
- 16:56talkpython.fm/Linode. That's L-I-N-O-D-E. Plans start at just $5 a month for a dedicated server
- 17:03with a gig of RAM. They have 10 data centers across the globe. So no matter where you are or where your
- 17:08users are, there's a data center for you. Whether you want to run a Python web app, host a private
- 17:13Git server, or just a file server, you'll get native SSDs on all the machines, a newly upgraded
- 17:18200 gigabit network, 24-7 friendly support, even on holidays, and a seven-day money-back guarantee.
- 17:25Need a little help with your infrastructure? They even offer professional services to help you with
- 17:30architecture, migrations, and more. Do you want a dedicated server for free for the next four months?
- 17:34Just visit talkpython.fm/Linode.
- 17:37I want to dig into the schedulers because there's a lot of interesting stuff going on
- 17:43there. One thing that I think maybe it might be worth digging into a little bit for folks is this
- 17:49demo that you did at PyCon around working with, basically you had this question you want to answer,
- 17:56it's like, what is the average or median tip that a person gives to a taxicab driver plotted by time of
- 18:04day? You know, like Friday evening, Monday morning, and so on. And so there's a huge data set,
- 18:10maybe you can tell people where to get it, but it's the taxicab data set for some year,
- 18:15and it's got like 20 gigs on disk and 60 gigs in memory. Now, I have a MacBook Pro here that's like
- 18:22all knobs to 11, and that would barely hold a half of that data, right? So like even on a high-end
- 18:28computer, it's still like, I need something more to run this because I can't load that into memory.
- 18:34Well, to be fair, actually, that's not by like big data standards, it's actually pretty small.
- 18:38People use Dask on like 20 terabytes rather than 20 gigabytes pretty often. But you're right that
- 18:42it's like, it's awkward to run on a single machine.
- 18:44Yeah, you can do a lot of paging.
- 18:45Yeah, it's a pretty easy data set, though, to run in a conference demo, just because it's
- 18:49pretty interpretable.
- 18:50Yeah.
- 18:50Yeah.
- 18:50Everyone can immediately understand average tip by time of day and day of the week.
- 18:54Yeah, so it's a good demo. I'll maybe talk through it briefly here,
- 18:58but I encourage people to look at the PyCon. There's probably PyCon 2017, I think, for Dask.
- 19:02Yeah, and I'll put a link to the talk in the show.
- 19:04Yeah, so in that example, we had a bunch of CSV files living on like Amazon S3 or Google
- 19:10Cloud Storage, I don't remember which.
- 19:11Yeah, Google Cloud Storage.
- 19:12And you could use the pandas read CSV function to read a bit of those files, but not the entire
- 19:17thing. But if I had to read everything, it would fill up RAM and pandas would just halt.
- 19:21And that's kind of the problem we run into in PyData today when we hit big data. Everything's
- 19:25great to run out of RAM, then you're kind of, you're out of luck.
- 19:28So we sort of switched out the import of pandas for DasDataFrame, called the DasDataFrame
- 19:33read CSV function, which has all of the same keyword arguments of pandas read CSV, which
- 19:37if you know pandas are numerous. And sort of reading one file, we sort of give it a glob
- 19:41string. We'd ask it to read all the files.
- 19:43Yeah, we'd like did normal pandas API stuff. I think we filtered out some bad rows or like
- 19:49some free rides in New York City that we had to remove. We made a new column, which is
- 19:53a tip fraction. We then use pandas datetime functionality, I think, to group by the hour of the day.
- 19:58And the day of the week. And if you know pandas, like that API is pretty comfortable to you.
- 20:03Just the data's too big.
- 20:04Yeah, it was the same experience, pandas. Like we switched out the import, we put a star in
- 20:09our file name to read all the CSV files. We might have asked for a cluster. So we might
- 20:13have asked something like Kubernetes or Yarn or Slurm or some other cluster manager to
- 20:17give us a bunch of Dask workers. That one's probably using Kubernetes because it's on Google.
- 20:20Those showed up. So Google was fine enough to give us virtual machines. We deployed Dask on
- 20:25them. And then, yeah, then we hit compute. And then all of the machines in our cluster
- 20:28went ahead and they probably called little pandas read CSV functions on different ranges in those CSV
- 20:34files coming off of Google Cloud Storage. They then did different group operations. They did some
- 20:39filtering operations on their own. They're probably somewhat related to the ones that we asked them to
- 20:43do, but a little bit different. They had to communicate between each other. So those machines
- 20:47had different pandas data frames. They had to share results back and forth between each other.
- 20:50If one of those machines went down, Dask had to ask for a new one or had to recover the data that
- 20:55machine had. And at the very end, we got back at pandas data frame and we plotted it. And I think
- 21:00the punchline for that one is that the tips for like three or 4 a.m. are absurdly high. It's like
- 21:0640% or something like that.
- 21:07Yeah. Did you have any insight why that is? Do people know?
- 21:12I mean, the hypothesis is that it's people coming home from bars. I was actually giving the same demo
- 21:15at a conference once and someone was like, oh, filter out all the short rides and I'll bet it
- 21:20goes away. And so you did that and the spike does go away. And so it's probably just people getting
- 21:24$5 cab rides from the bar. And we were looking at tip fraction, which is sort of going to have a lot
- 21:29of noise. But it was fun because this guy said, hey, try this thing out. And he knew how to do it.
- 21:33He'd never seen Dask before. He'd just known pandas before. Gave him the keyboard. He typed in the
- 21:37pandas commands and it just worked. We got a new insight out of it. And so that sort of experience
- 21:42shows us that a tool like Dask data frame gives us the ability to do pandas operations,
- 21:47to extend our pandas knowledge, but across a cluster. That data set could have been 20 terabytes
- 21:51and the same thing would have worked just fine. You would have wanted more machines. It would have
- 21:55been fine. Wait, or one more time. One more time. Yeah. So Dask also works well on a single machine
- 21:59just by using small RAM intelligent ways. Oh, it does. Okay. So it can be more efficient.
- 22:03You could give it a ton of data, but it can realize I can't take it all in one big bite. I got to eat
- 22:09the elephant sort of thing. Yeah. So if you can run through your computation, a small RAM,
- 22:12Dask can usually find a way to do so. And so that's actually like Dask can be used on clusters. And
- 22:16that's the flashy thing to show to people at a PyCon talk. But most Dask users are using just their
- 22:22laptops. So for a long time, Dask actually just ran on us on single machines for the first year of its
- 22:26life. We built all the parallel algorithms, but didn't have a distributed scheduler. And there people
- 22:30just wanted to sort of stream through their data, but with pandas or NumPy APIs. So people were
- 22:35dealing with 100 gigabyte data sets on their laptops pretty comfortably.
- 22:38Oh, that's interesting. I didn't realize that that was a thing it could do. That's cool.
- 22:41Could it be used in the extreme? Like if I've got a really small system with not much RAM at all,
- 22:49I'm thinking like little IoT things. Could it let me process like not big data,
- 22:53but like normal data and like a tiny device?
- 22:55Sure. Depending on how much data or how much you're looking for. Sure.
- 22:59Yeah. Okay. Interesting. That's a super cool feature. Now, one of the first things that struck me
- 23:03when you ran this, like obviously you've got all these machines. I think you had 32 systems with
- 23:09two cores each when you ran the demo and it went really quickly, which is cool. I expected it to
- 23:14come up with a graph and you could say, run it, but we can't even run it locally here. It is much,
- 23:18you know, in 10 seconds or something. But instead, what I saw when you did that was there's like a
- 23:24beautiful graph that's alive and animated describing like the life of your cluster and the computation
- 23:29and like different colors, meaning different things. Can you describe like that diagnostic
- 23:34style page? And so people know. Yeah, sure. It's hard to describe a picture, much less like an
- 23:40interactive dashboard. But yeah, so maybe I'll describe a little bit of like the architecture
- 23:44of Dask first. I'll make this a bit more clear. Okay. So Dask has a bunch of workers that are on
- 23:49different machines that are doing work, holding onto data, communicating with each other. Then there's a
- 23:53centralized scheduler, which is keeping track of all those workers. This is like the,
- 23:57like the foreman at a job site, maybe of all these workers telling the workers what to do,
- 24:01telling them to share with each other, et cetera. And that foreman, that scheduler has a ton of
- 24:06information about what all the workers are doing, all the tasks that are being run, the memory usage,
- 24:11network communications, you know, file descriptors that are open on every machine, et cetera.
- 24:15And in trying to benchmark and profile and debug a lot of Dask work, we found that we wanted access to
- 24:21all that information. And so we built this really nice dashboard. And so, yeah, it tells you all that
- 24:26information. You saw one page at that demo, but there are like 10 or 20 different pages of different
- 24:31sets of information. So there's just a ton of state in the scheduler. And we wanted to expose all that
- 24:36state visually. This ends up being, it was originally designed for the developers, but it ends up being
- 24:40critical for users because understanding performance is really hard in the distributed system, right?
- 24:45Our understanding of what is fast and slow in a single machine gets totally turned around when you
- 24:49start adding concurrent access to disk and network communications and everything. So yeah, it's a live
- 24:55dashboard. We used Bokeh. That's a Bokeh server application to build it. So it's got, you know,
- 25:00it's updating at something like a hundred milliseconds frame rates. So it looks live to the human eye. Yeah.
- 25:05It's showing you progress. It's showing you every task that gets done and when it gets done and where
- 25:09it gets done. It's showing you memory use on all different machines. You can dive in. You can actually
- 25:13get like line by line profiling statistical information on all of your code.
- 25:18So that coordinate across machines. So like this function is taking this long, but actually it's
- 25:22summing up the profiling across all the cluster. So the scheduler is just aware of everything and the
- 25:27workers are all gathering tons of information. There's tons of diagnostics on that machine.
- 25:30Yeah. So maybe a way to say this is that in order to make good decisions about where to schedule certain
- 25:35tasks, DAS needs to have a bunch of information about how long previous tasks have taken, the current
- 25:39status everywhere. And so we've gotten very, very good at collecting telemetry and keeping it
- 25:45in a nice index form on the scheduler. And so now that we have all that information,
- 25:48we can just present to people visually.
- 25:50Might as well share.
- 25:50Yeah. I find myself sometimes using DASC just on sequential computations just because I want
- 25:55the dashboard. Like I don't want parallelism. I just want the dashboard. It's just the best
- 25:58profiler I have.
- 25:59It is a good insight into what's happening there. That's super cool. And I love that it's live. So
- 26:04it seems really nice. I was surprised at how polished that part of it was.
- 26:08That is honestly just due to Bokeh. If people, if they like dashboards, go look at Bokeh server.
- 26:13I didn't know any JavaScript. I didn't know about Bokeh before. It was super easy to use.
- 26:17I integrated it in my application. It was clean. It was nice. And it looks polished, as you said.
- 26:21That's super cool. Now you did say that you can run DASC locally and there's a lot of advantages
- 26:26to doing that as you already described, but it's super easy, right? Maybe just describe,
- 26:31like it's just a couple of lines to set up a little mini cluster running on your system,
- 26:36right?
- 26:37Yeah. So it's even easier than that, but yes. So if you do from DASC, so if you, first
- 26:40of all, you would pip install DASC or content install DASC. It's a Python library. It's pure
- 26:45Python. You would then, if you want the sort of the local cluster experience with the dashboard
- 26:49and everything, you say from DASC, I would import client. And then you create a client, which
- 26:53with no arguments, it would create for you like a few workers on your local machine and a scheduler
- 26:57locally. And then all the rest of your DASC work would just run on that. You also don't need
- 27:01to do that. You can just import DASC and there's a thread pool waiting for you if you don't
- 27:05set anything up. So a lot of people, again, don't use the distributed part of DASC. They
- 27:10just use DASC locally and DASC can operate just as a normal library. It spins up a thread
- 27:14pool, runs your computations there and you're done. So there's no actual setup you need to
- 27:18do.
- 27:18Right.
- 27:18Sorry. There was a great tweet about maybe a few weeks ago. Someone was using the X-Array
- 27:23library. X-Array is a popular library for array computing in like the geoscience world.
- 27:28Someone says like, yeah, someone was recommending X-Array and DASC on Twitter. And someone says,
- 27:32yeah, I've heard about X-Array. Use it all the time. It's great. Never heard of DASC though.
- 27:35Don't know what you're talking about. And it was hilarious because X-Array uses DASC under
- 27:39the hood. The guy had just never realized that he was using DASC. So that's a real success
- 27:43point.
- 27:43Yeah. If you don't have to poke your head up and like make it really hard and obvious that
- 27:48this thing is part of it, right? That's great.
- 27:50DASC had disappeared into being just infrastructure.
- 27:52Yeah. So another thing that I thought was a super cool feature about this is you were
- 27:58talking about some kind of working with a really big tree of data, right? And you start
- 28:04processing it and it's going okay, but it's going somewhat slowly and it's a live talk with
- 28:10not that much time. So you're like, all right, well, let's add some more workers to it. And
- 28:14while the computation is running, you add like 10 more workers or something. And it just on
- 28:19your cool bokeh graph and everything, you just see it ramp up and take off. And so you can
- 28:23dynamically add and remove these workers to the cluster, right?
- 28:27Yeah, definitely. So DASC is all the things you'd expect from any modern distributed system.
- 28:32It handles resilience, handles dynamically adding things. You can deploy it on any common job
- 28:37scheduler. So it does sort of all the things that you'd expect from something like Spark,
- 28:40you mentioned before, or TensorFlow or Flink or any of the sort of popular attribute systems today,
- 28:46but it does sort of adjust those things. So you can sort of sprinkle in that magical dust
- 28:50into existing projects. And that's really the benefit. Yeah. So we focus a lot on how do we
- 28:55add clusters efficiently or how do we add workers to a cluster dynamically?
- 28:57Yeah. It seems really useful. Just as you're doing more work, you just throw it in. And
- 29:02I'm guessing these clusters can be long lived things and different jobs can come and go. And
- 29:06are they typically set up for like research groups or other people in longer term
- 29:11situations or are they like sprung up out of Kubernetes, like it burst into the cloud and
- 29:16then go away?
- 29:17I'm going to say both actually. So what we'll often see is that the institution, which will
- 29:21have something like Kubernetes or Yarn or Slurm, and they'll give their users access to spin up
- 29:26these clusters. So an analyst will sit down at their desk, they'll open up a Jupyter notebook,
- 29:29they'll import DASC, use one of the DASC deployment solutions to ask for Kubernetes DASC cluster.
- 29:35Then like their own little scheduler and work rules will be created on that machine,
- 29:39on that cluster. They'll do some work for an hour or so, and they'll go away. And that cluster will go
- 29:43away. What IT really likes about the sort of adding and removing of workers is that we can add and
- 29:49remove workers during their computation. So previously they would go into the cluster, they'd ask for,
- 29:53hey, I want 100 machines. They'd use those machines for like a minute while they load their data,
- 29:57and they would stare at a plot for an hour. And so it's not so much the ability to add new workers,
- 30:01it is the ability to remove those workers when they're not being used. This gives like really good
- 30:05utilization. You can support a lot more people who have really bursty workloads. So a lot of data
- 30:10scientists, a lot of scientists, their analysis is very bursty. They do a bunch of work and they stare
- 30:15at their screen for half an hour. They do a bunch more work and they stare at the screen for half an
- 30:19hour. And so that sort of dynamism is really helpful in those sorts of use cases.
- 30:22Yeah, I can imagine. That's super cool. Now we talked about the DAS data frame and DAS array and
- 30:28those being basically exact parallels of the NumPy and Pandas version. But another thing that you can do
- 30:37is you can work in a more general purpose way with this thing called a delayed and a compute, right?
- 30:43Which will let you take more arbitrary Python code and fan it out in this way, right?
- 30:48Yeah. So let me first add a disclaimer. DAS data frame and DAS array are not exactly like
- 30:53NumPy and Pandas. They're just very close. Close enough, you'll be fine.
- 30:55Similar, okay.
- 30:56If I don't say that, people will yell at me afterwards. So yeah, so the creation of DAS
- 31:00delayed is actually really interesting. So when we first built DAS, we were aiming for something that
- 31:05was Spark-like. Like, oh, we're going to build this like very specific system to parallelize NumPy and
- 31:10parallelize Pandas and that'll handle everything. Everyone was built on top of those things. That did not
- 31:14end up being the case. Some people definitely wanted parallel Pandas and parallel NumPy,
- 31:18but a lot of people said, well, yeah, like I use NumPy and Pandas, but I don't want a big NumPy
- 31:22and Pandas. I'm using something that's like really different, really custom, really bespoke.
- 31:25And they wanted something else as though we had built like a really fast car. And they said,
- 31:31great, that's a beautiful car. I actually just want the engine because I'm building a rocket ship
- 31:35or I'm building a submarine or I'm building like a mechatronic cat or something.
- 31:39It turns out that like in the Python space, people build like really diverse things. Like
- 31:46Python developers are just on the forefront. They're doing new things. They're not solving
- 31:50the same classic business intelligence problem over and over again. They're building things that are new.
- 31:54And so DAS delayed was like a really low-level API where they could build out their own task graphs,
- 31:59their own parallel computations, sort of one chunk at a time using normal Python for loops.
- 32:04So it allows you to build like really custom, really complex systems with normal looking Python
- 32:09code, but still get all the parallels in the task and provide. So you still get the dashboard,
- 32:13you still get the resilience. You can build out your own system in that way.
- 32:15Yeah. You even have the graph and the dashboard, as you said, which is really cool.
- 32:19Yeah.
- 32:19I love it. So when I saw that, I was thinking, well, this is really interesting. And I see how that lets
- 32:25me solve a more general numerical problem. Could I solve other things with it, right? Like suppose I have
- 32:31some interesting website that needs better performance, right? I've got something that
- 32:36has really nothing at all to do with computation. Maybe it talks to databases or other things,
- 32:41right? Could I put a DASC backend on like a high-performance website and get it to do,
- 32:48you know, bizarre cluster computations to go faster? Or is it really more focused on just data science?
- 32:53Yeah. So people would use DASC in that setting in the same way they might use like a multiprocessing
- 32:58pool or a thread pool, or Celery maybe, but they would scale it out across a cluster.
- 33:03So DASC satisfies like the concurrent futures interface, if you use concurrent futures,
- 33:07and also does async away stuff. So people definitely integrate it into systems like what you're talking
- 33:10about. I think at UC Berkeley, there's a project called Cesium that does something like that.
- 33:14I gave a talk at PyGotham like a year or two ago that also talked about that. So yeah,
- 33:19like people definitely integrate DASC into more webby kinds of systems. It's not accelerating
- 33:25the web server. It's just accelerating the sort of computations that the web server is hosting.
- 33:29It's useful because it has like millisecond latencies and scales out really nicely and
- 33:34is like very Pythonic. It fits all the Python APIs you'd expect.
- 33:37Yeah. And the fact that it implements async and await is super cool. If you use it with something
- 33:41like Sanic or Court or one of these async enabled web frameworks, it's just a line, a weight,
- 33:47some execution, and the scalability, you know, spreads maybe just some DASC Kubernetes cluster or
- 33:54something. That's pretty awesome. You talked about the latency and I was pretty impressed
- 33:58with how those were working. You were quoting some really good times. And actually you said
- 34:02that's one of the reasons you created your own scheduler and you didn't just try to piggyback on
- 34:07Spark is because you needed extremely low latency because it's very, it's kind of chatty, right? If I'm
- 34:12going to take the dot product of a thing that's all over the place, they've got to coordinate quite a bit
- 34:16back and forth, right? That can't be too bad.
- 34:18Yeah. So Spark actually internally has okay latencies today. It didn't at the time,
- 34:22but they're also at sort of the millisecond range where Spark falls down as in complexity.
- 34:25They don't handle sort of arbitrary task graphs. Sort of the other side of that is systems like
- 34:30Airflow, Luigi, and Celery, which can do more arbitrary task graphs. You can say, you know,
- 34:35download this particular file. And if it works, then email this person, or if it doesn't work,
- 34:39parse this other thing. You can build these dependencies into Airflow, Luigi, Celery.
- 34:43Where those things fall down is that they don't have good inner task communication. So you can't
- 34:48easily say, I've got these two different pandas dataframes with different machines,
- 34:51have them talk to each other. They don't handle that. They also have long latencies in sort of
- 34:55the like tens of hundreds of milliseconds, which can be...
- 34:58Right. Which is not that long, but when you amplify it across, you know, a thousand times,
- 35:02then all of a sudden it's huge.
- 35:03Yeah. Or when your pandas computations take 20 milliseconds or one millisecond,
- 35:07and you want to do a million seconds, then suddenly latency does become a big issue. So we needed sort of
- 35:11the scalability and performance of Spark, but with the sort of flexibility of Airflow,
- 35:17Luigi, Celery. And that's sort of where Dask is sort of that mix between those two camps.
- 35:21This portion of Talk Python To Me is sponsored by Backlog from NewLab. Developers know the importance
- 35:29of organization and efficiency when it comes to collaborating on a team. And Backlog is the
- 35:34perfect collaborative task management software for your team. With Backlog, you can create tasks,
- 35:39track bugs, make changes, give feedback, and have team conversations right next to your code. You track
- 35:44progress with features like Gantt and burndown charts. You document your processes right alongside your
- 35:50wikis. You can integrate with the tools you use every day like Slack, Jira, and Google Sheets. You can
- 35:54automatically register issues from email or web form submissions. Take your work on the go using their
- 35:59top-rated mobile apps available on Android and iOS. Try Backlog for your team for free for 30 days using
- 36:05our special URL at talkpython.fm/backlog. That's talkpython.fm/backlog.
- 36:14I was really impressed with the low latency that you guys were able to achieve. And so maybe that's a good
- 36:18way to segment over to some of the internal implementations. You talked about using G-event,
- 36:23Tornado. What are some of the internal pieces that are at work there?
- 36:28Yeah. So on the distributed system, we use Tornado for concurrency. This is because we're
- 36:32supporting both Python 2 and 3 at the time. Tornado is becoming more asyncIO friendly. That's sort of
- 36:37becoming more common. So Tornado for concurrency. Also Tornado a little bit for TCP communications,
- 36:41although we've had to improve Tornado's bandwidth for high-performance computers.
- 36:46That's cool. So has Tornado gotten a little bit better because you guys have been
- 36:49pushing it to the limit? Yeah, definitely.
- 36:50That's good. Yeah, that's good.
- 36:52Dask touches a ton of the ecosystem. And so Dask developers tend to get pretty comfortable with
- 36:57lots of other projects. So Antoine Petroux used to work on Dask a lot. He did a lot of the
- 37:01networking stuff in Python, and he also worked on Tornado and did lots of things. So he was handling that.
- 37:06So yeah, Tornado for concurrency and TCP communication. So all the Dask workers are
- 37:11TCP servers that connect to each other. So it's kind of like a peer-to-peer application.
- 37:15A bunch of just raw, basic Python data structures for our internal state, just because those are
- 37:21the fastest we can find. The Python dictionary is actually a pretty efficient data structure.
- 37:25So that's how we handle most of the internal logic. And then for computation, if you're using
- 37:29Dask data frame, we're using pandas for computation. If you're using Dask array,
- 37:32we're using numpy for computation. So we didn't have to rebuild those things.
- 37:35And then, you know, compression libraries, encryption libraries, Kubernetes libraries.
- 37:40There's sort of a broad set of things we end up having to touch.
- 37:43I can imagine. Is the cluster doing like HTTPS or other types of encrypted communication and
- 37:48stuff like that between the workers and the supervisor?
- 37:50Yeah. So not HTTPS. HTTP is sort of too slow for us. We tend to use TCP.
- 37:55Okay.
- 37:56Dask does support TLS out of the box, or SSL, you might know it as. But the comms are also
- 38:00pluggable. So we're actually looking at right now a high-performance networking library called
- 38:04UCX to do like InfiniBand and other stuff. Security is standard in that way, assuming
- 38:08you're happy with TLS.
- 38:09Yeah. Yeah. I suspect most people are. Until the quantum computers break it, and then we have
- 38:13a problem.
- 38:14Sure. Comms are extensible. We can add something else.
- 38:17It's like a quantum state algorithm.
- 38:19Yeah. Yeah. I suspect we're going to be scrambling to solve the banking problem and e-commerce
- 38:24problem faster first, though. That'll be where the real fear and panic will be. But luckily,
- 38:31that's not here yet. So this just sounds like you guys are really pushing the limits of so much
- 38:36of these technologies, which sounds like it must be a lot of fun to work on.
- 38:39Yeah. It's been a wild ride.
- 38:40I can imagine.
- 38:41Yeah. It's actually been interesting also building conventions and protocols among the community.
- 38:46I think Dask is at an interesting spot because we do talk to everybody. We talk to most scientific
- 38:52disciplines. We talk to banking. We talk to Fortune 500 companies. And we see that they all have the
- 38:58same problems. So I think recently I put together a bunch of people on file formats. Not because I care
- 39:04deeply about file formats, because I had talked to all of them. We also talked to all the different
- 39:07library developers. And it's really interesting to see, you know, OK, Tornado 4.5. Are we ready to
- 39:12drop it or not, for example? And we talked to the Bokeh developers, the Jupyter developers, the DAS
- 39:16developers, the Tornado developers. It's a well-integrated project into the ecosystem. I want to sort of like
- 39:21hang there for a moment and say that because, again, Dask was designed to affect an ecosystem,
- 39:25move an ecosystem forward, it actually has like its sort of tendrils into lots of different
- 39:30community groups. And that's been a really fun thing to see. Sort of not on a technological side,
- 39:34just on a social side. It's been very sort of satisfying and very interesting to see all these
- 39:39different groups work together. Yeah, I can imagine you could have worked with not just the library
- 39:43developers on all the different parts of the ecosystem, but you're also on the other side of
- 39:47the scientists and the data scientists and people solving really cool problems, right?
- 39:50You'd be amazed how often like climate scientists and quantitative traders have exactly the same problems.
- 39:56You know, that's something I noticed doing professional training for 10 years. You know,
- 40:01I taught a class at Edwards Air Force Base. I taught one at a hedge fund in New York and I taught one at a
- 40:07startup in San Francisco and like 80% that's the same. It's all the same, right? Like it's good
- 40:13computation. It's algorithmical thinking. It's like distributed systems. And then there's the special
- 40:18sauce that probably I don't even understand anyway, right? But it's super interesting to realize that how
- 40:23similar these different disciplines can be.
- 40:25Yeah. And from an open source standpoint, like this is new because previously all those domains had
- 40:30like a very different technology stack. Now they're all using the same technology stack. And so as a
- 40:35person who sort of is paid to think about software, but also cares about advancing humanity, it's like a
- 40:41really nice opportunity, right? We can take all this money from these quant traders, build that
- 40:45technology and then apply that technology to genomics or something.
- 40:48Right. Or climate science or something that like really needs to get it right quickly.
- 40:52That's sort of a nice opportunity that we have right now, especially in Python, I think that we can
- 40:58hire a bunch of people to do a bunch of good work that advances humanity. Also helps people rich,
- 41:04makes people rich playing the stock market, but you know, we can let that happen.
- 41:07Hey, yeah. If they're helping drive it forward, you know, it might be okay.
- 41:10Sure.
- 41:11For the good, maybe that's debatable, but probably. It sounds like such a cool project. Now maybe let's
- 41:17talk a little bit more of the human side of it. Like obviously you work a lot on it,
- 41:21as you said, but who else? Like, are there a lot of people that maintain to ask or what's the story
- 41:26there?
- 41:26I've worked on it for a while within, so we started within Continuum or what is now called Anaconda.
- 41:31And there's a bunch of other engineers within Anaconda who also work on Dask.
- 41:34They do sort of halftime something else and halftime work on Dask.
- 41:37Are they still?
- 41:37Definitely. People like Jim Criss, Tom Augsburger, Martin Durant, and others throughout the company.
- 41:41And so yeah, they'll maintain various parts of the project or push it forward. So like Jim recently has
- 41:46been working on making Dask easier to deploy on Hadoop or Spark systems using Yarn. And that's
- 41:51something that is important for Anaconda's business and also just generally useful for people. So there's
- 41:55a sort of nice overlap between helping out the open source project and also getting paid to do the work.
- 42:00Yeah.
- 42:01Outside of Anaconda, so I'm now at NVIDIA, there's a growing group at NVIDIA who's also working on
- 42:05Dask, which is pretty exciting. And also there's a bunch of other people who are working in other
- 42:09research labs or other companies who need to use Dask for their work and need to build out the
- 42:14Kubernetes connection or something like that. And they maintain that both because it's good for
- 42:18their company and also they just sort of enjoy doing that. So I would say in sort of the periphery of
- 42:23Dask, most of the work is happening in other companies and other people. And there's hundreds of people who do
- 42:29work on Dask in any given month or two.
- 42:31There's probably a lot of people that make like one or two little contributions to like fix their
- 42:36edge case, but it all adds up, right?
- 42:37There's that. There's also maybe like 20 or 30 people who are maintaining, not just adding a fix,
- 42:42but like maintaining some Dask foo package. So there's like, there's a researcher, Alistair Miles,
- 42:48who works in the Oxford area, who works on genomics processing. And he has like a Dask enabled
- 42:54genomics suite called Psyched Allel. So that's his job, right?
- 42:58So he's working on that day to day. There's, you know, the scikit-learn developers maintain the Dask
- 43:03scikit-learn connection through Joblib. So Olivier Grissell has commit rights over all of Dask. He's
- 43:07the main scikit-learn contributor. So there's a bunch of sort of, as Dask expands out into the rest of
- 43:13the ecosystem, that it's sort of being adopted by many, many smaller groups who are in other
- 43:18institutions.
- 43:19So it sounds to me like there might be some decent opportunities for folks to contribute
- 43:23to Dask in the sense that, you know, maybe there's somebody that's doing some kind of research
- 43:29and their library or something like it would really benefit from having a Dask level version of that.
- 43:36So if people are looking to contribute to open source and the data science space, are you guys
- 43:41looking for that kind of stuff?
- 43:42Yeah, definitely. I mean, you don't have to look these days. People are just doing it.
- 43:45What I would say is that there's probably, in whatever domain you're in, there's probably some
- 43:50group that's already thinking about how to use Dask in that space and jump onto that group.
- 43:55There's a lot of sort of like low-hanging fruit right now. Pick your favorite PyData library.
- 43:59Think about how it could scale. And there's probably some small effort around that currently.
- 44:03And there's a lot of, you know, if you want to get into open source, it's a great place to be.
- 44:07You're like right on the very exciting edge of big data and scalability. Things are pretty easy today.
- 44:12We've solved a lot of the like the major issues by with sort of the core projects like NumPy and
- 44:17Pandas and scikit-learn. So yeah, there's a ton of ton of pretty exciting work that's like
- 44:21just starting to pick up now. So yeah, if you're interested in open source, it's a great place to start.
- 44:25It seems like there's so many data science libraries that there's probably a lot of opportunity to
- 44:30like bring some of them into the fold. Pretty low-hanging fruit there. So let me ask you some
- 44:35kind of how wild is that type of thing. One is what's the biggest cluster you've ever seen it run on?
- 44:43The biggest I've had-
- 44:44Or heard about it running on?
- 44:45Yeah. I would say like a thousand machines is probably the biggest that I've seen.
- 44:51And that's probably like with an order of magnitude of limits today. But those machines are big machines.
- 44:56They have like 30 cores on them. Yeah. Like that's also just mostly for benchmarking. Like
- 45:00most problems in data science aren't that big. Right. Thousands sort of.
- 45:03That's awesome. I was thinking of places like CERN that have their big grid computing stuff and things
- 45:08like that. Like they could potentially spin up something pretty incredible.
- 45:12That gets used on a fair number of supercomputers today. But it's very, very rarely used on like
- 45:18the entire supercomputer. There's really no system outside of MPI that I would expect to run on the full
- 45:24like CERN federated grid. So most of the sort of data source oriented libraries end up sort of maxing
- 45:31out around a thousand machines. I mean, hypothetically you go higher, but the overheads will be enough to
- 45:36kill you. Does it have a sort of a, like how many people's hands do you have to shake to shake
- 45:40everyone's hand in a group? You know, like that in factorial type of issue. As you add more,
- 45:45does it get like harder and harder to add the next worker to the cluster or is it okay?
- 45:49No, it's fine. Everything's linear in terms of number of workers. Workers are, it's not a,
- 45:53like a mesh grid. It's workers talk to the scheduler to find out who they have to talk
- 45:56to. They'll then peer to peer talk to those people. But in any given computation, you only talk to like,
- 46:01you know, five to 10 people at once.
- 46:02Okay.
- 46:03It's fine.
- 46:03Yeah. Interesting. Okay. The other one is what's the coolest thing that you've seen
- 46:07computed or run on Dask or built with Dask?
- 46:09I'm going to say, there's things I can't, yeah, things I can't talk about, but.
- 46:13Some are, the most amazing ones are super secret.
- 46:16I'm going to point people to the Pangio project. So this is actually my most recent
- 46:19Okay.
- 46:19PyCon talk in 2018, talking about other people's work. So Pangio is pretty cool.
- 46:23Pangio is a bunch of earth scientists who are doing climate change, meteorology, hydrology,
- 46:28figuring out the earth. And they have these, you know, 100 terabyte petabyte arrays that
- 46:33they're trying to work with. They haven't quite gotten to the petabyte scale yet.
- 46:35And yeah, so they usually set up something like Jupyter hub on either a supercomputer or
- 46:40on the cloud and Kubernetes. They then analyze tens or hundreds of terabytes of data with
- 46:45X-ray or Dask around the hood and get out, you know, nice plots that show that indeed sea
- 46:50levels are rising. I think it's pretty cool in that it's good community of people. So there's
- 46:55like a bunch of different groups, NASA, universities, USGS, UK Met Office, anyone who's looking at
- 47:01large amounts of data, companies, plant labs, et cetera. So it's a good community.
- 47:05They're like figuring out how to store one copy of the data in the cloud and then have everyone
- 47:11compute on that using cool technologies like Kubernetes. They're inventing cool technologies
- 47:15like how do we store multi-dimensional arrays in the cloud. So yeah, like that's maybe a good
- 47:19effort. Not necessarily cool computation, like from a Dask perspective, it's actually pretty
- 47:24like vanilla, but it's cool to see a scientific domain advance in a significant way using some
- 47:31of these newer technologies like Jupyter hub and Dask and Kubernetes. And I like to see that
- 47:34repeat it. So I think we do the same thing with medical imaging and with genomics. So that's maybe
- 47:39like a cool example. It's not so much a technical situation, it's a community situation.
- 47:43Yeah. Well, it sounds like a cool example that could be just replicated across verticals.
- 47:48Definitely. We're starting to see that, which is really exciting.
- 47:50Okay. Those are great. So when I was looking into Dask, I ran across some other libraries that are
- 47:55like, kind of like you described, DaskFu. So there was DaskCuda, DaskML, DaskKubernetes. Do you want to
- 48:02just talk a little briefly about some of those types of things?
- 48:05Sure. And why you might use them?
- 48:06I'll go in reverse order. So DaskKubernetes is a library that helps you deploy Dask clusters
- 48:11on Kubernetes.
- 48:12So you pointed at like a Kubernetes cluster and you say, go forth and use that and it could
- 48:18just create the pods and run them in all that?
- 48:20Definitely. So it creates pods for all the workers. It manages those pods. If you ask it,
- 48:23there's like little buttons, you ask it to scale up or scale down. It'll manage all that stuff for you
- 48:27using the Kubernetes API. It presents users with like a super simple interface. They can open up
- 48:32a Jupyter notebook and just sort of play around. So that's what that does. And it has peers like Dask
- 48:36Yarn for Hadoop Spark clusters and Dask JobQ for more high-performance computing schedulers like Slurm,
- 48:42PBS, SGE, LSF. So that's what you ask for Kubernetes. That's like on the deployment side. DaskML is an effort
- 48:48to, there were a lot of sort of interesting ways of using Dask with machine learning algorithms,
- 48:53things like GLMs, Generalizing Your Models, XGBoost, scikit-learn. That were all different
- 48:59technical approaches. And DaskML is like an almost like a namespace library that collects all of them
- 49:03together, but also using the sort of scikit-learn style APIs. So if you like scikit-learn and you want
- 49:08to scale that across a cluster, either with simple things like hyperparameter searches or with large
- 49:14data things like logistic regression or XGBoost, you should look at DaskML and it'll help you do
- 49:18that. Dask CUDA is a, that's like a new thing I've been playing with since moving to NVIDIA. People
- 49:23have been using Dask with GPUs for a long time and they've developed like a bunch of weird wonky
- 49:27scripts to like set things up just the right way. There were a ton of these within NVIDIA when I
- 49:31showed up. It's just a few like nice convenient Python ways to set up Dask to run on either one
- 49:38machine with many GPUs or on a cluster of machines with lots of GPUs and how to make that easy.
- 49:42So it's kind of like Dask Kubernetes in that it's about deployment, but it's more focused on
- 49:47deploying around GPUs and there are some intricacies to doing that well.
- 49:51I imagine you can scale like crazy if you put the right number of GPUs on a bunch of machines and let
- 49:58it go.
- 49:58No, GPUs are actually pretty game-changing. It's fun.
- 50:02Yeah. It's kind of near the limits of human understanding to think about how much computation
- 50:08per second happens on a GPU.
- 50:10I think CPUs are also well beyond the limits of human understanding.
- 50:14But this is like the galaxy versus the universe, you know, like...
- 50:20Sure.
- 50:20They're both outside of our understanding.
- 50:22I should like mention that I work for NVIDIA now, so please don't trust anything I say.
- 50:25But yeah, GPUs are like fundamentally like a game changer in terms of computation. Like you can get a
- 50:30couple orders of magnitude performance increase out of the same power, which I mean, from like a science
- 50:35perspective, like has the opportunity to unlock some things that we couldn't do before. GPUs are also
- 50:39notoriously hard to program, which is why most scientists don't use them. And so that's sort of
- 50:44part of why I work at NVIDIA today. They're building out a GPU data science stack and they're using
- 50:49NASK to paralyze around it. And so it's fun to see... It's fun both to sort of grow NASK within NVIDIA and have
- 50:54another large company behind it. But also from a science perspective, like I think we can do some
- 50:59good work to improve accessibility to different kinds of hardware like GPUs that might dramatically
- 51:04change the kinds of problems that we can solve, which is exciting in different ways.
- 51:08Yeah, very incredible. And I would much rather see GPU cycles spent on that than on cryptocurrency.
- 51:13Sure.
- 51:14Although cryptocurrency is good for NVIDIA and all the GPU, the graphics card makers,
- 51:18they don't seem as useful as like solving science problems on them.
- 51:22All right. We're getting close to our time that we have left. So I'll ask you just a couple of
- 51:28quick questions before we wrap it up. So we talked about where NASK is. Like, where is it going? It
- 51:34sounds like there's a lot of headroom for it to grow. And NVIDIA is investing in it by sort of this work
- 51:40that you all are doing. And it sounds like they're also building something amazing. So yeah, what's next?
- 51:44NVIDIA aside for a moment, I'll say that NASK technologically is sort of done. The core of it,
- 51:49there's plenty of bugs and plenty of features we can add, but we're sort of at like the incremental
- 51:52advancement stage. I would say where I'm seeing a lot of change right now is in broadening it out
- 51:58to other domains. So I mentioned Panjio a little bit before. I think that's a good example of NASK
- 52:02spreading out and solving a particular domains problem. And we're seeing, I think, a lot more of
- 52:06that. So I think we'll see a lot more social growth and a lot more applications to new domains.
- 52:11That's really what I'm pretty excited about.
- 52:12That's cool. So it's like NASK is basically ready, but there's all these other parts of the ecosystem
- 52:16that could now build on it and really amp up what they're doing.
- 52:20Yeah, let's go tackle those. Let's go look at genomics.
- 52:22Yeah, for sure.
- 52:23Let's go look at imaging. Let's go look at medicine. Let's go look at all of the parts of the world that
- 52:28need computation on a large scale, but that didn't obviously fit into the sort of Spark,
- 52:33Hadoop, or TensorFlow regime. And NASK, because it's more general, can probably handle those things a lot
- 52:38better.
- 52:38Yeah, it's amazing. I guess, let me ask you one more NASK question before we wrap it up real quick.
- 52:43So NASK, is NASK 100% Python?
- 52:47The core part, yeah.
- 52:48Or near?
- 52:48Yes. You're probably also using NumPy and Pandas, which are not Python.
- 52:51Which, yeah, right, as we discussed, but yeah.
- 52:53NASK itself is pure Python.
- 52:54I think it's really interesting because you think of this really high-performance computing
- 52:59sort of core, right? And it's not written in Go or C, but it's written in Python. And I just
- 53:06think that's an interesting observation, right?
- 53:08Python is actually not that bad when it comes to core data structure manipulation,
- 53:13tuples, list, dictionaries. It's maybe like a factor of two to five slower, not a hundred times
- 53:17slower. It's also not that bad at networking. It does that decently well. Socially, the fact
- 53:21that Python had both a data science stack and a networking stack in the same language made it
- 53:26sort of the obvious right choice. That being said, I wouldn't be surprised if in a couple of years,
- 53:30we do rewrite the core bits in C++ or something, but we'll see.
- 53:33Sure. Eventually. When it's kind of finely baked and you're looking for that extra 20,
- 53:3730% here or there, right?
- 53:38Yeah, we'll see. We haven't yet reached the point where it's a huge bottleneck to most people,
- 53:42but like the climate science people do have petabyte arrays and sometimes a scheduler does
- 53:45become a bottleneck there.
- 53:46Right. It's cool. It's interesting. So final two questions. If you're going to write some
- 53:51Python code, what editor do you use?
- 53:53I use Vim, not for any particular reason. I just showed up the computer lab one day and said,
- 53:57how do I use Linux? And the guy there was a Vim user. So now I'm also a Vim user.
- 54:01I think I haven't moved off just because I'm so often on other machines. So like rich editors just
- 54:07don't move over as easily.
- 54:08Yeah. I'm on the cluster. I need to edit something. It doesn't work to fire up PyCharm and do that so
- 54:13easily.
- 54:14Right. Yeah. So Vim for now, but not religiously, just anecdotally.
- 54:18Sure. Sounds good. Yeah. I'm sure you do some stuff with Jupyter Notebooks as well every now and then.
- 54:23Sure. I'll maybe also put a plugin for JupyterLab. I think everyone should switch from the classic
- 54:27notebook to JupyterLab, especially if you're running Dask because you can get all those dashboards
- 54:31inside JupyterLab really nicely. It's a really nice environment.
- 54:33Oh yeah. That sounds awesome. All right. And then notable PyPI package. I'll go ahead and throw
- 54:38pip install Dask out there for you.
- 54:40So I'll cheat a little bit here. I'm going to list a few. First, in a theme of the NumPy space,
- 54:46I really like how NumPy is expanding beyond just the NumPy implementation.
- 54:49So there's Kupy, which is a NumPy implementation on the GPU.
- 54:53There's Sparse, which is a NumPy implementation with Sparse arrays. And there's Aura, which is a
- 54:58new date-time D type for NumPy. I like that all of these were built on the NumPy API. We're built
- 55:04outside of NumPy. I think the kind of heterogeneity is something we're going to move towards in the
- 55:08future. And so it's cool to see NumPy develop protocols and conventions that allow that kind
- 55:12of experimentation. And it's cool to see people picking that up and building things around it.
- 55:16So that's pretty exciting.
- 55:17Those are great picks. It's cool that I learned one API and now I can do other things,
- 55:23right? Like I know how to do the NumPy stuff, so now I can do it on a GPU.
- 55:26Right. Or I've got my NumPy code. I want to have better date times. I can just add this new library
- 55:31and suddenly all my NumPy code works because that's sort of extensibility, which is something that we
- 55:35need, I think, going forward.
- 55:37Yeah, absolutely. All right, Matthew. Well, this was super interesting. Thank you for being on the show.
- 55:41You have a final call to action. People want to get involved with Dask. What do they do?
- 55:44Try it out. You should go to examples.dask.org. And there's a launch binder link on that website.
- 55:51If you click on that link, you'll be taken to a JupyterLab notebook running in the cloud,
- 55:54which has everything set up for you, pretty much of examples. So you can try things out,
- 55:57see what interests you, and play around. So again, that's examples.dask.org.
- 56:00Yeah, and I also link to the Dask examples GitHub repo that you have on your account
- 56:04in the show notes. Yeah, so people can check that out too.
- 56:07Awesome. All right. Well, thank you for being on the show. It was great to chat with you and
- 56:10keep up the good work. It looks like you're making a big difference.
- 56:13Great. Thank you so much for having me, Michael. Talk to you soon.
- 56:15Yep. Bye.
- 56:15This has been another episode of Talk Python To Me. Our guest on this episode was Matthew Rockland,
- 56:22and it's been brought to you by Linode and Backlog. Linode is your go-to hosting for whatever
- 56:27you're building with Python. Get four months free at talkpython.fm/Linode. That's L-I-N-O-D-E.
- 56:34With Backlog, you can create tasks, track bugs, make changes, give feedback, and have team
- 56:39conversations right next to your code. Try Backlog for your team for free for 30 days using the special
- 56:45URL talkpython.fm/Backlog. Want to level up your Python? If you're just getting started,
- 56:52try my Python Jumpstart by Building 10 Apps course. Or if you're looking for something more advanced,
- 56:58check out our new async course that digs into all the different types of async programming you can do
- 57:03Python. And of course, if you're interested in more than one of these, be sure to check out our
- 57:07everything bundle. It's like a subscription that never expires. Be sure to subscribe to the show.
- 57:12Open your favorite podcatcher and search for Python. We should be right at the top. You can also find
- 57:17the iTunes feed at /itunes, the Google Play feed at /play, and the direct RSS feed at slash
- 57:23RSS on talkpython.fm. This is your host, Michael Kennedy. Thanks so much for listening. I really
- 57:29appreciate it. Now get out there and write some Python code.
- 57:31Bye.
- 57:32Bye.
- 57:32Bye.
- 57:32Bye.
- 57:32I'm out.