Latest / Talk Python To Me / #405: Testing in Radio Astronomy with Python and pytest
Transcript
- 0:00So you know about dependencies and testing, right? If you're going to talk to your database in your
- 0:04app, you have to decide how to approach that with your test. There are a lot of solid options you
- 0:09might pick from, and they vary by goals. Do you mock out the dB layer for isolation, or do you use
- 0:15a test dB to make it as real as possible? Or do you even just punt and use the real dB for expediency?
- 0:22What if your dependency was a huge array of radio telescopes in a rack of hundreds of bespoke
- 0:29servers? That's the challenge on deck for today, where we discuss testing radio astronomy with
- 0:36pytest and our guest, James Smith. He's a digital signal processing engineer at the South African
- 0:41Radio Astronomy Observatory and has some great stories and tips to share. This is Talk Python
- 0:47to Me, episode 405, recorded February 13th, 2023.
- 0:59Welcome to Talk Python To Me, a weekly podcast on Python. This is your host, Michael Kennedy. Follow
- 1:10me on Mastodon, where I'm @mkennedy and follow the podcast using @talkpython, both on fosstodon.org.
- 1:17Be careful with impersonating accounts on other instances. There are many. Keep up with the show
- 1:22and listen to over seven years of past episodes at talkpython.fm. We've started streaming most of our
- 1:28episodes live on YouTube. Subscribe to our YouTube channel over at talkpython.fm/youtube to get
- 1:34notified about upcoming shows and be part of that episode. This episode of Talk Python To Me is brought
- 1:40to you by Typy. They're here to take on the challenge of rapidly transforming a Bayer algorithm in Python
- 1:46into a full-fledged decision support system. Check them out at talkpython.fm/Typy, T-A-I-P-Y.
- 1:53And it's brought to you by Sentry. Don't let those errors go unnoticed. Use Sentry. Get started at
- 1:59Talk Python.fm slash Sentry. James, welcome to Talk Python To Me.
- 2:04Normally, I talk Python to computers, Michael, but this would be a first. You are a human, right?
- 2:09I am. Well, you know, you got to ask ChatGCP about that. We'll see. There's a lot of people who are
- 2:14interested in talking about Python. When I first put this podcast together, I thought, well, who's
- 2:19going to be the target audience? I thought people were really into Python. Like people will make
- 2:23things like Flask and stuff. And they're just, you know, it's kind of a big part of the world,
- 2:27but there's a ton of people who are scientists or just curious about programming who listen as well.
- 2:32So it really surprised me how many people you can talk Python to and how much they seem to appreciate it.
- 2:37So it's cool. Indeed. Yeah. But I also spend a fair amount of time talking Python to computers as well.
- 2:43Sometimes more fun, sometimes more frustrating. You never know.
- 2:46Yes, we're familiar with that. I'm sure. I'm sure. Well, you have this extra angle of it's not just
- 2:53talking to pure software, right, that lives in an internet API vacuum, but you have physical things,
- 3:01many, many physical things in radio astronomy and large arrays of telescopes and receivers and
- 3:07as we're going to talk about lots of different things. And I think that's one of the really
- 3:10interesting aspects of this episode to talk to you is Python against real world things out there and
- 3:17real time as well. Perhaps sort of to jump back and put the listeners in a bit of context. I work at
- 3:23the South African Radio Astronomy Observatory. Our sort of primary project is called Meerkat. It's a
- 3:28precursor of one of the world's biggest radio telescopes, which is planned. So the project is called SKA.
- 3:35So it stands for Square Kilometer Array, which refers to the size of the collecting area of the
- 3:40telescope that will eventually be built. It's in its beginning stages now. And that has a lot of moving
- 3:44parts right from the actual antennas that are pointing into the sky and recording radio emissions
- 3:51from the universe somewhere through down to the point where a scientist actually sits down with the data
- 3:57product in order to analyze and to write his paper that he's hoping to publish and win his Nobel Prize.
- 4:04And so everything from the beginning of the end there needs some software control. And Python is the
- 4:10sort of weapon of choice for all of those applications.
- 4:13Yeah, it's pretty interesting to see what you're going to talk about. You gave a couple of
- 4:17presentations at PyCon South Africa. Is that right?
- 4:21That's right. Yes. Last year.
- 4:23Yeah, fantastic. And people all, of course, link to those in the show notes and people can check them
- 4:28out. You got a lot of cool graphics and stuff there. And the fact that you built this real time
- 4:33aspect involving Python, which is not its normal use, perhaps, I think is really something that
- 4:40we're going to have a good time talking about as well as just how do you test something like a large
- 4:44receiver array rather than, you know, is the user logged in in the database? Yes or no. And let's
- 4:51mock that out, right? This is both, I think, very similar and yet very different, right?
- 4:56Yes, it can be. And there's a lot that you can do, but there's also some interesting gotchas,
- 5:01which we can talk about there. So, I mean, I don't know where you want to start.
- 5:06Let's get a real quick introduction with you before we get too far down in this topic. And so,
- 5:10tell people how you got into programming and astronomy and all that kind of stuff.
- 5:15Well, programming, well, both of those have become, both of those started out as hobbies and they've
- 5:20sort of become my job, which means I don't do them as a hobby anymore, which is always fun. When I was
- 5:25younger in school, I made the mistake during a summer holiday of telling my dad that I was bored.
- 5:29And so, yeah, he handed me a book and this book was programming in C, I think, I forget exactly.
- 5:36And being young and naive, I thought this was a great idea and started working my way through it.
- 5:41So, since then, I've been programming more or less continuously. It was sort of the mid to late
- 5:472000s that Python started to become more prominent and I picked that up and haven't looked back.
- 5:52Astronomy was also another hobby. In my student days, I spent many South African,
- 5:57cold South African nights looking at the stars. And then a job opportunity opened up at Sereo to do
- 6:03electronic engineering, which was the field that I trained in university. That was about seven years
- 6:09ago. And so I've been combining these sort of programming and electronic engineering and my
- 6:14astronomy hobby, which has shifted now into radio instead of optical. But yeah, I basically come from
- 6:19that. Fantastic. I remember getting a book in C thinking, oh, I'm going to learn programming and then
- 6:26read it like, okay, this, when I was pretty young, I was like, okay, this is a little bit much divide
- 6:30off at the moment, but came back to you as well. But that's how it was, right? We used to get books
- 6:34pre-internet, YouTube, and where you just fired up and say, teach me programming in the next half
- 6:40hour. With listings of code and you have to type them in and then you miss a semicolon somewhere
- 6:45and scratch your head for half a day. That's right. But I think that was a good preparation
- 6:49though. I mean, as great as Python is, it is somewhat high level. And I think it's helpful to
- 6:53have a sort of a, even if you don't often work at that level, to have an understanding of what's going
- 6:58on at a slightly lower level than what the computer is doing. It's valuable to have that experience,
- 7:02but I'm also, even though I did it professionally for a couple of years, happy that I'm not,
- 7:06I don't have to continuously work at that level, right? You can just be so more productive in
- 7:10a higher level language like Python. Indeed. Totally. Yeah. So I think you introduced this a
- 7:17little bit, but tell people about Seraro, this project, how'd you get to that place?
- 7:21Yeah. Seraro, well, I got there by responding to a job advert and, you know, interviewing and what
- 7:27have you. Seraro sort of started out as a response to the international kind of scientific project to
- 7:33build a square kilometer array telescope. The idea is to make it the most sensitive radio telescope that
- 7:38has ever been built. And when you're doing that kind of project, you want to build it in an ideal
- 7:43setting, just like optical telescopes. If you want to do proper science, you want to do it far away
- 7:48from cities where there's no light pollution. Similarly, radio telescopes, you want to do them
- 7:52where there's no radio interference. So cell phones, TV signals, wifi, that kind of stuff.
- 7:56The Southern hemisphere also has a bit of an advantage in that we can see parts of the galaxy that the
- 8:02Northern hemisphere can't. And so as this project progressed, various sites were identified.
- 8:07And ultimately the decision was made to put part of the telescope in South Africa and part of it in
- 8:12Australia. And Seraro is really the, just the organization around developing the South African
- 8:17part of that telescope. That's where we are.
- 8:20It's a very cool project. I think a square kilometer array of telescope, that's pretty impressive,
- 8:25right? And also something that's much easier to do with radio than with optical, I would imagine.
- 8:31Yes. When it comes to telescopes, bigger is better, but there reaches a point of where building a bigger
- 8:37one becomes expensive and very difficult. And so a trick that you can use in radio is called
- 8:43interferometry. So if you measure your radio waves at different points and you measure them in phase
- 8:48with each other or what they call coherently, then you can get away with making a lot of smaller
- 8:53telescopes to build up the same kind of area, which will give you the same effect as a bigger one,
- 8:58but much cheaper because you can do a lot of, a lot of smaller, cheaper telescopes. If that in a nutshell
- 9:03is really why, why these telescope arrays exist. It's very difficult to do that with optical telescopes
- 9:08because the wavelength is so short, the frequency is so high that getting, getting the, it is possible,
- 9:13it can be done, but getting the signal coherent or in phase is very, very difficult.
- 9:18I see.
- 9:18That's why we do it in radio.
- 9:19Yeah. You don't have much time. There's not much of a gap between how you've got to coordinate the
- 9:24signals across the radio, but it's even worse in optical. I see.
- 9:27Exactly. Exactly. Nice. So people who listened to the episode about imaging the black hole,
- 9:32we talked a lot about that. So, you know, I don't necessarily need to think we need to cover
- 9:37too much depth about it. But one thing I think that people might find interesting is I think,
- 9:42remember from your talk that you said, this is part, some of the work that you're doing is part
- 9:47of the deep space network for communicating with, is that right? With NASA.
- 9:51South African radio astronomy has its origins in the deep space network.
- 9:55So if you're trying to communicate with spacecraft that are outside of earth orbit,
- 9:58you need a very powerful, something that looks a bit like a radio telescope in much,
- 10:03except that you're transmitting as well, because you need to be able to talk to the,
- 10:07you know, Voyager or your Mars rover that's out there in space, but very inconveniently for
- 10:12scientific purposes, the earth rotates. So for about a third of the day, if you have a telescope
- 10:18in California, for example, I think is where one of NASA's big ones are, you know, half of the
- 10:23day you can't really talk to your, to your spaceships. NASA built a network of telescopes
- 10:28around the world. And, and one was in Australia and one was here in South Africa. And some of the
- 10:32early Mars missions were actually used the telescope in South Africa for, for communication. But that was,
- 10:38I think in the seventies, I forget my history exactly, but they got a better one in Spain.
- 10:42And so the one in, the one in South Africa was kind of converted into a facility just for science.
- 10:47And that's been operated by our national research foundation, which evolved into Sareo for the last
- 10:54sort of few years. And that's what kind of gave us our leg up.
- 10:56Yeah, exactly. It was already built and it was there. And they're like, you know what,
- 11:00instead of just let it put it on mothballs, why don't you guys do science with it? Right? That's cool.
- 11:04And, and we've been using it quite well since then. They've done, I wouldn't say groundbreaking
- 11:08science. I don't know that any Nobel prizes have happened, but we have, we have some good radio
- 11:12astronomers originally from South Africa that have used data from this telescope. So yeah.
- 11:16Excellent. All right. Let's talk about first the real time aspect, this thing that you focus
- 11:22on called the correlator, right? And maybe, maybe give us this side of the story. Cause I think this
- 11:28alone is, is pretty interesting and what you've built here with Python, you and your team.
- 11:32So from a conceptual point of view in the episode a few weeks ago, where you interviewed Dr. Sarah
- 11:38Asun, I don't know if I'm pronouncing her name correctly. The Event Horizon telescope worked by pointing
- 11:44different telescopes around the world at the same object or all radio to all, shall I say,
- 11:49all radio telescopes arrays, whether they're very long baseline, like what she used or much shorter
- 11:54have something called a correlator. And this is the thing that basically combines the signals from
- 12:00the individual telescopes in a way that is a, that enables downstream users, scientists to actually
- 12:06make sense of this data. So in order for that to work, the data needs to be in phase. It needs to be
- 12:12coherent. And at very long baselines, they do this by having each station, having their, their, their very
- 12:17own atomic clock to generate very precise reference signals.
- 12:20So as a reminder for people, maybe didn't hear that episode is, you know, the earth is curved as we
- 12:24all know, hopefully, and the radio waves come in and as it hits that sphere, they hit the different
- 12:31parts of the array. The more spread out, it is even more exaggerated, but it hits the different parts
- 12:35of the array at different times. So you have to offset those back in the signal to say, well, it came in at
- 12:41this angle, and it came in at this time. And the speed of light says this one is, you know, a nanosecond
- 12:45behind that one. So you got to figure out how to realign those. So it looks like a flat surface that they hit
- 12:51all simultaneously to look like a single picture, right? So that's the job. That's basically the job of this thing.
- 12:57So partially, you can do the first bit with just with geometry, we know what the rotation of the earth
- 13:02is, we know where our different telescopes are. And so we can calculate roughly what the time difference
- 13:07will be. The job of the correlator is once you've got those signals, and you've applied your sort of
- 13:11rough delay offset to each of those signals, the correlator will find the correlations between the
- 13:17incoming signals, simply by multiplying the signals together. Mathematically, it's not terribly
- 13:22complicated. It's really just multiplication, you know, of each pair of antennas. But it's with that,
- 13:27you may remember your from your high school mathematics, the trigonometric identity,
- 13:31when you apply to when you multiply two sine waves together, you get a sum and a difference
- 13:35product. And it's a similar kind of concept applying to not not just to abstract sine waves,
- 13:41but to radio waves that are at various frequencies. The main engineering challenge is just doing this
- 13:46fast enough for practical purposes. So in the in the example of the event horizon telescope with very
- 13:53long baseline interferometry, it's not possible to do it in real time, because
- 13:56your individual elements are just too far apart, you can't get all the data together.
- 14:01Not for math, but because the actual data quantity getting them all back and forth across the world is
- 14:06too hard. Exactly. So there's specialized hardware that takes those signals and writes them basically just straight onto hard drives. Then these hard drives are physically taken to a central location. I think Sarah did talk about that in her episode.
- 14:22Yeah, I think it was Boston and maybe Cambridge and London, something.
- 14:26One was in Europe, yes.
- 14:28No, it was Max Planck Institute in Germany is what it was, I believe.
- 14:30That's right. Yeah. One was in the States. One was in Europe.
- 14:34This portion of Talk Python To Me is brought to you by TypePy. TypePy is the next generation open source Python application builder. With TypePy, you can turn data and AI algorithms into full web apps in no time. Here's how it works. You start with a bare algorithm written in Python. You then use TypePy's innovative tool set that enables Python developers to build interactive end user applications quickly. There's a visual designer to develop highly interactive GUIs ready for production. And for inbound data streams, you can program
- 15:04against the TypePy core layer as well. TypePy core provides intelligent pipeline management, data caching, and scenario and cycle management facilities. That's it. You'll have transformed a bare algorithm into a full-fledged decision support system for end users. TypePy is pure Python and open source, and you install it with a simple pip install TypePy. For large organizations that need fine-grained control and authorization around their data, there is a paid TypePy Enterprise Edition. But the TypePy core and GUI described above,
- 15:34is completely free to use. Learn more and get started by visiting talkpython.fm/taipy. That's T-A-I-P-Y. The links in your show notes. Thank you to TypePy for sponsoring the show.
- 15:46Yes, and so, and then the same, well, similar equipment does the reverse process. It reads the data off, and then it basically batch processes it. This happens in software, so you cross-multiply all of the signals together.
- 16:00That's great if you have a limited number of telescopes, up to a few dozen or so, as with Event Horizon Telescope. In the Meerkat case, we've got 64 of them, and we're building a few more.
- 16:12And as it becomes the full square kilometer array, we're going to be talking about hundreds or possibly even thousands of individual telescope elements.
- 16:20So recording everything onto a hard drive at that data rate becomes impractical.
- 16:23So the approach that we take is we use what we call a real-time correlator.
- 16:27It processes and reduces the data as a sort of first stage in real-time, live, before recording to the disk.
- 16:34And as a part of that step, we integrate for a little while.
- 16:37So if you think about it from point of view, if you've done some photography at nighttime, you want to do a long exposure, so you open your camera shutter for a long time to get the more signal.
- 16:47It's very similar to that.
- 16:48So we would integrate over, you know, half a second or a second or, you know, eight seconds.
- 16:53And that gives you a much reduced, there's still a lot of data that comes out of the other side, but it's much, much smaller than if you were recording straight onto hard drives from the telescope, the way that they do in Event Horizon Telescope.
- 17:05Right. That is interesting.
- 17:06I guess it is just like taking a picture, just a different frequency, right?
- 17:10But same basic idea?
- 17:11Exactly. Exactly.
- 17:12Nice. And so there's a lot of data coming through here.
- 17:15You talked about how Event Horizon couldn't even ship it around the world quick enough or, you know, even though they were very, very far apart and pretty remote.
- 17:22But there's a lot of data here.
- 17:23And so maybe give people a sense of the data center.
- 17:26Excuse me.
- 17:27Give people a sense of the data center.
- 17:28And like, you've got this array of, I don't remember how many of these correlator server U1 slices you've got.
- 17:35Yeah, no, no.
- 17:35But it's not just one corner, PC in the corner, is it?
- 17:38No, no.
- 17:39Although with the way the technology progresses, maybe one day.
- 17:43No.
- 17:43So our current generation correlator uses an FPGA-based computing platform.
- 17:49We call it Scarab.
- 17:50There's a bit of a tradition to name radio astronomy compute things after insects.
- 17:55So the previous generation one was called Roach.
- 17:57This one is called Scarab.
- 17:59They stand for something.
- 18:01Configurable open architecture for computing hardware, I think, was the Roach.
- 18:04And Scarab, the first three letters are SKA.
- 18:08Yeah, there we go.
- 18:09There's the Scarab.
- 18:10And what that is, is an FPGA is a field programmable gate array.
- 18:14So it's a little piece of reconfigurable silicon that has, it's like having a hardware accelerated signal processing.
- 18:20It's very fast and it's wired straight into Ethernet for interconnect.
- 18:23So in our data center in the Karoo in South Africa, we've got about 280 of these individual Scarabs.
- 18:29And each of them has a role to play in the signal processing pipeline.
- 18:33They talk to each other via Ethernet and they're controlled by a central master controller computer that runs Python.
- 18:40So it uses an asynchronous little routine to coordinate the activities of each of these Scarabs.
- 18:46The processing parameters need to be updated from time to time.
- 18:50So, for example, as the Earth turns, the geometric delay between a given pair of telescopes will change slightly.
- 18:56And so that gets updated periodically in the Scarab so that it can carry on processing the data at the full rate that the telescope is taking data in.
- 19:06So to give you an idea of that, each telescope is producing data at about 35 gigabit per second.
- 19:1235 gigabit a second?
- 19:13Yeah.
- 19:13Times 64.
- 19:14Yeah.
- 19:15Yeah, that's a lot of data.
- 19:17After the processing, the other end of the correlator, so we get about four or five gigabit per second.
- 19:23So that's reduced due to kind of the long exposure effect.
- 19:26It's averaged over a few seconds.
- 19:27So it's four or five gigabit per second out the other end.
- 19:30And then that gets stored on hard drives for processing and imaging so that scientists can do their science later on.
- 19:36But that's the initial stage of the signal processing pipeline.
- 19:39Yeah.
- 19:39So you've got 64 of these running in concert.
- 19:42What does uptime in DevOps look like for you all?
- 19:46Is this continuously 24 hours a day recording or is it offline for a certain number of hours?
- 19:52Yes, it is.
- 19:53And the limiting factor, I'm happy to say, is usually not the correlator.
- 19:57We don't need all 280 scarabs to run.
- 20:00We can run with about 190 of them with full science capability.
- 20:04So there is capacity for spares.
- 20:05And when you have a system with this many moving parts, there is downtime.
- 20:09You know, people actually need to go and change the oil in the motors on the telescope
- 20:13and routine maintenance kinds of things like that.
- 20:16I don't remember our numbers exactly, but I believe it's above 75% of the time that the telescope is busy and doing science.
- 20:23This is more recent.
- 20:24It's only in the last sort of few years that the technology platform has become a bit more mature.
- 20:29In the early stages, it was really still sort of engineering commissioning.
- 20:32But I think we're using above 75% of time now for actual science observations.
- 20:37That's pretty impressive for considering all the pieces involved.
- 20:41And one of these scarabs, each one is basically assigned to an individual telescope, part of the array?
- 20:46Partially.
- 20:46So the first one will do what is called channelization.
- 20:50So it's much easier to operate on narrow signals of, you know, very close to a sine wave.
- 20:56So the telescope will sample a little bit more than a gigahertz width of bandwidth.
- 20:59And that will be chopped up into, you know, a few thousand channels.
- 21:03Then those channels will get sort of dished out.
- 21:07And another scarab later on will cross multiply the corresponding frequency channels from every single telescope together.
- 21:14So this architecture is called FX.
- 21:16So first frequency channelization, then cross correlation, pardon me.
- 21:21Before you get your ultimate, well, product which gets stored in the archive and on which then further science process.
- 21:27Yeah, people start to ask questions and draw graphs and things.
- 21:30Exactly.
- 21:31Yeah. So one of the parts that you employ to make this run fast is, I think you said you use CUDA cores on NVIDIA GPUs or something like that.
- 21:41Is that right? Do I remember this correctly?
- 21:42Yes, that's right.
- 21:43So the scarab that you showed on the screen, that's our previous but current generation correlators is working on that platform.
- 21:51It has its pros and cons.
- 21:52It's kind of a bespoke piece of hardware.
- 21:54It is reconfigurable, but there are not that many customers for this particular board.
- 21:59The problem with doing your own hardware is that it takes a lot of time, particularly if you're an organization that you want to do science.
- 22:06So for the next expansion of Meerkat, to build more antennas, we need more processing capability to be able to handle more bandwidth.
- 22:13We've kind of figured out that where they are now, GPUs can do the work.
- 22:19GPUs have actually been powerful enough to do the work for a while now.
- 22:22The problem has actually been the memory bandwidth to actually get your data from your telescope onto your GPU to do the number crunching.
- 22:30So for scarab, it was very easy.
- 22:32It has some 40 gigabit Ethernet, and that's wired straight into the FPGA.
- 22:35So there's no operating system taking its time.
- 22:38There's no PCI Express that needs to be negotiated.
- 22:41The data just comes straight off the network and it can do its processing.
- 22:44Previously, computers were not fast enough to get the numbers on and off the card.
- 22:48But since PCIe 4 has become a thing and sort of the GeForce RTX 3000 series cards, which we're using PCIe 4, we could do it on GPUs now.
- 22:59So we haven't deployed one yet.
- 23:01What I spoke about is the prototype that we've developed.
- 23:03That's part Python and part CUDA, right?
- 23:07Yes, yes.
- 23:08So the CUDA is actually quite small.
- 23:10As I mentioned earlier, the processing is quite simple.
- 23:14So there's a stage for channelizing.
- 23:17So that uses a piece of math called a Fourier transform.
- 23:19And there's been years of research going into that to make it very computationally efficient.
- 23:23It's very fast.
- 23:24The other part is simply multiplying lots of numbers together.
- 23:27And that's something that GPUs are really, really good at.
- 23:29So we've made good use of technology advances driven by things like AI and machine learning, which relies on really large matrix multiplications.
- 23:37So we just piggyback off of that technology.
- 23:40And the bonus is we don't have to develop our own hardware anymore, which is nice.
- 23:44And those things are only getting faster, right?
- 23:45If you could have done it on a 3070 or whatever, an NVIDIA 3070, then, you know, it's getting faster and going to get easier and easier as things go.
- 23:53You might need a small power generator to run one of those cards these days.
- 23:58They're kind of insane.
- 23:59But the 30 series are a little bit easier than the 40 series.
- 24:02To give you an idea, in our prototype system, we're using 3070 Ti's at the moment.
- 24:07And one of those GPUs does the work of four scarabs.
- 24:09Wow.
- 24:10So it's the rate that technology moves forward.
- 24:13To be fair, the scarab is about six or seven years old.
- 24:16It was revolutionary at the time.
- 24:17But, you know, commercial technology has moved forward a lot.
- 24:20Yeah, it sure has.
- 24:21You talked, just a bit of a sidebar.
- 24:23You talked about one of the challenges being getting the data in and out of the GPUs from a bandwidth perspective.
- 24:30Do things like systems on a chip and this Apple unified memory, where the bandwidth, the memory of the CPU is the memory of the GPU.
- 24:39Does that, have you guys considered playing with that?
- 24:41Is that interesting?
- 24:42We have had a look.
- 24:44That's, so Apple's model is something that's not really reached mainstream yet.
- 24:48And Apple doesn't really sell a computer in a form factor that would be amenable to employment in a data center environment.
- 24:54Yeah.
- 24:54You'd have to put a bunch of minis on their edge or something.
- 24:57Yeah.
- 24:57Exactly.
- 24:58Yes.
- 24:58So it's something that we've got an eye on, but we haven't got a usable kind of hardware prototype at this point.
- 25:03We're currently using AMD EPYC platforms.
- 25:06They have lots of PCIe lanes and lots of memory channels.
- 25:09So that lets you get data on and off, you know, from your network to your GPU very quickly.
- 25:15Advances such as direct memory addressing and other such things.
- 25:19I forget all the terminology now.
- 25:21But basically, the faster that you can get it off the, into the GPU's RAM so that the GPU can do its thing, the better.
- 25:27Yeah.
- 25:27Yeah.
- 25:27It's an interesting trade-off to consider because the GPUs, even in the new higher-end Apple stuff, is still quite a bit slower than NVIDIA.
- 25:36But the memory is instant.
- 25:37So like there's, you know, where does that trade-off cross the line?
- 25:41It's going to be interesting as this kind of architecture evolves.
- 25:43Yeah.
- 25:44We've definitely got eyes on that.
- 25:45And we'll see how it goes.
- 25:47All right.
- 25:47For doing the CUDA stuff, what's the Python side look like?
- 25:51Is that, what library is she using and stuff?
- 25:53So the Python, that's got to kind of do, so the GPUs are very good at crunching numbers, but, you know, they're not very good at anything else.
- 26:01So there's a lot of steps in that for a GPU to be able to do all of those calculations.
- 26:06You have a high-speed network, 100 gigabit, 200 gigabit, that's very fast.
- 26:11And so you need software to be able to, you know, run your network stack, receive data, and that comes into system RAM.
- 26:18You need to be able to DMA it into the GPU's memory.
- 26:21You need to be able to know when the work is finished so that you can copy the data back, packet that up in Ethernet packets again, and send it out.
- 26:29And so there's a lot of things that we use in Python to enable that.
- 26:33The first and most sort of obvious one would be a library called PyCuda, which allows you to wrap up CUDA functions in a nice Python handle and interact with your GPU in a way that's, you know, more amenable to Python code.
- 26:48There we go.
- 26:49That's the one.
- 26:49Yeah, very cool.
- 26:50So the other one, the thing that you've got to think about carefully then is coordinating your activities where your GPU is executing.
- 26:59PyCuda calls the streams, if you're working in an OpenCL kind of abstraction, it calls it command queues.
- 27:04So they work almost like threads on a computer.
- 27:06So you need to have some sort of way of coordinating so that when you start one calculation, you've got to make sure that the data is there, that it can work on it.
- 27:16And similarly, you don't want to start copying it back before the calculation is finished.
- 27:20So PyCuda makes this quite easy.
- 27:23You could use, I think, NVIDIA calls it events.
- 27:25But they're basically semaphores and markers to help you to coordinate between your different threads for sending, processing and receiving data from the GPU.
- 27:34And similarly getting it off the network and onto the network again.
- 27:37Yeah.
- 27:37PyCuda looks great.
- 27:38Another thing you spoke about that was pretty interesting is your use of async and await.
- 27:43Do all the network stuff, which I think is, it's a clearly a good choice and fits right here.
- 27:49But I feel like a lot of people don't consider it fast enough or good enough.
- 27:53Network, but not just that.
- 27:54Also the GPU.
- 27:55You have a few functions and they're running loops.
- 27:58So the way that we've structured our code and you can, you can, we've got, I'll send, I'll share a link with you.
- 28:03There's documentation in Read the Docs as well explaining this.
- 28:07But we have one loop that just waits for traffic to come in off the network, bundles it up.
- 28:12And this is kind of one of the trick things you, you need to do things in batches.
- 28:16If you involve the Python interpreter, every time a packet hits the neck, then it'll end up being very slow.
- 28:22So we have a lower level library written in C++ that batches up a whole chunk in the order of about 100 or 200 megabytes worth of data.
- 28:29And you use that await keyword to let you know when there's a chunk of data ready.
- 28:34So when there's a chunk of data ready.
- 28:35I see.
- 28:35You wait until enough is buffered up and then you pull it back on the resume or whatever.
- 28:41Okay.
- 28:41Exactly.
- 28:42So you, you, you mark that for upload.
- 28:44You put an event in the, in the stream or the command queue and let that run.
- 28:48And then in the next, you're busy, you're using the await.
- 28:51So you're waiting for that event.
- 28:53And when you see that, you know that the data is uploaded to the GPU.
- 28:56You trigger the processing, whichever processing task needs to happen and put another event and then pass it onto the next.
- 29:02So the third loop waits for that final event.
- 29:05When it sees it, it knows that the processing is done and you can initiate the copy of the GPU RAM back to the system.
- 29:11And then you can send the transmit that out on the network.
- 29:15So those two things working in tandem.
- 29:17Yeah.
- 29:18I didn't expect the GPU to have a, this async interface, but it does make a lot of sense.
- 29:23There's a lot of, a lot of parallels in a GPU.
- 29:25I don't think that it's natively in PyCuda.
- 29:28I think that's a wrapper that we've done around it.
- 29:30It's been a little while since I've touched that particular code, but there's no reason that you can't do that at all.
- 29:35And it's an approach that we find has been very, very useful.
- 29:37Okay.
- 29:37But your assessment overall is that async and await Pythons, asyncio has been a solid choice for this whole platform.
- 29:44It's been, I've seen this approach used in other places as well.
- 29:48Even since before asyncio has been part of core Python using things like Flask or Tornado.
- 29:53So the approach, it's a very good approach.
- 29:55It's very helpful.
- 29:56Debugging async stuff when it goes wrong is a little bit more tricky, but when it works, it works very, very well.
- 30:01Yeah, that's for sure.
- 30:02You get the Heisenbugs keeping in the science space.
- 30:05Okay.
- 30:05So.
- 30:06Exactly.
- 30:07Quick audience question, I think it's going to be interesting before we move on to the testing of this whole system.
- 30:12So out in the audience, Slalwak asks, what do you think about simple distributed radio astronomy experiments for like citizen science?
- 30:20Are they possible?
- 30:21That's a very good question.
- 30:22Yes, they are.
- 30:24It's possible to do amateur radio astronomy using a relatively affordable STR dongles.
- 30:29STR standing for software defined radio.
- 30:31It's been a little while since I've looked at this.
- 30:33I must confess, as I've mentioned earlier, since I do this professionally,
- 30:36I don't bother with it that much as a hobby anymore.
- 30:38You have a square kilometer array you're building.
- 30:40You don't worry too much about it.
- 30:41I've got a big telescope at work.
- 30:43I don't need a small one at home.
- 30:45You can do science.
- 30:46It's difficult in most practical cases because most people live in cities where there's a lot of interference.
- 30:51Yeah.
- 30:52But it definitely can be done.
- 30:53One of the fun projects that I've seen has been using a satellite dish like what you would connect satellite TV,
- 30:59but with a little bit of electronic knowledge and you don't need a degree.
- 31:03You can just be on a hobbyist level to do that.
- 31:05You can build a square law receiver.
- 31:07So it's very much just, is there signal on?
- 31:09Isn't there?
- 31:10You're not going to be decoding any TV streams.
- 31:12But you can measure, for example, the temperature of the sun using this.
- 31:15And you can measure its angular dimensions by simply pointing it and then letting the sun drift through a few times.
- 31:22Yeah.
- 31:22So there are fun projects that can be done.
- 31:24As to say whether it can be useful as citizen science.
- 31:28In other words, useful from a scientific point of view over more than just something interesting to do.
- 31:33I'd have to go and have a look.
- 31:35I'm not 100% sure.
- 31:36It's very difficult to get meaningful results without very, very expensive equipment.
- 31:39That's why we've got such expensive facilities being built.
- 31:45This portion of Talk Python To Me is brought to you by Sentry.
- 31:48How would you like to remove a little stress from your life?
- 31:51Do you worry that users may be encountering errors, slowdowns, or crashes with your app right now?
- 31:57Would you even know it until they sent you that support email?
- 32:00How much better would it be to have the error or performance details immediately sent to you,
- 32:04including the call stack and values of local variables and the active user recorded in the report?
- 32:10With Sentry, this is not only possible, it's simple.
- 32:13In fact, we use Sentry on all the Talk Python web properties.
- 32:17We've actually fixed a bug triggered by a user and had the upgrade ready to roll out as we got the support email.
- 32:24That was a great email to write back.
- 32:26Hey, we already saw your error and have already rolled out the fix.
- 32:29Imagine their surprise.
- 32:30Surprise and delight your users.
- 32:33Create your Sentry account at talkpython.fm/sentry.
- 32:37And if you sign up with the code talkpython, all one word,
- 32:40it's good for two free months of Sentry's business plan,
- 32:44which will give you up to 20 times as many monthly events as well as other features.
- 32:48Create better software, delight your users, and support the podcast.
- 32:53Visit talkpython.fm/sentry and use the coupon code talkpython.
- 32:58One thing you did point out, I can't remember which in the two talks it was,
- 33:03but you did say that you can go and rent at least optical telescopes remotely, right?
- 33:09Yes.
- 33:09Most optical telescopes are operated remotely, but a lot of ones that are commercially available as well,
- 33:15head over to telescopes.com, and you can buy ones that can be electronically controlled.
- 33:20And those you can do interesting, is it telescopes or telescope.com?
- 33:24Wow.
- 33:24Yeah, that's the one.
- 33:25You can buy ones that are electronically controlled.
- 33:27Okay.
- 33:27Those can actually be useful for citizen science.
- 33:29There's a lot of, for example, astronomy organizations that do regular observations of variable stars or winery stars,
- 33:36and they rely a lot on data submitted by amateurs.
- 33:38While any particular observation will not necessarily be that useful,
- 33:43but in aggregate, thousands of these observations are very helpful for doing the science that they would be doing then.
- 33:49That could typically be run by university faculty,
- 33:51and over, you know, they would aggregate these observations over long periods of time from different locations to...
- 33:57Yeah, that sounds like a cool research project.
- 33:59...to draw some scientific conclusions about what's happening with these stars.
- 34:02Very neat.
- 34:02It's a good question, though.
- 34:03Yeah, it is. Indeed. Thanks.
- 34:04So let's talk about the testing side.
- 34:08From my sort of engineering background,
- 34:10one of the sort of key questions that you've got to ask as an engineer is,
- 34:13if you have specifications for a system to build, to design,
- 34:16at what point do you know that it's doing the thing that it's expected to do?
- 34:20So you've got a certain set of user requirements.
- 34:22The user needs to be able to have this level of sensitivity and this level of bandwidth and, you know, accuracy.
- 34:27Less than this much noise or something, yeah?
- 34:30Exactly. In terms of hard numbers.
- 34:32So you need to have some sort of way to prove that the system that you've designed and built is going to meet those specifications.
- 34:37And so testing is a fundamental part of that.
- 34:40Sometimes you can prove by analysis, you know, just by using maths and showing, you know,
- 34:45this is what the system is designed to do.
- 34:47But the first prize is if you can run a test and say, look, we've got a controlled set of inputs,
- 34:51we can measure the outputs, and we can determine from this that the system is doing what we said it is doing,
- 34:56and how well it is, how well it is.
- 34:58So, you know, what the noise level is or what the sensitivity is, whatever the case is.
- 35:02And that's something that is often a little bit neglected in scientific projects, particularly astronomy.
- 35:09That's the one that I've got experience with.
- 35:10Other fields I've seen as well.
- 35:12Often physicists and astronomers are very, very clever, and they're trained in a lot of fields.
- 35:16They tend to build their own instruments and hardware and write their own software.
- 35:19It has a kind of amateurish aspect to it sometimes.
- 35:22Not universally, but this is the tendency.
- 35:25Until it's more or less doing what the researcher wants, and then he carries on.
- 35:29So many a software project has been written by a PhD student.
- 35:32He's generated some results and, you know, published his paper, gotten his PhD.
- 35:38That's very difficult to scrutinize because the code is written by someone and the logic lives in someone's head.
- 35:43And so I'm kind of keen on this concept of testing because I think it adds a level of rigor and transparency to the scientific process.
- 35:49Because if I've got tests in place, then anyone can come along and look at how I've tested my instrument and, you know, criticize or evaluate whether it actually does what I say it does when I publish my research.
- 36:02So I think the concept is really important.
- 36:05I do too.
- 36:06And it's in open source, one of the important signals that people use when they go and look at a package they might consider, like PyCuda or Pandas or whatever,
- 36:16is does this thing have tests as part of its design, right?
- 36:21If I'm going to depend on somebody else's library or if I'm a maintainer and I create a library and someone's going to send me a PR,
- 36:27how do I know whether their changes that they're suggesting to me broke something I didn't see coming, right?
- 36:33And having unit tests or some kind of test typically driven with pytest for Python is a really important, not just supporting pillar of that project,
- 36:42but also a signal to others from the outside, like this thing, people care about this, they've verified it, they want to keep it strong.
- 36:48And it sounds to me like this might also be really important for science in the same way.
- 36:54You talked about people coming to review your work or to try to reproduce it.
- 36:59And if they see the test and they can run the test, it communicates something additional rather than just, well, I thought a lot about it and here's my graph.
- 37:08Exactly, yes.
- 37:09We want to do groundbreaking science and we want to be able to say that when we make observations that what we're seeing is real science
- 37:16and it's not just some sort of anomaly that we found in the telescope signal chain.
- 37:20And the presence of good tests helps with that because then, you know, we have rigorous testing that we can say, look, this is the performance characteristics of our system.
- 37:30You know, it gives a little bit of extra confidence in your scientific results that way.
- 37:34Indeed.
- 37:35So how does this look different than like testing Flask or something, right?
- 37:39Because it's not exactly the same and you maybe are leaning on it a little bit more to communicate more information, not just pass or fail.
- 37:46There are a few things.
- 37:47In one sense, we do use unit tests in the same way that a lot of open source projects do.
- 37:53Just, you know, does each individual component of my module do the thing that I've designed it to do?
- 37:59But if you go a little bit beyond that, the same sort of philosophy and application can be applied to systems as a whole.
- 38:06If you have a complicated system with a lot of different parts talking to each other, it can be tricky to a change that you make might not break if you look at it in isolation.
- 38:17But does those interfaces still work?
- 38:19If you're unit testing something, often you mock out whatever's at the end.
- 38:23So you pretend that you'll get a real response from a website when you do an API call.
- 38:29But if you've touched the code that actually handles that API call, then your unit test is not going to pick that up.
- 38:34So we've got a relatively rigorous process for what one might call integration testing.
- 38:40So an entire system gets set up in a simulated environment, but an input like it might get from a real telescope and, you know, the ability to watch that output.
- 38:50And so we do that on a regular basis.
- 38:52We spin up an entire correlator in a system in the lab, give it a deterministic input.
- 38:59And so we can measure the output and, you know, determine whether or not it meets the criteria.
- 39:04Yeah, cool.
- 39:05Is this like a software emulator in Docker or is this an actual one of your 1U FPGA things that's dedicated to this integration testing?
- 39:16It can be both.
- 39:17It can be both.
- 39:18So we've used the same approach to testing the old Scarab correlator.
- 39:23One of the Scarabs can be configured to emulate a telescope.
- 39:26So it can produce a signal similar to what a telescope might be, except not having astronomical signals in the data.
- 39:34It would have a deterministic signal such as, you know, a normal frequency tone or just white noise, depending on what kind of test we want to run on the correlator itself.
- 39:43You don't replay the wow signal to it?
- 39:45We could, but it's faster just to generate signals.
- 39:49You're not going to get with a strongly deterministic signal.
- 39:52In other words, if you know exactly what you're putting in, you can see what you're getting out as well.
- 39:57The wow signal, not as useful for determining the noise level.
- 40:01Yes, exactly.
- 40:02More fun, not as useful.
- 40:03Yeah.
- 40:04So one of the things you did is you changed some of the output from pytest to be more representative of talking about how you've met your requirements and stuff.
- 40:16Maybe tell folks about how that works.
- 40:17Yeah, that was an interesting exercise.
- 40:20Soraya uses a process called systems engineering, which was developed in Bell Labs, I think in the 40s.
- 40:26It was quite a while ago.
- 40:27And it's been strongly influenced by the sort of military processes.
- 40:31People in a software environment would recognize it as like a waterfall pattern where you'd have a big design up front.
- 40:38So you'd have a lengthy analysis of what the requirements of your system are and, you know, allocated different performance characteristics to different components.
- 40:47And once you've done with the design, you need reams and reams of documentation to prove that your design meets the specifications as well.
- 40:55Graphs, tables, pictures, numbers, all of these kinds of things.
- 40:59pytest and other packages, there are other ones, but pytest is the one that we've used.
- 41:04It has a much more simple output.
- 41:05In other words, it'll give you lots of details.
- 41:08If something goes wrong, it'll give you a stack trace.
- 41:10It'll give you, you know, debug information of what the variables were at the time that there was a problem or that the assertion didn't meet.
- 41:17But if everything passes.
- 41:18It's all green.
- 41:20Okay, we're good to go.
- 41:21You know, like, okay, the sensitivity is better than X, but how much better, you know?
- 41:26And, you know, how does that vary with frequency?
- 41:29These kinds of things, what we'd like to know and what we'd like to be able to present to the various stakeholders
- 41:33that are interested in the performance of the telescope.
- 41:35We have a system.
- 41:36Okay, you need to zoom out a little bit there.
- 41:38And for those of you who are watching on YouTube, I do apologize for the, it's difficult to put code on a screen in a way that's not going to put your audience to sleep.
- 41:47Yeah, and I just grabbed this off of your talk just so we had something to, like, kind of be concrete about.
- 41:51You have this interesting reporting aspect that runs along with your test for sure.
- 41:55Yes.
- 41:56So pytest has a plugin called Report Log.
- 41:59And that, if you sort of squint at it and look a little bit carefully, it allows you to kind of record metadata as you're going along.
- 42:08So things that are happening in your test.
- 42:10So there's several things happening at once here.
- 42:12And maybe if I could just take a step back, this test that you've got up is the test of linearity.
- 42:17So what does that mean is that if I put in a signal, X, and I get an output, Y.
- 42:22So if I put in a signal, 2X, I should get 2Y as the output.
- 42:25So they should be directly proportional to the other.
- 42:28And if there's, if they're not, then there's a non-linearity of some sort in the system.
- 42:32No system is perfectly linear, so there will be some sort of margin for error.
- 42:36We don't have a specific spec on this particular linearity test.
- 42:40It's a quick one to run because it takes only a few minutes.
- 42:42And it can give us a sort of a first eyeball of, are things working as we expect them to do.
- 42:47pytest, if for those of you who are not familiar with it, the tests are written in the same syntax as Python functions,
- 42:53except where the inputs of the function are either parameters or fixtures.
- 42:57So parameters can be, if there's a parameter space over which your test will run.
- 43:01So in our case, for example, different numbers of frequency channels, different numbers of antennas.
- 43:05This one isn't parameterized.
- 43:07It uses only a few fixtures.
- 43:09The fixtures are things to ensure that you have a test that is reproducible.
- 43:16So in this case, the correlator fixture gives us a correlator.
- 43:20It spins up in the test cluster that we've got in our lab.
- 43:23And it gives, so the typing today gives you the hint that we're getting a remote control.
- 43:28So that little correlator object there gives us the ability to communicate with it and control it.
- 43:32The next one is a receiver.
- 43:34So that's, you know, what if a correlator is running, you need to be able to receive what it's outputting so that you can compare it against whatever the spec is.
- 43:42And the third one is the PDF report.
- 43:45So the name is a bit of a misnomer.
- 43:47Initially, I, so that little fixture is written using module called PyLatex.
- 43:52So shout out, shout out to the authors of that one.
- 43:53It's very useful.
- 43:55And the best way to generate, you can generate PDFs directly from Python, but it's very low level and it's difficult.
- 44:01So we use LaTeX as a kind of intermediate step to do the typesetting and PDF generation for that.
- 44:07So with that, you can focus on actually just getting the content and then use LaTeX to arrange things and typeset and make sure that there's, you know, the lines wrap over and what have you.
- 44:16Ultimately, they're there.
- 44:17The output will be a PDF with a report of the test as it's run.
- 44:21So this is the configuration that we ran.
- 44:23These are the steps that we followed.
- 44:24And these are our results.
- 44:25Version two of that uses an intermediate product.
- 44:28So instead of outputting a PDF straight away, we just serialize the data and put it into a little JSON dictionary.
- 44:34The reason for that is sometimes in LaTeX, you've got to tweak your formatting or something like that.
- 44:39And it would be nice to not have to rerun the entire test just to change the font or, you know, update a heading.
- 44:44And so there's actually an intermediate step.
- 44:46And then there's another step just later that takes that JSON, parses it and generates the PDF later.
- 44:51Right.
- 44:51Well, you can also ask questions about it, right?
- 44:53You can analyze the test JSON and, you know, maybe draw averages over time.
- 44:59Or here's how much it's varied as we've evolved our system, right?
- 45:04Not just pass, fail.
- 45:05What did this one look like?
- 45:06So JSON's pretty good.
- 45:08When you incorporate this with other CI, CD tools, you get up actions or Jenkins or whatever the case is, you can do this repeatedly.
- 45:15And then you have records of over time, you know, how your system has evolved versus, you know, what changes you've made.
- 45:20And it makes it much easier to reason about and, you know, understand the performance of your system and how it changes over time.
- 45:27I think that's really neat.
- 45:28I don't see that being done very often at all.
- 45:30And I think it's easy to look at this little bit of code that you put up in your presentation and say, oh, okay, well, that's pytest.
- 45:38And now here's a fixture and so on.
- 45:39But, like, if you think about what those fixtures are doing, one of those fixtures maybe is controlling one of those 1U FPGA machines to set it up, right?
- 45:48And then the other one is in our, there's a lot of power and stuff going on with these little, you know, here's a variable we call the correlator.
- 45:55Exactly.
- 45:56Yeah.
- 45:56So you're right.
- 45:57There is a lot of code hidden behind here, but it's code that you're going to run every time.
- 46:01So it doesn't matter what test you're doing, you're going to want to spin up a correlator.
- 46:05And whether it's, you know, an FPGA or a GPU doesn't really matter.
- 46:09You want to run through the same sort of steps so that your test is repeatable and that the result corresponds to the input that you give it.
- 46:15And so the pytest fixtures are great for that because once they allow you to get the boring stuff done, once you're confident that you're doing it right, then you can just keep doing it.
- 46:24You use the same correlator fixture for every test.
- 46:26And if there's an update, if something changes, if there's a change to the hardware that you need or the protocol that you communicate with them, then you can update it just in one place.
- 46:34And all your tests will benefit from that update straight away.
- 46:38Yeah.
- 46:38It's a very powerful aspect of pytest.
- 46:41You've taken it to quite a level here.
- 46:43One of the things that I kind of wanted to, when I did the talk last year that I wanted to put forward is that, you know, these concepts of testing, you can apply them to real world systems as well.
- 46:53So if you can talk to it, then you can use pytest to test it.
- 46:57If you can talk to it over the network, a serial cable or, you know, USB or something like that, you can test actual hardware, make it do things, you know, so that you can qualify it.
- 47:07It doesn't, it's not just restricted to, you know, little toy pieces of software, you know, your flask or your tornado or abstract conceptual things that live in the cloud somewhere.
- 47:16It can actually translate to real world things.
- 47:18Yeah.
- 47:19People say when they talk about tests and stuff, they say, well, look, it is, sometimes I say it is your documentation or it is the way you verify things are working.
- 47:28But when you get to the engineering and the science level and you're trying to verify physical things and stuff, it's cool to see how far you can push it to maybe even answer that question better.
- 47:37Right.
- 47:38Like with this reporting, for example, over time.
- 47:40I think it makes it more transparent as well.
- 47:43We, in the open source community, we like to quote Linus's law a lot, we say, with enough eyeballs, all bugs are shallow.
- 47:49But if we're honest with ourselves, like not everyone is going to go and read the code.
- 47:52Yeah.
- 47:52But on the other hand, if you, if you can see, you know, a graph of, you know, this is the frequency response of the system, that makes it much easier for interested parties to actually interrogate and say, look, you know, is this good or is it lacking in some aspects?
- 48:05So from that point of view, I think it just increases the transparency and allows not only yourself, but the sort of the general, the wider scientific community to have more confidence in the, in the performance of your telescope.
- 48:15Makes it more approachable too, I think.
- 48:17Exactly.
- 48:18Yeah.
- 48:18People maybe wouldn't read a unit test and what the heck are they supposed to make out of it anyway?
- 48:23You know, they may well look at a graph that was generated by the unit test, right?
- 48:28Exactly.
- 48:28Yeah.
- 48:28And this is, it's much more, it's much easier for me to parse as well because, you know, I get to the office in the morning and, you know, the CI run is done overnight and I can see at a glance, you know, are things working the way that they should?
- 48:39Yeah.
- 48:39Cool.
- 48:40What has been the reaction from other scientists and engineers when you talk to them about this?
- 48:46How's this perceived more broadly?
- 48:48It's been relatively positive.
- 48:49Scientists want to know when they can get time on the telescope and then I have to tell them, well, there's a committee that evaluates scientific proposals.
- 48:56We can't short circuit that, unfortunately.
- 48:58Beercat has gotten a lot of attention from, well, scientists who are interested in radio astronomy, particularly fields like pulsars and another of our sort of clients is possibly the wrong word, but is the project called Breakthrough Listen.
- 49:14If you've heard of SETI, it's the same crowd.
- 49:16Okay.
- 49:16That are trying to search for extraterrestrial intelligence.
- 49:19Sometimes they're interested in these kinds of things, sometimes not.
- 49:22Often it's a much shorter question of like, is it working and can I get some of the data?
- 49:25Yeah.
- 49:26If the answer of those two is yes and they start looking at the data, then, you know, this performance figures and test results are sometimes more interesting to them.
- 49:33Sure.
- 49:34But generally, generally, it's quite well received.
- 49:36It seems like a cool idea to me.
- 49:37Do you have, you know, time on telescopes is really precious and rare, hard to come by.
- 49:44The more powerful the telescope, I imagine, the more contention there is for that time.
- 49:48Is there a bunch of simulation and software and things that people can hand out to these folks that they can work with beforehand so they become more prepared?
- 49:58Yes.
- 49:58And, well, it mostly consists, it depends on what you're interested in.
- 50:04Meerkat is an interesting architecture in that there are some of the clients that have hardware right on site that are subscribing to data and processing it in real time and Breakthrough Listen is one of them.
- 50:16You know, they're interested in very, very fast transient stuff.
- 50:18Other scientists are more, they're not in as much of a hurry.
- 50:22They're more interested in the end result, the output of the correlator that has been through several stages of pre-processing.
- 50:28And it depends on what kind of science that they're doing.
- 50:30And so, as with most telescopes, certainly, but scientific instruments in general, we keep all of the data from observations of past.
- 50:37Typically, there's an embargo on that.
- 50:39So it could be a period of 12 to 24 months to allow the originating scientist of the observation enough time to do his analysis and publish his papers.
- 50:48But once that is lifted, then that data is available to basically anyone who wants to use it.
- 50:54So all they need to do is contact us and we can give them access to historical data sets.
- 50:59And they can begin to test their algorithms on actual historical observations.
- 51:04Yeah, that seems good.
- 51:05Excellent.
- 51:05All right.
- 51:06Quick question, follow-up question here before we kind of wrap things up.
- 51:10James asks, what happens to the raw data?
- 51:12Talking about coming out of the correlator, I suppose, received.
- 51:15How much of it is captured and stored versus processed down and then storing the result?
- 51:20Okay.
- 51:20So, as I mentioned earlier, each telescope generates data at about 35 gigabits per second.
- 51:26That is impractical to store.
- 51:29We have logic on site that will buffer up a few seconds worth of data.
- 51:34And then they have algorithms that are searching through it for interesting things.
- 51:38And if there's something that they notice, there's a mechanism to dump that to disk.
- 51:41So just a few seconds at a time.
- 51:43And that happens a few times a year.
- 51:44Generally, the most interesting pieces are a little bit more downstream.
- 51:48So 35 gigabits per second times 64 is a large number.
- 51:53So that's north of two terabits per second that the antennas themselves generate.
- 51:59The output of a 64 antenna correlator is about four gigabits per second.
- 52:03You could ingest that on a Mac mini if you somehow had a USB 4 to...
- 52:08Just somewhere there to keep plugging and unplugging drives really quickly, yeah.
- 52:11To ethernet.
- 52:12Yeah, you'd need to do it pretty quickly.
- 52:13But that is practical.
- 52:14That we have a storage cluster.
- 52:17So we have one on site in the desert in South Africa.
- 52:20It's relatively small, only about five petabytes.
- 52:22But that acts as a cache.
- 52:24And then there is a fiber link to Cape Town where we have a data center with a much larger archive.
- 52:29That uses an object store.
- 52:31I believe it's Ceph.
- 52:33It was also an open source thing.
- 52:34And I'm speaking a little bit outside of my expertise now.
- 52:37But that data is retained then.
- 52:39Well, so far in perpetuity, we haven't gotten to the stage where we start deleting old data yet.
- 52:43So we've got all of the observations that we've ever run.
- 52:46And they range in size.
- 52:47It depends on the observation.
- 52:49But sometimes they're a few gigabytes.
- 52:50And sometimes they're sort of many terabytes in size.
- 52:54Yeah, it's a lot of data.
- 52:55You wouldn't store the two terabit per second, though.
- 52:57That's too much.
- 52:58I don't know what we're doing with that.
- 52:59That's one of the reasons that the correlator exists.
- 53:01To sort of get that down to a manageable, useful level.
- 53:04Yeah, indeed.
- 53:05All right.
- 53:06Well, anything else you want to add that we haven't talked about briefly about this testing side of things?
- 53:11Have we covered it pretty well?
- 53:12The one thing that we haven't kind of talked about is we talked a little bit about earlier about how critical the performance of this is.
- 53:18And one of the things that testing has really enabled is for us to optimize the performance of the system.
- 53:23And in a way that's, I think, not immediately obvious.
- 53:26If you have a first naive implementation of your signal processing algorithm that's easy to read, easy to reason about, it's not likely to be the fastest possible way to process the data.
- 53:36But it's good to have that.
- 53:37And then once you have that, then you can write a test for it.
- 53:40So you can compare a known input to a known output and see if your maths is correct.
- 53:45That way, when you iterate, perhaps we can change the memory access patterns or, you know, improve the coordination between the threads.
- 53:52It's very easy when you do that to make a mistake and start messing up your results.
- 53:56But when you have a unit test and you start messing up results, it can catch it straight away.
- 54:00So having that testing in place allows us a little bit of, you know, room to experiment to really push this to the limits of what these GPUs are capable of doing in terms of increasing bandwidth or, you know, more antennas that we can process or, you know, all these kinds of things.
- 54:15Yeah.
- 54:16And you, I mean, you mentioned regressions earlier.
- 54:17That's so an excellent thing.
- 54:19So you're working on another part of a system and something breaks that, you know, having these tests in place will let you know, we've messed something up.
- 54:25Let's revert back and be a little bit more careful next time.
- 54:28So I think it's just a great concept in industry, in science, in academia.
- 54:32Everyone would benefit from having more embedded tests in place.
- 54:36It's not a panacea.
- 54:38You're not going to anticipate all possible failure modes in your tests, but it definitely helps catch many of the obvious ones.
- 54:45Yeah.
- 54:45Good advice.
- 54:46Testing science is tricky.
- 54:47It's usually a stream of numbers in some way.
- 54:50It's not, yes, there was a user.
- 54:52No, it came back none.
- 54:53Or there was an exception.
- 54:54It's still shooting out a bunch of numbers.
- 54:56Are they good?
- 54:58Maybe they're better.
- 54:58I don't know.
- 54:59Right.
- 54:59But having systems in place to record them, to test them, to say if it matches this curve within some tolerance, it's still good.
- 55:07Yes.
- 55:07It's really important in those areas because it's so hard to look at it and know what the deal is.
- 55:13Exactly.
- 55:13And I mean, so it is a team effort.
- 55:15There's not necessarily any one person that's going to have the experience to do all of these things.
- 55:20So the person who is a very experienced systems engineer who will know the methods by which we can evaluate the performance is not necessarily going to be the best coder.
- 55:28So that's why we have a large team in order to pull all of these things in.
- 55:32So, yes.
- 55:33Yeah.
- 55:33So shout out to my colleagues at Sorayao.
- 55:35We're doing good work.
- 55:37At least I like to think we are.
- 55:38It sure seems like it.
- 55:39Cool.
- 55:39All right.
- 55:40Well, we're about out of time to talk more about this.
- 55:43So let me ask you the final two questions before you get out of here.
- 55:45If you're going to write some Python code for this crazy big system you've built, what editor do you use?
- 55:52I'm a bit old school.
- 55:53I basically just use Vim.
- 55:54Vim.
- 55:54Right on.
- 55:55I feel most comfortable in the terminal.
- 55:57So no fancy GUIs for me.
- 55:58Yeah.
- 55:59There you go.
- 55:59And then notable PyPI package.
- 56:01Do you want to give a shout out to?
- 56:03Well, a couple of ones that I've already mentioned.
- 56:05pytest is very important.
- 56:07PyCuda has also been critical in our work so far.
- 56:11So, yeah.
- 56:12Shout out to those two.
- 56:13Thanks to the open source community for providing that for us.
- 56:15Yeah, it's really cool how much of these general open source projects are supporting science and other types of exploration.
- 56:23Cool.
- 56:23Yeah.
- 56:24Okay, final call to action.
- 56:25People are interested in maybe adopting some of your practices.
- 56:29Maybe they want to learn more about how you did this reporting in pytest.
- 56:32Or even as someone in the audience asks, you know, can they get access?
- 56:37How do they get access to the data sets potentially?
- 56:40You know, what do you tell them?
- 56:41The data sets.
- 56:42Well, I hope you have a very big hard drive on your laptop.
- 56:45If you go to seraya.ac.za, there'll be a contact page.
- 56:48And if you can send us a question and we'll make sure that it gets to the right person.
- 56:52I'm not sure what the procedure is for access for people outside.
- 56:56I can get to it when I want to, but then I'm inside the organization.
- 57:00So start with an email.
- 57:01But if you ask the question on our contact page, yeah.
- 57:04And then we'll send you to the right place.
- 57:06To learn more, I'll put the GitHub link to the software for the correlator.
- 57:11It's all there and the documentation is relatively good.
- 57:15If there's something that's missing, you're welcome to just raise an issue on the GitHub repo and then we'll see how we can help.
- 57:20Excellent.
- 57:21Well, thanks for sharing your story and keep up the good work.
- 57:24Michael, yeah.
- 57:25Thanks very much.
- 57:25It's been great to be here.
- 57:27Yeah, it has been great to talk to you.
- 57:28See you later.
- 57:29Cheers.
- 57:30This has been another episode of Talk Python To Me.
- 57:33Thank you to our sponsors.
- 57:35Be sure to check out what they're offering.
- 57:36It really helps support the show.
- 57:38Type I is here to take on the challenge of rapidly transforming a bare algorithm in Python into a full-fledged decision support system for end users.
- 57:46Get started with Type I core and GUI for free at talkpython.fm/type I.
- 57:52T-A-I-P-Y.
- 57:53Take some stress out of your life.
- 57:55Get notified immediately about errors and performance issues in your web or mobile applications with Sentry.
- 58:01Just visit talkpython.fm/sentry and get started for free.
- 58:06And be sure to use the promo code TALKPYTHON, all one word.
- 58:10Want to level up your Python?
- 58:12We have one of the largest catalogs of Python video courses over at Talk Python.
- 58:15Our content ranges from true beginners to deeply advanced topics like memory and async.
- 58:20And best of all, there's not a subscription in sight.
- 58:23Check it out for yourself at training.talkpython.fm.
- 58:26Be sure to subscribe to the show, open your favorite podcast app, and search for Python.
- 58:31We should be right at the top.
- 58:32You can also find the iTunes feed at /itunes, the Google Play feed at /play, and the direct RSS feed at /rss on talkpython.fm.
- 58:41We're live streaming most of our recordings these days.
- 58:45If you want to be part of the show and have your comments featured on the air, be sure to subscribe to our YouTube channel at talkpython.fm/youtube.
- 58:53This is your host, Michael Kennedy.
- 58:55Thanks so much for listening.
- 58:56I really appreciate it.
- 58:57Now get out there and write some Python code.
- 58:59I'll see you next time.