In this episode of the Elixir Mentor Podcast, I'm joined by Paulo Valente, an R&D Software Engineer and maintainer of Nx, the Numerical Elixir ecosystem. Paulo shares his deep expertise in numerical computing and machine learning within the Elixir ecosystem, discussing both advanced concepts like sharding strategies and fundamentals for newcomers to the field. We explore the technical challenges and opportunities in growing Nx adoption, examining how this powerful library brings tensor computation and machine learning capabilities to Elixir applications. Paulo offers insights into the future directions of numerical computing in Elixir, balancing performance optimization with developer experience. The conversation spans from practical implementation details to broader discussions about fostering a thriving machine learning community within Elixir. Whether you're new to numerical computing or an experienced ML practitioner, this episode provides valuable perspectives on building and scaling numerical applications with Elixir. #ElixirLang #MachineLearning #Nx #NumericalComputing #TensorComputation Connect with Paulo: X: https://x.com/polvalente GitHub: https://github.com/sponsors/polvalente Nx Guide: https://hexdocs.pm/nx/intro-to-nx.html SUPPORT ELIXIR MENTOR Elixir Mentor: https://elixirmentor.com/ siteBrains: https://sitebrains.io
Audio and video play straight from the show's own hosting. PodSubs stores and serves no media.
Transcript
From the show. Tap a time to play from there.
Yeah, all this OBS stuff broke on me two weeks ago and then I just got hammered and was sick and I haven't been able to figure it out. But for whatever reason, whenever anyone that's listening early on right now, if you know why switching OBS scenes with video sources is causing lag on video streaming, let me know because it's really annoying. But yeah, so that's what's going on there.
Yeah, I I have an audio set up here that's pretty brittle. Maybe brittle was the correct word, because I, I share the same keyboard, mouse, monitor, and external sound card between the the work laptop and my desktop. And I have two KTM switches for that because I already had one that that could handle the mouse and keyboard, but it doesn't handle the sound card pretty well.
And I got a cheaper one just for the the USB switching. And sometimes I just boot into Windows, let's say for whatever reason, and it just doesn't recognize the sound card. Yeah, that's at all. Yeah, sometimes I'm tempted. I just want maybe just a Linux box for doing streams and then I don't have to worry. I mean, maybe I would have to worry about. Other things but audio drivers
in Linux is. More difficult, right? Yeah. It is a problem of it, yeah. Yeah, that makes sense. Hey, what's up, Saul? All right, I'm going to go ahead and kick this off. What's up guys? I'm Jacob Blitzo, your Elixir mentor, and welcome to another exciting episode of the Elixir Mentor Podcast. This is where we discuss everything related to Elixir, from interviews with enthusiasts, pioneers in the community to innovative projects and library shaping. Elixir's future. Today I'm thrilled to welcome Paulo Valente, an R&D software
engineer and maintainer of NX, the numerical Elixir ecosystem. Welcome to the show, Paulo. It's awesome to have you here. Do you want to go ahead and just kind of give a brief introduction of yourself? Yeah, thanks for having me. You gave already most of the introduction that I or I normally give. I want to highlight that I work at Dockyard and most of the NX work that I do is at dock on Dockyard time. So it's pretty important for us
to recognize that. Yeah, that's amazing. Dockyard is does amazing stuff for the Elixir community. Yeah, and as you can see around me, I'm also a musician by hobby mostly. And actually, yeah, I got into programming in DSP, signal processing and then machine learning because of music. So that's a nice curiosity. Yeah, yeah, yeah. And I work with an X.
Yeah, very cool. What what kind of started you to get into the like the elixir world? What pulled you in? It was mostly just coincidence, because in early 28, late 2017, early 2018, I was looking for an internship because I needed a military internship for graduating college. And a friend of mine that he's
still around in the Elixir space, but not quite as much. Bernardo Omrin. He was working at Stone, a fintech in Brazil and he basically when I was going to start looking for an internship, he asked me if I wanted wanted to go work there. So things lined up nicely, but I my coding challenge was in Python. And then one month or two after I joined we started moving
towards Elixir and Long story short, we build a an online bank from scratch using Elixir. Wow. And I worked there for almost five years, 4 1/2. OK, nice. And then what brought you towards the like the creation of Annex and that project?
Well, as I mentioned, one of the main reasons for me to having for me to become an electronics engineer was so that I could work with music, even if on the side. So besides me, I have a guitar amplifier that I modded like two months ago and it's my main driver right now. So always like looking for applications of engineering
towards music. And during college that meant doing a research internship in audio processing. And that's in that space that I learned most of the linear algebra that I know. And also I started learning machine learning. Yeah. And then I ended up not doing my project in that space, my my graduation project in that space, mostly because I wanted
to do it in Elixir and focus more on the functional programming and distributed system side of it, because that's what I was working with at the time. This is like mid 2019. So I ended up doing a project that that's related to machine functional programming systems for managing machine learning subsystems, which meant that the
MVP was Elixir calling into Python via GRPC. And then with that bridge, we could consume data images from different video streams, batch them, and then send them to the classifier that was in Python And then get the results back and unbatch the results. And if this sounds familiar is
it's because it's basically an X serving. But yeah, I did that in mid 2019 and there was always this internal urge for me to work with machine learning or something in the space in a lecture. And then unbeknownst to me, Sean and Jose started working in on Annex in the late 2020 and then they they published the library
in early 2021 and that's when I started working in the project, OK. Very cool. That's awesome. For people that may not know, can you explain like in the simplest terms you can, what what is NX and how does it help Elixir and what does it actually do for us? Hey, first NX stands for Numerical Elixir and the reason that we need a project like an axe is because of how the beam works being the the Elixir VM or
or like VM because it's always trade-offs, right. So because we want a platform that's built for concurrent programming, the trade off there is that functions in general have to give up control of the the system every four milliseconds if they aren't done. This means that computations that take longer than that will
be even slower than what they would be. And that coupled with some of the other data structures that we have on the beam makes it so that number crunching and especially linear algebra type of crunching, that that's the basis of machine learning and AI, those aren't suited for the Bing VM. And then NX can leverage
elixirs, metaprogramming, the ability to turn code into other data structures instead of just spinning out the result. We can take advantage of that to then start lowering down the code until we can call into CC functions for instance. So NX is the higher level interface for doing number
crunching in Elixir. That's the the short summary. OK, very cool. And that's like when you'll hear examples of people like adding Rust to their stacks and things. NX would kind of alleviate you having to bring in another language, right? It's like the high level version of. Well, NX kind of. NX kind of already does bring that. Not NX itself, but NX is built with pluggable backends, so for
people in the Elixir space that's like Tesla having a Hackney or Finch type of client, or Acto having adapters for other databases. Then not just post Chris. It's the same interface, but the implementation and the functions that are available aren't necessarily the same. And NX does that. And then we have back ends which
provide the the individual functions. And we can also provide compilers which take whole NX functions, NX computations and lower them down into machine code as a unit. But those libraries, they do have the their native code, the ones that that we wrote officially they are, they use C++, but that's just because it's the the common language that we know we have Ortex which
is in the the Elixir annex or GitHub or organization right now. And Ortex is written in Rust, Explorer is written in Rust as well. And both of those provide annex back ends or at least part of of back ends as well. Gotcha. OK, very cool. For those that are like are new and like me, I don't know much about numerical computing or
anything, but you'll always hear the term like tensor thrown around. Can you kind of explain to the US what that is like? Like is it close to what a list is a matricy? What? What is it? I was having the this discussion with a friend of mine this earlier this week because we're going through a deep learning book, like a book club of sorts.
And the simpler answer is that you can think of the answers as lists of lists. So going from lower dimensions to greater dimensions, we have scalars, numbers, so 12101 million, they're all scalars. It's just a single number. We have vectors which are just a list of numbers.
There's a discussion whether a vector is just a list of of numbers. But for this purpose, let's let's think of just being a list. And then a matrix is a list of lists and they all need to have the same size. And then there's the tensor, which is the generalization for more dimensions. So that's one way to think about tensors. And we can, we can maybe do some analogies here, not analogies,
but really connecting the these abstract concepts with something that people are familiar with. So let's think about a video. Each pixel is a scaler. And then if you're talking about RGB video, RGBA with the transparency channel as well, each channel is a matrix. So the red channel is just a matrix of pixels. The blue channel was the same,
green and alpha, all the the same shape, the same width and height, each one of with different values. But it's just a matrix for each channel. If we're talking about about a JPG image or PNG or GBA images, those can be thought of as 3D tensors already, because it's a list of matrix matrices you have with height and channels.
And then when you step into the 4th dimension, you can think about time, for instance, that's a video. It's a list of images over time. OK. So a video can be thought of as a 4D dancer. In that sense it seems a bit disconnected. But when you start working with the lower level data,
manipulating images as tensors, this becomes a bit more evident. But I I know that it's a bit a bit out there to just say that a video is a tensor, but really it can be a little. Bit. Yeah. And then the important thing is that when you step into higher dimensions, things can be interpreted in different ways.
So you're saying that a vector is a list of numbers Is one thing, but maybe you just want a list of numbers. It's not like a unit measurement unit. The factor and then a matrix is the same. It can. It can just have a list of factors. And when you go into higher dimensional tensors, the interpretation really will depend on what the the person is doing.
So there's not really much more than I can use to define a tensor than just a list of numbers, a deeply in acid list of numbers. And from the aspect from like just the higher up macro view of them, what what are they used for? You're using them to analyze and compare data types and data, right? Yeah. So if you're doing image field training, for instance, you need to represent the the image in
some way that you can't hear. My dog, he's dreaming behind me. If you're doing image processing, you need to be able to represent the image in some way that you can manipulate mathematically. And then if you load the image as a tensor then you can use all of the linear algebra contracts that we have out there to operate on that data structure.
It's the same thing as asking I need to count frequencies of letters in a text. What's the best data structure? It will depend on the sub problem that you want to solve. For instance, if you're doing arbitrary encodings such as UTF 8, UTF 16 and you don't want to restrict yourself, maybe you want to accumulate a map. If you're just counting Latin
letters the 26 of those and not do and do it in a case insensitive way, then maybe an array can be like a. An array with 26 entries might be enough. And then the advantage of the array is that you don't keep allocating memory over time. The map will grow over time and that might be a problem. And there is no good answer to
hey, this is the best data structure right now. But when you're talking about getting something as a list or a collection of numbers and then doing mathematical functions on that collection, probably some type of tensor representation is going to be the the best way to go. And what what makes it so much better?
Just because you don't have your unknown like length of arrays or a growing map, you is it like a confined to rules or what makes it? It's mostly because if you have the the concept of a tensor, you most likely have the linear algebra functions or functions that can perform operations on tensors defined along with it. OK, it generally comes the other way around. Hey, I want to apply these
functions to tensors. OK, let's create a tensor representation. OK, so you start, you start with your your algebra and then you get your representation in the tensor form. Yeah. Gotcha, that makes sense. That's cool when when we're talking about like this is correct me if I'm just like not making sense. But there are like 3 main capabilities of NX, right? You have like tensors with type
to data. And then you have your numerical definitions and then like automatic differentiation, right? Is that or would you be able to kind of walk through those and talk about them a little bit with us? Yeah, we we have the tensor representations as we we have been discussing and along with those the functions. That off. Yeah. And then the numerical
definitions gets into that meta programming aspect that I was mentioning it. It's just a easier way of writing an X functions. You don't need defence, but what you'll need is. Imagine I want to get a sequence of computations, sequence of functions to be treated as a single unit. I can wrap that into a function.
It might be a def fan, but it could just be a simple elixir function and then I call into the inputs with an X functions. If I'm just using an X functions for building the output, then NX can use one of the back ends that we provide which is the NX define expression to trace through the computation and
instead of spitting out a number it it spits out an AST a a representation of the computation in terms of data. So if you have an addition operation, you're going to have a node that says, hey, this is an addition with these arguments. And that's the power of that fan. It's being able to restrict the subset of Elixir that you can use for NX.
And then the output of a def fan, the intermediate output is a def fan expression. And because it's code represented as data, we can do stuff with that. And one of the things that we can do is automatic differentiation, but we can do other things as well. Really anything that requires understanding the code as as a
structure and not just values, just the the values that it functions without the next FM will be able to the definite expression will be able to help with that. And then yeah, after we have the definite expression, we can then pass that on to a compiler, which gets into what I was talking about earlier, where there are some back ends that are also compilers and they can get those functions lowered down
into machine code as a unit. But maybe you don't have a compiler ready. And then you just traverse the we have the deaf end evaluator which traverses the the deaf end expression and then calls into the specific back end functions underneath. I think I I think I get it. Yeah, it's, it's a bit hard to to grok.
It's, it's too much information holes, maybe a more concrete example. So if we step up from Annex to Accent, the neural network library X and has layers, and each layer is treated as a unit of computations for the purposes
of X and. But whenever you're recalling from, you have a deaf fan and you're recalling into another deaf fan, the AST will propagate. It's not the values that are being passed. So you can accumulate the AST over. And this means that an Axon model is just a big definite expression with some other stuff around as well.
And then you have a function that takes in parameters and outputs something. And the parameters are not just the input, but also the weights of the neural network. The media is always saying when you're, you see announcements about LLMS and whatnot, oh, it's a 70 billion perimeter thing.
It's because besides the input, you have 70 billion numbers somewhere in there which are passed as arguments. OK. And then what you want to do is for training, you pass an input and then you know the expected output and you know the actual output that the function gives. Then you apply what we call a last function, which is
basically how wrong you are. And and then if you have a way of differentiating the function, the loss function, then you can use that to modify the weights back. And that's the power that a deaf end gives. You don't have to define how the differentiation how happens.
You're using automatic differentiation for that, but it it this is just possible because it's all code being represented as data before it. Executes. OK. All right. If we take all of this stuff that you've just kind of explained to us, can we can, can you kind of put it into like a real world example that from the standpoint of a developer, how
you would even begin to use NX and like what's a good project where you would start implementing it? Well, if you're aiming to learn NX and machine learning, the simpler examples are probably the best ones. NX on there some some guides there and maybe start with those. So things like representing the
the XOR function as a neural network and then training the neural network to give off the proper result. That's maybe the simplest example that you can have. And then you can step up to digit classification, which is another one of the bread and butter examples that we have. And then after that you can start threading your path in
machine learning and work easily. Cause in working with those, you'll learn learn about supervised learning, which is this concept where I have the input and the expected output as a pair and then I can use those to train the new network. That's supervised learning. And then you'll learn about that. You'll learn about the how to use accent at least.
And then if you need an X, you're probably going to need a specific subset of NX. And then you can go in the documentation and see how to use that. And as you step up to digital classification, you're already moving from a regression problem to a classification problem. And then you'll Start learning about different types of machine learning problems. And that's at least how I learn
things. I like starting from a higher level concept and learning the details as I see the holes in the knowledge. And not only as I see them, but as I see that I need to fill in those holes. Yeah, well, I feel like this is a very easy subject to jump too far and too quick and you get overwhelmed because there's a lot going on. Yeah, if you, if you're doing like depth first learning, you're probably going to end up
looking into bits and bytes. And that's not that that's too far deep. And maybe depending on what you want to do, the linear algebra surface too far deep 'cause we have Bumblebee. If you're a an Elixir developer that wants to have an AI application AI function running in your app, but you don't really want to learn how to build one, maybe Bumblebee already provides the the model
that you want to run. And then it's just a like 4 lines of code to get that as a process that you can call into in your application tree. OK, I see. Yeah. Can you explain? I, can you explain what Bumblebee is a little bit for us? I think it's just like learning models, right, that you can apply to what you're doing
without LLMS, right? Or I might be wrong. It's not just LLMS I think maybe, but really what bumblebee is. Yes, we have NX as the foundation. Then we have Axon for neural networks and above Axon we have bumblebee which takes in configuration from Hugging Face which is a separate repository
for machine learning. Think of it as GitHub for machine learning. OK. Bumblebee can load models from Hugging face into Exxon models. So it you need to define some coding bumblebee for that to happen. But in the end result is that we have a way of getting the configuration off of Hugging Face and import that as NX code. And then you can apply
everything that we have to have been talking about so far. But if you don't want to, we can just use that NX code. I think it it spits out an Excel model and then you can get that and just use NX serving which is a a functionality in NX4. Spinning up a process that can handle batches of data for a
given function. Then it's just spin that up and and run with your model. Don't need to to go too deep, you can just stay at the bumblebee level if you want. Yeah, that's nice. Yeah, I demoed this a bit in the Denver Elixir meet up. That's there's an online recording somewhere out in on YouTube. OK. If people want to see like how to connect bumblebee with a live view for instance.
Yeah, very cool. I'm checking out the bumblebee GitHub right now and apparently hopefully people can hear me. I bumped my game quite a bit. Apparently my audio is a little quiet, but yours is good, so hopefully maybe I'll just kind of go crazy on my gain. Dude, OBS man, it's nothing but trouble lately. I might have to find a new alternative. But anyways, hopefully,
hopefully you can hear me now. Nero. Do I sound better or is it still quiet? We'll just assume it's probably a little better, but I'm probably still on the low side when it comes to like handling performance optimization with NX. Are there like specific things that you need to do to make sure you're keeping the performance that you need?
There. It's probably really hard to. There are some things that I I mean the the most important one is to make sure that your code is running with a native back end such as Yaxley or EMLX. And besides that if if the computation doesn't change too much over time.
So if you're passing, if you're always passing the same shape of data as input, then you might also want to use a compiler if available. OK. Generally the complaints that I get of hey this is too slow is mostly due to people not configuring the back end compiler properly and then that's one thing.
The other is stay in an X lane as much as much as possible. So one quick example. Imagine I have a list of angles that I want to calculate the cosine of and the list of angles is represented as in an Accenture. A simple way would be to do a for loop and apply the cosine at
each position and then I get the number and sort that somewhere. The fast version is to just call an X Cos on the tensor itself and Cos is in element. By its operation, it already knows how to apply itself to the tensor, and that means that you didn't leave an excellent to calculate the loop of the cosine and the. I mean, that's a pretty simple
example, but as as soon as you get to more complicated functions, or you're translating functions from math into NX, then maybe you need to change the way you think about the code a bit to make it fit into the paradigm of vectorized computations. I see we have a question from George, he said. Can you describe again what is a
back end and and what is a compiler? Yeah. So NX provides a behavior NX dot back end, which lists quite a few callbacks that you need to implement for the NX interface to call into. So the back end is just that, it's a way of turning the NX
call into some result. The back end can do whatever it wants really. In general we want to calculate the actual functions, but not always. And DNXFN expression is one example of that where instead of spitting out numbers you're spitting out a an AST. Kind of like using in depth macro instead of dev, right?
But the back end is just that. And then you can implement that in Elixir itself, which is the NX binary back end that comes with NX. Or you can call into C functions from somewhere else that's the back end. The compiler is doing almost the same, but instead of being called of it being called into buy an X whenever you do an X
dot add. For instance, an X dot add is going to call a back end. But if you do an X def fan compile, jet jet apply, or you have a globally configured compiler and you do a dafn and call the dafn, all of those are going to call into the compiler that's configured. The compiler is going to take in not NX add or NX subtract.
It's going to take in a function and the arguments. OK. And then whenever you do that and you're called the the function with the argument to get the expression that represents that function, and then it takes that expression and transforms it into native code. Doesn't need to be native code, but that's generally why you want to do a compiler. OK, that makes sense. And your probably your
performance and everything is probably a lot better when you're down in native code, right? Yeah, it is. But The thing is when you you do a compiler, you're you also have the ability of the underlying code that you're using to do operate a fusion and whatnot. So one example is EMLX, the back end and compiler that we have. For running on Apple GPU, Metal and EMLX without a compiler is
about 5 times slower than with a compiler. Wow. And yeah, it's a pretty big difference. Yeah, that's, you know, someone. Let's see, at the very beginning we had Mark, he's curious to hear about the new metal support. Great timing. And so that must have been a new a new feature recently added. I I don't it might have been
like one month ago exactly. OK. That I decided that maybe it, it, it was time to not just try to keep using an XUE, which is another back end compiler that we have. That's the first thing that we want. We tried to bring Metal support into an X. And then I decided, hey, MLX seems to be stable right now. Maybe we can use that.
And MLX is the official Apple library for for machine learning. So we put together a team that me, Samrat, Coco like most of the comments were by us 3 and in like 10 days we we got the whole back end done.
That's amazing. That's. Good. Yeah, I I was really impressed. Aside from like specific options in specific functions that are harder to to implement, but most of NX already works with the back end. And I just now yesterday I I sent a pull request for the compiler. OK. It does some crazy stuff 'cause it needs to call it back into Elixir from NIF land.
Which was? Pretty uncommon and it if we were doing this like a month ago it wouldn't be possible because cocos library didn't exist yet. But yeah, we called back into an X into elixir to run through the function that an X defines. But with what? With the tracing arguments that MLX provides, so that spit spits out internally at least, the
equivalent of what we have as a definite expression. And then MLX can compile that down into a function. And then we just get that function, return it to Elixir, cache that, and then pass that with the list of inputs into another NAF that will do the actual function call. OK, is most of is is the back end and like the compiler are
these always, are these mostly like GPU tasks or how does that work? Not necessarily. I wouldn't say mostly they can run on GPU, but for instance if you're talking about MLX, Macs have a unified memory architecture so you're doing stuff on the GPU or on the CPU. Boils down to what does what faster.
OK. GPUs are highly parallel, but they don't do sequential stuff really well. So if we're doing a loop over and over the same data, maybe doing that on the CPU is going to be faster. OK, now is this something that is automatically figured out or is this something that has to be done in configuration? It has to be done in configuration. OK. Right now, we might be able to
to say, hey, you're trying to run this on this GPU, but that's not it should be running on the CPU. Yeah, but we're definitely not on that stage. Yeah, no, I mean, that was probably a dumb question. I was just, I didn't know. No, definitely not a dumb question. In general, it's it's hard for someone that's not in the space to differentiate between it's
sequential code and parallel code and parallel code versus concurrent code. Because the magic of the GPUs really is that you're truly parallel. You're not concurrent. I mean, you're concurrent in the sense that the GPU is a resource, but as soon as you have a computation running on the GPU, it can take over all the of the GPU at once if it needs to. And then that's why running things on the GPO is a lot
faster. GP OS are built for doing high, highly parallel computations over the exact types of computations that we have in neural networks, which is matrix and vector products mostly. Got you. That's where the GPO shines. OK, that makes sense. And that's why you, that's why I like NVIDIA stocks are shooting through the roof right now. Yeah, but then when you get to
something like the Fourier transform, which is really common for non machine learning stuff, GPUs don't do that too well. OK. Like the, the CPU implementations tend to be, if not faster, at least as fast. OK. As GPU, so and then you don't have the overhead of transferring data to the GPU. OK, that makes sense. Are you able to have these? Like if you have different
tasks, can you are you, can you have different configurations set up that like this goes to the CPU and this goes to the GPU? You have currently you had you, you can, but currently you have to to split the computation manually for that to happen. But the work that I've been doing the past three months in sharding and partitioning functions, one of the things that stems from that is that you
can annotate a an X function with metadata and then basically get it to be split up between different execution stages. Oh, OK, cool. And then each execution stage will be able to to be compiled down to whatever target you want. Nice. OK, that's cool. And the the goal here is for us to be able to get maybe the 1st 2 stages to run on the current
machine and then the third stage to run on a separate machine. If we have clustering, that should work just fine. OK. And then the machines don't need to be the same hardware. Oh wow, yeah, that's cool. I can cluster my Mac with my Linux machines and then have the native code for each one run. OK. The communication happens via Elixir, but.
Like over like node? Oh, like a distributed system? Then yeah. Yes, exactly that. And like just being able to compile onto different hardware is already enough. But even in the same machine you can have a section that runs on the CPU and a section that runs on the GPU. I brought this as a as an experimental thing to an X Siri even, but it probably needs to
be redone where there are certain functions that don't work home at all yet. OK. On that back end. Then I take the computation and split it up so that those functions are running on the CPU. OK, that's. Then I then you go back to to the GPU to run the rest. Could you potentially then kind of treat it like a load balancer as well, like like across your resources that are available?
I wouldn't say a load balancer because that's more on the NX serving type of functionality. OK. At least in the sense of balancing loads of how many requests you have versus how many machines you have or how many you have when I said. That I was meaning more like. Yeah, balancing being. Allocated. Yeah, if you, if you're, you want to have, imagine you're, you're running on desktops. Like there's one desktop there,
there's another right beside me and this machine. Imagine all of the three, all all three of those are used by people. You don't want to hog all the resources because people might be using those for whatever. Then maybe it makes sense for you to to run most of the code in your in the machine that you're using and then take over parts of the other machines just for.
Maybe the model doesn't fit in your machine, but really the least splits that you do is probably going to be faster. OK. Yeah, that makes sense. But yeah, you there are a lot, a lot of things that you can do when you have that kind of trend or control. Yeah, no, that's really cool. I love that. Another thing that we might be able to do, or at least that's one of the things that I, I want to get working by February.
Imagine you have a a cluster of being nodes. You can build a graph that tells you which nodes are what's the the the least least latency path without loops between those nodes like just so that in the end you can take a computation
splitted over all of those nodes in such a way that you're doing the least split with the least amount of latency possible. Nice. Yeah, that really like there's your performance optimization, right, The lowest latency in. Yeah, yeah. But then that that's not a machine learning problem anymore. Yeah. It becomes like distributed systems graphs. Right. Yeah. That type of problems please.
It's just how you're handling your machine learning problems. Yeah. Now you're going to need like some version of DevOps just for for that part. Yeah. What is like when you're setting up? Like when you're using like distributed nodes and things for processing machine learning problems, is it normally like local, local host things like are, is it like lab like, you know, desk testing things or are
you running servers all over the world to do stuff with like larger projects? Imagine you have a web app for instance, and then it does a lot of stuff and one of the the things that it does, it requires a machine learning task, but it
just doesn't do that. It does other things as well. It might make sense for you to have multiple web nodes and then have those web nodes call into a separate single GPU node just for that machine learning task. OK, so it's if you have a web app and you do a machine learning task, have a separate resource just for that. Yeah, that's not necessarily
what you want to do. Like if if the the machine learning task is the main thing that you do. OK. Maybe you want to keep them closer, but generally it's one of many moving parts and then an X serving can handle that for you. The the Denver Meter demo that I mentioned, I start by developing things as a single note and then I I start 2 notes, one of which
one of one of those has just the NX serving and the other has just the web parts of the the supervisor tree. And because it's name registration in a global aspect, the whenever you call an X serving batched run from the live view it or it will call into the other node automatically. Like you you change the the the
supervision tree but not the code that's called the the NX for me. Then if you have multiple nodes with the same serving then it does load balancing and that types type of stuff. OK. And that's taken care of in your NX serving for the load balancing part? Nice. Yeah, that's cool. So we can have 20 web nodes and 2-3 GPO nodes. OK, Yeah, that's really cool.
Yeah, I. Have a lot to learn. I love that. That's very cool. My mind is getting blown over and over right now. Yeah. But really keeping my keeping in mind that all of these concepts that we talked about, they keep appearing as the relevant questions are being asked.
So really it's just too much thing, too much stuff to learn or it seems too much because we're talking for too long without you going back and oh, I have what I need to to do what I want it wanted to do right now, which is the process that you're following when you're developing something. Yeah, it's like, hey, I need to solve this problem. What do I need to do? What do I need to learn or I
need to run this OK, I can solve the problem. Hey, I have a new problem. What do I need to do to solve that? It just gets overwhelming when you're like, yeah, when you're just taking actual overview of. Everything right? Exactly. But that is true. Like anytime you're learning something, it's best to start your own project, right? And then, yeah, you run into problem at a time that you have to solve versus 100 problems at once.
Yeah, and then things get less overwhelming. Yeah, for sure. When you do that, plus the thing that I mentioned where maybe you want to go depth first but limit the depth. Yeah, yeah. No, I get like a lot of times I'll like to like, read something about a subject, right. But then you'll find yourself reading and like, learning too much where you start to not grasp things, and that's where I'll stop. And then you get that to start
at step one. Yeah. Yeah, like I need to go back and just kind of wrap my head around tensors and then then we can continue. Yeah, just to highlight for people listening, it's this stuff that we're talking about in learning. It's not just machine learning, it's learning in general.
That's the same process of learning that I apply for everything I learn. Find find a motivator problem, use that to bootstrap the low level knowledge but not too much, and then go into a separate problem, then that's something. And then if you do that over and over, you're closing the gap between the higher level knowledge and the low level knowledge until you fully grasp the subject. Yeah, that's great advice. I love that. That's good.
So what what's on the road map for NX that you're like most excited about that you can talk about it. You don't have to talk about anything that you're not ready to, but. Well, I'd say that the sharding and partitioning thing that I mentioned. Yeah, that sounds really cool. We talked about partitioning, which is sequential splits in the code, but there is also sharding. Sorry, there is also sharding,
where Imagine going back to the cosine example. To calculate the cosine in each position of a vector. You don't need to get the data from other positions right? And that means that if you split the computation up, calculate each data piece separately, and then stitch the results back together, you're going to get the same result.
Which means that if you want to configure your code to be split up, let's say you get a matrix and split into and then split that into four parts and get two of those who run on the GPU and the other two to run on the CPU. Or you have multiple Gpos in each of those processes, one of the the thing, one of the other parts, and then you'll stitch the results back together.
Then you might be able to handle more data or handle data in a faster way. So both of those have the aspect of being able to handle more data, which is really important for in a time that, like the run of the MU LLM requires 80
gigabytes of RAM or something. Yeah. That's wild. Like I I have that on on my desktop but in RAM, not in VRAM. Right. Right. And yeah, you you need to be able to split your split up your computation if you want to run that on your machine or if you need to reduce costs by getting a cheaper GPU, then maybe you instead of splitting it up on
different machines, you do splits over time. Right. You do one thing, save the results disk the other thing safe, and if you do that in the correct sequence, you'll get the same result. Slower. Or maybe not, because if you're you couldn't run it anyway beforehand. Anything is faster than Infinity. Yeah, yeah, If you if you kill your. Resource Infinity time. Exactly.
So yeah, I think sharding and partitioning is what starts to bring an axe in a different direction than what Python is going into. Yeah, well, it's if it's like, at least from my point of view, it seems like it makes it a lot more accessible to the average dev that just wants to play around. Yeah, but it's not just the average dev because you you can stern, let's take a small company, you can start developing on your your dev
machine. And then you would just expose that as a service. And then you started getting in money and you can get like the same machine because it's probably cheap because you you already had that before the company. So you can buy the same of the another of the same machine and then run on that and start bootstrapping yourself without having to increase hardware costs exponentially. Because if you're doing cloud
stuff like one month or two of cloud costs, if you need to run 24/7 already, already covers the cost of having your own hardware depending on, on what you're you're doing. And then yeah, a medium sized company and oh, I need more clients. OK, you have the the beam and the beam can solve the clustering for you and X serving
can do the load balancing. So it's easy to start going up in size without having to have the the the cost rising the same rate. The cost can rise a lot slower and that's one of the things that churning, partitioning and next serving can bring. Yeah, like you, it allows you to do like horizontal scaling at a very small scale.
Yeah, but also if you're going into the close the data center clustering direction. Yeah, yeah. It works the. Same way, right? Exactly because of the beam. Yeah, magic. And then it's a lot easier for us to bring machine learning from Python to that then bring the Bing to. Yeah, that makes sense. So with that being said, does that mean like the Python has a lot of limitations when it comes
to doing doing this that kind of things where you do need sharding and like resource splitting? It's harder. You have Axel Labs that does partitioning, maybe sharding as well. In Python using MLX, they need to use GRPC for transferring data between nodes. We have native RPC. That's already a pretty strong argument I'd say.
And the beam distribution is is pluggable as well. We're talking about configure bike ends on Tesla and NX. The Beam distribution itself can be configured in different ways, so if you have a really specific network type then maybe the Beam can leverage that. Yeah, that's awesome. It's kind of it's kind of like the beam was accidentally made
for machine learning. Yeah, but or the joke that everything has already been invented. That too, right? Maybe. Maybe up until 1986 and then everything is just a rehash. Yeah, that's true. That's probably more likely, right? Or the simulation got reset somewhere and we're just starting over. Yeah. But really, neural networks are
maybe something that came. I'm almost sure that neural networks came before Erlink was a thing. Yeah, I would think so, right. Yeah, we just didn't have the the compute power. Right. At least like theoretically, they were there. Yeah. And but then you, you have something that's built for distributed compute concurrent work. It, it, it was built to handle
like as many people as as people exist, right? That's for telephones. So it's fear. And then that same scale still happens. It's just that we have more people, but it's still scaling with the number of people, the number of requests that we have or OK, we have bots and so on. But really the bulk of legitimate product requests that are going to happen is going to
be scanning with number of people and then at that scale or link shines. Yeah. Yeah, and we have the same power. Yeah, it's wild that all of this was figured out in 1986. Yeah. That's cool. I mean, it just kind of shows you that like the we run into
the same problems throughout time, right? And it's kind of just the media shifts like instead of telephones, it's still data over wires, right? It's still kind of the same thing. It's just a different way we're using it. Yeah, maybe a nice way to look at this is if you're just looking from the top down, it might look like we're going in circles, but it might just be spiraling up.
Yeah, there you go. Yeah, that makes sense. It it's almost the same thing, but it's with more accumulated knowledge with different resources available. One example the the MLX compiler that I I wrote this week, 3 weeks ago. When I first looked at the problem I was going for a different type of solution, but then there the the NIF call library came about and I was
able to incorporate that into the solution space that I could leverage. And then the the the resulting code was a lot simpler and didn't require me going in the internals of MLX. So it really is me going back to where I started, but with a different starting condition. Yeah, you a tool was enabled to make your life a little easier.
Yeah, and that made the whole difference, but this happens in the larger scale as well. Yeah. Your your phone is maybe maybe, you know, it's likely faster than the whole the whole world's computing power at the time that we we went to the moon. The whole world's. Yeah, not just like the the the rocket computer, I'd say maybe
all computers. For sure. Yep. And it's just your phone. Maybe your Apple Watch? Even right? Yeah, might be, might be faster. Not not as much memory, but faster, yeah. And that's crazy to think about. That is crazy. It's crazy that like our phone would not even fit into like a huge building. Yeah, and fun fact, if you have an iPhone and you you're running
live on native, we can run an X code in our application. Oh, really? Yeah, the IT it's still unreleased, but the talk that I gave in at Elixir Conf was compiling NX to to some code that we could deploy to the iPad and run it natively without sending data back to the server. Oh wow, that's cool. And I use the iPad because
that's the iOS device that I have, but it should work with the iPhone as well. Yeah, I would think it'd work the same way, right? Yeah. That's cool, so you can have an NX server running on a on an iPhone. Kind of like that, yeah. Think about it in the next function. Instead. OK, that's cool. I like that I'm live view native is a cool project. I I need to spend some time with it now.
Now that it's, it seems like it's in a pretty good spot to start playing around with. It is. It is Dockyard is starting to accept contracts for native occasions. That's great. Yeah, Yeah. I think it's a game changer for at least adoption in the Elixir space. I'd say that everything that brings the elixir into a different direction then, or into a different space than what
it was already present helps with adoption. Yeah, absolutely. But I, I, I do think that we, we need to have that. We need to think about documentation. It's not just documenting for other Elixir people. We need to be able to document for people that know the thing but don't know Elixir as well. I think you need the two, the two pillars.
You need the to have the. Documentation and the like. Adoption Guides. Yeah, maybe that's one way to think about that. Like, you already know machine learning, right? But you're coming from Python, so here's your adoption guide for Elixir. Yeah, maybe a CHEAT SHEET between numpy, pythorch and an X, Yeah. Exactly. Yeah, that's the hardest part, right?
Adoption, bringing people over because I, I mean, I'm a good example. I had a buddy telling him, telling me to check out Elixir for like, I want to say like four years before I even checked out Elixir because you're just busy learning whatever you're currently doing. Like I was, you know, head down just node JS world and I didn't have time. And then when I finally made the time, then I didn't want to touch JavaScript anymore.
Yeah, I mean, comparing to JavaScript, it's pretty easy to choose. Yeah, I agree. No brainer, right? Yeah, but this was awesome. I feel like I have to like absorb our conversation for the next like day or four days. I feel like I learned a lot, but it was awesome chatting. Paulo, I really appreciate your time and you're always welcome to come back on and we can talk
about this stuff more. And hopefully over the next year or so, I become a little more acclimated to the NX and machine learning world because I am starting to make it a priority because. It's. A lot of cool stuff is happening in this space. Yeah, and lots more to come. There are lots of things that we didn't discuss as well. Yeah. So hey, it's a pretty, pretty interesting space.
There's a lot going on. You're a smart dude and I appreciate your time. Oh, thank you so much. Yeah. All right, if you guys need to find Paulo, I have all the links in the description on at least I don't think X has descriptions, but on YouTube and on twitch you'll find his his Twitter handle and GitHub and all that good stuff. So definitely check him out and I noticed also that the NX project is looking for like
supporters and donations. So if you guys Ken, that would be a great place to do it because it's a really awesome project. So make sure you guys check out Paulo and follow him on Are you on Twitter and Blue Sky? You're on both, right? Yeah, I'm on both. OK, cool. So make sure you guys give him a follow and I hope you have a good weekend, man. Thank you so much Testing.
Francesco Cesarini, founder of Erlang Solutions, and Allen Wyma, hosts of BEAM There, Done That, join Jacob for a live crossover of both podcasts. They trade origin stories, compare what the Erlang and Elixir...
Jason Cohen, founder of WP Engine and Smart Bear, joins Jacob to talk about his new book Hidden Multipliers. They dig into why engineers avoid marketing, the onboarding math behind SaaS trials, finding your ideal...
Filipe Cabaço, team lead on Realtime at Supabase, returns after two years to talk about his side projects: Vitro, a browser for every AI agent with a replayable timeline of what each one did, and Ampoule, which packs an...
Peter Ullrich returns to talk about Pushin.eu, the European GitHub alternative he's building in Elixir. Five months in, it has about 700 confirmed registrations after going viral on Hacker News, and Peter walks through...
Nathan Hessler, organizer of ExMex and RBQ Conf, is back four weeks out from ExMex 2026 in Austin. We cover MCing Rails World, how he picks speakers and keynotes for a single track, what running a Ruby conference taught...