Latest / Agentic Conversations (formally mlops.community) / PyTorch for Control Systems and Decision Making // Vincent Moens // #276
Transcript
- 0:00Vincent Mines research engineer at Metab, and I usually take a
- 0:07cappuccino when I get to work and a little bit later I take a
- 0:10flat white. Welcome back to the Envelopes
- 0:13Community podcast. I am your host Dimitrios, and
- 0:17today we are talking with one of the people that makes Pie Torch
- 0:22tick. This was a conversation that
- 0:26went so deep into the compiler and really it was tips and
- 0:31tricks for people who are using Pie Torch and they want to be
- 0:35able to optimise their Pie Torch use to the Max.
- 0:39I'm hoping that you are able to walk away with at least 9 tricks
- 0:45that make you a better Pie Torch user.
- 0:49I don't want to spoil any of this conversation because it was
- 0:53all so good and I will not do it justice.
- 0:55So let's get right into it. And for our recommendation of
- 1:01the day, I'm bringing some classical music into your life.
- 1:09Debussy, Claude Debussy. Just the epitome of smooth.
- 1:22I'll see you all on the other side.
- 1:24As always, if you liked this episode, share it with one
- 1:28friend. I think I saw somewhere on
- 2:18LinkedIn that you shared. Oh, here's a few ways that I've
- 2:22seen could be better when people are dealing with Pie Torch.
- 2:26Or here's a few tricks that you might not have thought about or
- 2:30easy wins. I can't remember exactly how you
- 2:32phrased it, but it was just like, you might want to do this
- 2:36next time you're messing around in Pie Torch and you probably
- 2:40remember what you posted. I don't remember because it's
- 2:42been over six months, right? But tell us what that was.
- 2:46Yeah, so it's actually funny because we we're gathering
- 2:51together with the the folks in Pythorch had this outside in New
- 2:55York. And when chatting with them, we
- 2:57kind of realised that we had very different ideas of what was
- 3:02the most efficient basically to take a tensor from RAM and send
- 3:05it to CUDA. And if you look at the Pythorch
- 3:08doc, we have this thing that we basically tell people, Oh, well,
- 3:11if the tensor is in pin memory and you call dots to CUDA with
- 3:16notebook in course 2, your transfer will be asynchronous
- 3:20with respect to the host, which means that it's basically going
- 3:23to be faster, you know, because you can send more than one
- 3:25tensor at a time from CPU to Yeah.
- 3:29So OK, that sounds good. Let's try to profile that.
- 3:33You know, let's take a tensor like actually 2/3 or more
- 3:37tensors and call dots, pin memory dots to Q dot with not
- 3:41booking course true and compare that with just the bare tensor
- 3:45to Q dot. You know, and you might be
- 3:47surprised that the simple tensor dot TE CUDA or the list of
- 3:52tensor dot TE CUDA might actually be faster than putting
- 3:56your tensor in pin memory and then sending it to CUDA.
- 4:00And we, we digged a little bit into that, but it wasn't like,
- 4:03oh, well, that seems a little bit strange.
- 4:05And so we looked at the, the documentation from our friends
- 4:09at NVIDIA and all these kind of things.
- 4:11And so we came up with this tutorial about proper usage of
- 4:15PIN memory and what PIN memory actually is.
- 4:17So PIN memory is a reserved part of your RAM where you're going
- 4:22to put things, you know, on hold for a little while before you
- 4:24send them to queue that you reserve that space and your
- 4:27queue, that device knows that it has to gather the data from
- 4:30there to to take it on on device.
- 4:34The thing is copying your data from RAM to these special place
- 4:39that is pin memory doesn't come for free.
- 4:40It's a, it's a copy of the data. And any time you're sending data
- 4:44from RAM to CUDA, it's going to transition through pin memory
- 4:49whether you want it or not. So if you go dot pin memory,
- 4:51you're doing it yourself. If you don't call pin memory,
- 4:54it's going to happen under the hood like by either chunks of
- 4:57data or things like that, but it's going to happen anyway.
- 5:00So The thing is, if you call tensor dot pin memory, you're
- 5:03doing something explicitly that would be done otherwise
- 5:06implicitly. And so The thing is that the the
- 5:10dog was the dog was a little bit misleading there.
- 5:13So basically the definition of over engineering.
- 5:17Yeah, exactly. And then and then I was chatting
- 5:21with my colleagues and I said, oh, well, that's a surprising
- 5:23fact. And some of them told me, well,
- 5:25you know, we should not worry about that too much because
- 5:27that's already pretty advanced. So we went on GitHub and we did
- 5:30the experiment, you know, of looking at tensor dots, pin
- 5:33memory dots to something. And we had a sort of results of
- 5:38people doing that because the kind of kind of says you should
- 5:43without explicitly because if you read between the lines, it's
- 5:45sort of like this is a proper way of doing it, but you might
- 5:48read it that way. And it's kind of that this
- 5:51common belief that, yeah, it's a good thing to do it.
- 5:55And and many people don't benchmark that obviously,
- 5:57because we kind of told them to do that.
- 5:59So we're like, OK, let's try to, you know, correct things a
- 6:02little bit and write a proper tutorial where we experiment
- 6:06things and and we try to give a consistent message.
- 6:09So I invite you to to to check the tutorial.
- 6:11It's full of infos on and, and interesting facts about that.
- 6:15But the TLDR here is basically benchmark what you're doing
- 6:21might be working for you for some reason.
- 6:24And if it doesn't, so most of the time if you're sending from
- 6:27CPU to Q dot just doing dots to Q dot with note booking was
- 6:31true. We're already give you a pretty
- 6:34decent amount of speed up that is sufficient, you know to to go
- 6:39away with that get away with. So yeah, that's anything.
- 6:42Have you found any other areas where you didn't necessarily
- 6:46mean to direct people that way? Like here in the docks?
- 6:51It was just a little ambiguous and so people took it for
- 6:55granted and then felt like they should be doing it and where.
- 7:00Yeah. So another example that comes to
- 7:02mind is modifying or copying tensors in place.
- 7:08It's something that people do all the time, like, you know,
- 7:13add underscore something or, you know, a radio module with in
- 7:19place supposed to you see that all of the time.
- 7:22And The thing is that the gain in terms of performance is
- 7:25marginal, if anything, and it's a pain to deal with that in if
- 7:31you're writing a compiler, because you know, that's in by
- 7:34torch right now, very heavy focused on Torch's compile and
- 7:37compiling things where you have a single storage that happens to
- 7:40pull into different things isn't very easy to deal with.
- 7:45And so the official guideline is do not do things in pace, you
- 7:48know, like it's probably not going to be faster.
- 7:50And if you benchmark it, it's very likely that is not going to
- 7:53be faster. And even if it is from the, if
- 7:57you try to compile that thing, it's going to be a little bit
- 8:01messy on our end. And and therefore also probably
- 8:04on your end, you know, because a compiled graph might not be as
- 8:07efficient as, as it could. So I think the compile guys are
- 8:10super skilled and so they, they dealt with that that a long time
- 8:13ago. But the official guideline is
- 8:15basically trying not to do things in place, you know, it
- 8:18might break things. It's not going to be faster.
- 8:21Yeah, where folks are looking for that extra little lift,
- 8:26that's probably not the place to be looking, yeah.
- 8:28Exactly, Yeah. So where is the place to be
- 8:31looking? Yeah, so now I'm going to like
- 8:37put my hat on off the RL guy because I'm working on torture,
- 8:41you know, the reinforcer training library.
- 8:43And one thing that is very specific about RL is that we're
- 8:47dealing with models that are that are rather tiny and that
- 8:51are called very, very frequently.
- 8:53So that basically means that we're heavily CPU overhead bound
- 8:57in the sense that very simple things, you know, like getting
- 9:00attributes in your module and things like that might take
- 9:03crazy amount of time compared to the mathematical operations that
- 9:06you're doing, like metrics and multiplications and things like
- 9:08that. And in this case, sometimes when
- 9:13I talk with people who are doing it and they don't believe me,
- 9:16but simple things like calling module dot eval takes a crazy
- 9:20amount of time because you're going to iterate over all those
- 9:23sub modules that you have and and like set an attribute and
- 9:26things like that. And and then that module is
- 9:27written in such a way that getting attribute is already
- 9:31kind of long. And so sometimes you see those
- 9:34training loops in RL where people, they're doing module dot
- 9:37train and they do something and they do module dot eval and they
- 9:40do something else and then they redo module dot train and all of
- 9:43these things introduced sometimes in overhead.
- 9:45That's just like about 1015% of your own time.
- 9:50And if you probably like, you're like, Oh my gosh, what am I
- 9:52doing? Like I'm training my model for
- 9:54basically 2 days. And in those two days, I have
- 9:57like 4 hours that are spent just going modular, training modular.
- 10:02And that seems totally crazy. And those like, if you're not
- 10:05compiling, if we are in the eager side of things, a very
- 10:09easy way to to throw that away is basically to create 2 copies
- 10:15of your module. So we're going to create one
- 10:17copy of your module with regular parameters, and then you're
- 10:20going to associate a second copy.
- 10:21There's a way to do that with what we call meta tensors, which
- 10:24is, which are tensors that are not on any device, you know,
- 10:27like they're kind of fake tensors.
- 10:29Or you can, if your model is very small, you can just create
- 10:32tensors that you are going to throw away later on.
- 10:36So the next thing that you're going to do is that you're going
- 10:37to take the parameters from the first module and you're going to
- 10:40copy those parameters, you know, on the second module.
- 10:42Now you'll have two module that two modules that points to the
- 10:45same data storages and all the same parameters.
- 10:48If you modify the parameters on the 1st module, then modify on
- 10:51the 2nd module 2. And The thing is that now you
- 10:54have those two modules, but they're different and so you can
- 10:57call dot eval on the second one. And now you have one module that
- 10:59behaves in eval mode and one module that behaves in training.
- 11:02And then you just use those two things and rather than, you
- 11:07know, in the same module calling dot eval dot train, you just,
- 11:10you know, name the first one module underscore, train the
- 11:13second one module underscore eval and you're done.
- 11:15You know, like and then the magic happens And there's a lot
- 11:17of things that you can do like that, you know, same thing with
- 11:19module dot requires grad false, which people do, you know, to
- 11:23detach parameters temporarily And then they do requires grad
- 11:26true to re put the parameters in the graph again.
- 11:30You can do that, you know, with this very simple trick I just
- 11:33explained, you know, and create 2 copies of a model, one that
- 11:36requires grad and the other one that doesn't.
- 11:38There's another thing that you can do like that.
- 11:39And usually, at least in a real world, again, the models are
- 11:42tiny, cold, very frequently, etcetera.
- 11:45It can bring you like a very decent speed up.
- 11:48How much is too much of these copies?
- 11:50Because I can see someone that is taking it overboard and
- 11:56saying, all right, I'm going to do this.
- 11:57And then all of a sudden there's a sprawl and they have 30 or 40
- 12:01different copies. It takes 0, virtually 0 space in
- 12:06memory. You know, like those things are
- 12:07just like regular Python classes and there's no extra data being
- 12:12copied anywhere. So like you can do as many as
- 12:16you want. I I don't think there's any
- 12:20upper bound that I know of. Well, so you did say and kind of
- 12:23glossed over Tortoro. I want to know everything about
- 12:26Tortoro and also it is interesting that you mentioned
- 12:30these are being called frequently.
- 12:32These are CPU bound. It feels like a whole different
- 12:36world than most people or the hype plays in these days with
- 12:40the LLMS, right? So yeah, give me the whole
- 12:44trade-offs and what it is and where and why we use it.
- 12:48Yeah, sure. So, so the, the story of torture
- 12:52starts about four years ago when we had this idea that we wanted
- 12:56to build some more domain libraries and we came up with
- 13:00things like, you know, Torch Rec for recommendation systems and
- 13:03Torch RL. You go for, for RL.
- 13:05And the story goes that I was basically hired specifically to
- 13:08do that thing here in London. And so I sat down and I started
- 13:13reading documents, you know, of people at Meta and people
- 13:18outside of Meta who had written about what they wanted to see,
- 13:22you know, as an RL library. And there was a lot of things
- 13:25like people were sometimes saying, oh, we just want
- 13:27functionals, you know, things like value functions and these
- 13:30kind of things that can be hard to do right, can be hard to do
- 13:34efficiently. But if we have those
- 13:36functionals, it's going to help us tremendously.
- 13:38But we don't want anything to high level because like we're
- 13:41scientists, you know, already the very research space.
- 13:44So we're going to deal with that ourselves.
- 13:46And then all the people who are like, Oh well, we want
- 13:48distributed things, you know, like distributed repeat buffers.
- 13:51So repeat buffers is basically a dynamic storage that we have in
- 13:53our own. You know, you fill it, you empty
- 13:55it all the time because your model is changing.
- 13:58So the data you're looking at is changing with the model because
- 14:01it's very dynamic. So they wanted some of that
- 14:05discount solutions distributed across those.
- 14:07So there was a lot of ask and nothing really consistent.
- 14:10And then we saw a little bit and we said, well, wait a minute.
- 14:13The thing is that RL is very heterogeneous.
- 14:16In RL, you have things like Alphago, you know, like MCTS
- 14:20kind of stuff, you know, that are very trendy, very
- 14:23complicated. You have other things like, you
- 14:27know, DQN to play Atari games. But you also have people who are
- 14:30using RL to do, I don't know, portfolio management or
- 14:34autonomous driving or robotics or you know, it goes a bit all
- 14:40over the the space of applications.
- 14:42That you know. And also like robots playing
- 14:46soccer, this kind of thing. So really it's, it's really
- 14:48crazy how many things you can do with RL.
- 14:50But The thing is that if you're writing a library, I always
- 14:52compare myself to my colleagues at Towards Vision, which I think
- 14:55have a much easier life because they're like, oh, well, I know
- 14:58exactly what's going to come in my modules.
- 15:00You know, it's going to be an image and the output is going to
- 15:02be something like a label or maybe, I don't know, something
- 15:05that has to do with the image, you know, So the, the, the, the,
- 15:08the space of possibilities is very limited.
- 15:11You know, it's going to be an image or video plus maybe a
- 15:13bonding box plus maybe a label. But you're never going to find
- 15:17something as crazy as, I don't know, a balance sheet, you know,
- 15:22or something like that in a row. You can have anything like the
- 15:26data is basic anything. And the other thing is also RL
- 15:31is not about because RL is not about the media.
- 15:33RL is about the algorithm. And the algorithm basically
- 15:36means that what you call a policy, you know this module
- 15:40that is making decisions in your environment, it can be very
- 15:45different depending on the algorithm.
- 15:46The PPO that we use and process for RHF has a policy that
- 15:51outputs an action probabilistically, you know,
- 15:53given the certain probability distribution, and it also
- 15:56outputs the log probability of that of that action conditioned
- 16:00on the distribution. And that's not the case for
- 16:02DQNDQN doesn't output actually an action.
- 16:05DQN outputs a value that then you transform into an action and
- 16:08you don't have this concept of log probability of the action.
- 16:11So you have two very similar things, you know, 2 basic
- 16:13modules that are aimed at making a decision in the environment
- 16:18and they have a very different signature.
- 16:20And we're like, OK, how are we going to build a library around
- 16:23things that have kind this kind of this common flavour of being
- 16:29a policy or a repeat buffer that stores data or, I don't know,
- 16:34like a value function when the signatures are so different.
- 16:38And that, that seemed like an impossible problem to solve.
- 16:40And then we said, OK, what we're going to do is that we're going
- 16:43to say, OK, any policy in torsional is going to receive
- 16:47sort of a dictionary as input. It's going to do its job and
- 16:50it's going to output a dictionary.
- 16:52And once we have abstracted what the signature of the policy is,
- 16:56we can say, OK, the policy just goes there in the pipeline and
- 16:59something with the repeat buffer.
- 17:00The repeat buffer receives a dictionary and does its own
- 17:02business with, with with that dictionary.
- 17:04And when you sample from that repeat buffer, you're going to
- 17:07get to know the dictionary. And like, OK, that seems like a
- 17:10pretty decent way to go forward, but dealing with dictionaries is
- 17:14not very convenient if you have two dictionaries.
- 17:16Like if I, if I have an environment and I do 100 steps
- 17:19in this environment, and then I try to stack those dictionaries
- 17:22together and represent them contiguously in memory, I might
- 17:26use something like pie tree. And pie tree is definitely like
- 17:30a proper solution to do that. But it's not very intuitive how
- 17:32we're going to call pie tree over your set of dictionaries to
- 17:36stack things together. And so we thought, OK, why don't
- 17:40we come up with another abstraction that allows us to
- 17:43easily stack those dictionaries together.
- 17:46And we came up with this thing, this thing called tensor dict.
- 17:48So initially tensor dict was just a class living in in
- 17:51Torshaw that basically behaves like a dictionary but has some
- 17:56extra features from torso tensor.
- 17:58And those extra features are like I was saying, those
- 18:00stacking tensor Dicks together, reshaping them.
- 18:03But also other stuff like sending a tensor Dick from your
- 18:06CPU to CUDA or from CUDA to CPU, which we do a lot in error
- 18:10because we need to save things, you know, in the repeat buffer,
- 18:14Other things like communicating between the two different nodes.
- 18:18So it has a lot of distributed features and it has a lot of
- 18:22like utils like if you have a tensor date, you can call tensor
- 18:24date dot bytes. And then you're going to get the
- 18:27amount of data that is contained in your tensor date.
- 18:29So that you can say, oh, well, if one single element that I get
- 18:32here is like one MB pig and I need to store 1 million of them,
- 18:37my repair buffer needs to be as big as that.
- 18:39Do I have enough RAM or don't I you know, to make this kind of
- 18:43decisions? Also, if you attend something
- 18:45that contains Llama 3.2, you can look at that and just call the
- 18:48bytes and you're going to know how big is your Llama model
- 18:50basically. So it has like all all of these
- 18:54features. So the story is that we had this
- 18:56thing living in Torshaw and the early users were like, man, this
- 18:59is amazing. Like I'm using that all of the
- 19:02time, but not only in RLA, you know, things like, you know,
- 19:05unsupervised learning or semi supervised learning and they're
- 19:09like. Because it had that modular
- 19:12ability or it it was able to have that flexibility.
- 19:16Since you said we're just going to have these dictionary types
- 19:20and we don't really care much about how you're using it, just
- 19:25we give you everything you need to use it how you want to use
- 19:28it. Yeah, exactly.
- 19:29And from the beginning, we really tried for Tensor to be
- 19:31distinct from RL. Like there was probably one or
- 19:35two bad decisions I made at the beginning, you know, in terms of
- 19:38designing Tensedict. And I quickly like backtracked
- 19:40and said, no, no, this is too, this is overfitted to RL.
- 19:44Like we're not going to do that because like it, it doesn't feel
- 19:47right. And so those users came to us
- 19:50and said, man, you should, you should do another library with
- 19:54Tensedict, which we did. So low tensile date is like like
- 19:57the it's own thing, separate from Torshire.
- 19:59Obviously there's a big chunk of the community using tensile date
- 20:02that is like that are users from Torshirell also because of like
- 20:06probably historical reasons. But today the users of Tensile
- 20:10Date are also like a lot of people that are working in Gen
- 20:14AI specifically like, you know, different models and things like
- 20:19that. Tensor D can also store non
- 20:21tensor data, which is very helpful like again, if you're
- 20:24doing for instance portfolio optimization, which as I
- 20:27mentioned before, you know, because you can store like, I
- 20:30don't know, headlines that go with your financial data or
- 20:32things like that. You can basically store anything
- 20:34in a tensor D if you do tensor D dot CUDA.
- 20:37Obviously if you have a string, the string will not be sent to
- 20:39CUDA. That doesn't mean anything
- 20:40because it's on the tensor, but all the tensors will behave like
- 20:44as expected. And the other use case for
- 20:46tensor D is also tensor D I'm talking about about tensor D to
- 20:50store data, but you can also use tensor D to store parameters.
- 20:53And then again, to come back to RL, we started using tensor D
- 20:58for another kind of things, which are functional calls.
- 21:01So functional calls are basically that you take the
- 21:03parameters out of your module, you store them in a data
- 21:06structure, and then you can do things like stacking parameters
- 21:09together and calling a vectorized map.
- 21:12So instead of looping over different configurations of your
- 21:14model, execute all the configurations of the model all
- 21:17at once over the stack of parameters, which is much faster
- 21:20because things are vectorized using Tensudic.
- 21:23That is very easy because again, I if I find 5 different models,
- 21:27I asked Tensudic to gather the parameters, I stack those
- 21:31parameters together in a continuous, in a set of
- 21:33continuous tensors. And then I just called my model,
- 21:36functionally dispatched those things.
- 21:39And that's much faster, you know, than looking over things.
- 21:42So yeah, that that's kind of the story of tortion.
- 21:44And that's what made, you know, tortion something that is very
- 21:46useful all across the board, you know, for our use cases.
- 21:50So what I'm always surprised and, and happy about is when I'm
- 21:54talking with users and people come to you and they say, oh,
- 21:57I'm using Torch Hall to do drug design.
- 21:59And you're like, this is amazing.
- 22:01Like I, I have no idea you could do drug design with that thing.
- 22:03And, you know, I truly kind of gives me the impression that we
- 22:09did, we did a good job, you know, in, in providing a library
- 22:12that could be used, you know, for very different, a very
- 22:14different set of things. But it does sound that that was
- 22:17almost one of the design principles that you had in mind
- 22:21was how can we make sure that this is not overfit on that RL?
- 22:25And did you, if you remember, because I know it's four years
- 22:30ago, how did you figure out that this is what we're looking for
- 22:34and this is the abstraction layer that we want to play in?
- 22:36Yeah. So that that's a good point.
- 22:38Definitely RL libraries all have this kind of solution where they
- 22:43have a data container that they use, you know, to carry data and
- 22:46even some of them, I guess by chance also maybe tensor DT is
- 22:50kind of like the generic name. So you, you might find your
- 22:54other tensor DT in other libraries.
- 22:57I guess that's here. The, the, the, the specificities
- 23:01of tensor DT is really how it blends within the Pythroid
- 23:04ecosystem. So compared to other solutions,
- 23:07we really tried in so deep to have like this one to one
- 23:11equivalence with Torch of the tensor.
- 23:13So think about this. You have your single tensor and
- 23:16you're writing an optimizer for a single tensor.
- 23:18So you read the Adam paper, for instance, and you're like, you
- 23:20go to the algorithm section and you're like, OK, you know, Kim
- 23:26is giving me like this, this example of how to write my
- 23:29optimizer in the line by line for one particular tensor.
- 23:32So I'm going to rewrite that in, in Pytorch for one particular
- 23:35tensor. And then you write this function
- 23:38and instead of passing a tensor, you pass a tensor, you know, and
- 23:42all those mathematical operation, you know, like tensor
- 23:45dot epsilon times epsilon plus blah, blah.
- 23:49You do that with a tensor dict and it's going to work like you
- 23:53can literally write a, a quote for a single tensor and just
- 23:57pass tensor dict instead. And things are going to work
- 23:59out-of-the-box. And that's really like what
- 24:01distinguishes tensor dict from existing solutions in other RL
- 24:05frameworks, which really build a class for RL use cases and which
- 24:10is great like because they don't need to think about anything
- 24:13else. I guess that in our case we're
- 24:15like, OK, let's try to invest, you know, in making that things
- 24:18bigger and little bit more ambitious for broader community,
- 24:22which I think is probably interesting to talk about here.
- 24:25So you started working on this four years ago in 2020 and that
- 24:30was right at like this, this explosion in my mind of folks
- 24:35recognising that there was really something here.
- 24:38And the developer experience was nice.
- 24:40You just kind of walked us through how you were thinking
- 24:43about creating abstractions. And it sounds like you were
- 24:47servicing people inside of Facebook first, right?
- 24:51And then or or inside of Meta, but then for a greater use case
- 24:59you recognised, yeah, there, there's something here.
- 25:02How much of the developer experience played a part in your
- 25:07mind as you're building versus just we want it to do what it
- 25:11needs to do because it, it really sounds, as you're
- 25:14explaining it all, it really sounds like you're thinking
- 25:17through those two vectors. You're thinking through it needs
- 25:20to do what it needs to do, but also we will.
- 25:23We want to make it so people don't have to go and create new
- 25:26Stack Overflow threads because now this tensor doesn't line up
- 25:30and we made it overly complicated.
- 25:33Yeah. So first I would say that Torch
- 25:36L is a little bit bigger in the sense that we really developed
- 25:39it for your open source community.
- 25:41It's something that I, I really cherish a lot.
- 25:44So that let me backtrack a little bit.
- 25:47I actually have a background in medicine.
- 25:49I used to be a medical doctor like back in the days, and then
- 25:52I did a PhD in your science. So I'm, I'm, I kind of have a
- 25:56scientific background if you want.
- 25:57And I really have this strong belief that it's through
- 26:03collaborative development that we can move things forward.
- 26:06And I think that's what, what also motivates a lot.
- 26:08You know, the, the, the Pytorch folks, about 50% of the
- 26:11collaborations in Pytorch are from the open source community,
- 26:14you know, so we know that just us is not enough to bring
- 26:20Pytorch at full speed. And I think it's the same in
- 26:23science, you know, like a single lab will not discover anything.
- 26:27It's because you have multiple people publishing and talking
- 26:29with each other that you build knowledge, you know, and, and
- 26:34I'm, I'm really convinced that I'm really proud to work for a
- 26:37company that that puts so much emphasis on open source.
- 26:41You know, I, I think that's really amazing.
- 26:43And I think it's a winning bet for many reasons.
- 26:46But anyway, so yeah, Torchell is very open source oriented.
- 26:50Now regarding developer experience, I, I think what made
- 26:53the success of Pytorch was really that, well, first the
- 26:58eager mode story, you know, that Pytorch was, you didn't need to
- 27:03compile a graph to execute Pytorch.
- 27:05And so you could like put bricks and prints and things like that,
- 27:08or you put if statements and they, they walk onto the bug.
- 27:11So that was very handy. But the other thing was Pytorch
- 27:15had included within a lot of stuff like NN dot module or
- 27:20optimizers and and it's all packaged in.
- 27:23So once you install Pythorch, you have all of those tools that
- 27:25are presented to you and they're, they're very Pythonic.
- 27:28They're very easy to use. We once talked with a very high
- 27:35end user who told us what I love about Pythorch is that in 15
- 27:40minutes, you can get started, you know, like you just need one
- 27:44longest tutorial and it's going to go through, you know, and in
- 27:48the module and data orders and and optimizers, and you can
- 27:53build your first model and train that on Ms or something, you
- 27:57know, and, and, and you're done, you know, like 15 minutes and,
- 27:59and you have understood the, the basics, which I find the basic,
- 28:03like it's mind boggling, if you think about it, that, that we're
- 28:06talking about, one of the things that most people think is the
- 28:08one of the most complex achievements of humankind,
- 28:11namely AI, And you can learn so much about that in, in such a
- 28:16little time. You know, it's a, it's kind of
- 28:18nicely done. It's, it's not trivial.
- 28:20I think that we're, we, we developers try to keep that in
- 28:25mind, you know, this kind of white or spirit when we develop
- 28:28new stuff. So I talked about, and that's
- 28:30definitely what I'm thinking about.
- 28:32I'm like, let's try to find the most by Torchy API or something
- 28:35that will be easy to use and does not require a learning
- 28:40curve that is too long and does not like change the way you
- 28:44think about things too much. Another thing for instance, that
- 28:47we recently open sourced is distributed tensors, no D
- 28:50tensors. And the idea there is that you
- 28:52have one tensor that you Shard, you know, across multiple nodes
- 28:56that is represented as a single object.
- 28:58And when you manipulate that object, you're actually
- 29:01manipulating the sharded version of that.
- 29:05I think it's a brilliant idea, you know, like, because it
- 29:07simplify things a lot for you. You're looking at that thing and
- 29:10like, is it a tensor? Is it a tensor?
- 29:12I don't care. I can write code for that.
- 29:14It's going to work out-of-the-box, whether it's
- 29:16distributed or not. You know, like this kind of
- 29:18thing, I think is like super duper handy.
- 29:22And, and I, I would bet that this is the kind of stuff that
- 29:25is going to guarantee, you know, pipe or chooser ability on the
- 29:28long term. And when would that be useful?
- 29:31Specifically, the distributed. Any time you're writing a code
- 29:35and you're like, oh, well, I want to apply this operation,
- 29:38you know, across different nodes.
- 29:41And you know, for instance, you, you, you just want to sum to
- 29:45tensors and you want your code to work either on a single node
- 29:49or on multiple nodes. Well, you the tensor one post
- 29:52tensor 2. And if those two things are the
- 29:54tensors, it's going to work, you know, as it works, you know,
- 29:57with a single tensor on a single machine.
- 29:59So basically, if you want to unit test your code, you don't
- 30:02need to have like if I'm in the distributed setting do this and
- 30:06if I'm not to do that, you know, this kind of thing that are very
- 30:08clunky. And then you read that thing in
- 30:09like, Oh my gosh, what's happening there?
- 30:11And when you're exploring the code, it's very difficult here.
- 30:14You kind of abstract that that distributed factor away and
- 30:16you're basically separating things.
- 30:19You know, a little bit like I was saying, like what I was
- 30:21saying with Torch Rally, you know, I was saying, well, we
- 30:23have one policy and does different things and then you're
- 30:26like and start to abstract that away and separate things and you
- 30:29know, get the nice API where you don't need to care too much
- 30:32about that. I think this is the same thing
- 30:34with with the sensor in my understanding.
- 30:36It really sounds like you're looking at probably these the
- 30:41most common use cases or the most common ways that people are
- 30:45utilising this and recognising what someone is looking for as
- 30:52far as the output. Or basically like looking at the
- 30:57steps that they're doing and then saying to yourself, can we
- 31:02make these 10 steps 5 and can we still keep all of the usability
- 31:08and all of the knobs that if somebody wants to go and they
- 31:11want to figure things out, they can, but there's probably some
- 31:15bloat there. And so how do we get rid of the
- 31:17bloat? Yeah, there's that.
- 31:20And there's also like, obviously, you know, we're
- 31:24obviously working very cosy with a lot of folks in the community,
- 31:27you know, like within Meta, you know that we have like Lana team
- 31:31and Jenny I, but also outside of Meta, a lot of those big
- 31:35companies and startups are using Pytorch and are collaborating
- 31:39with us, you know, in implementing stuff.
- 31:41And so we kind of have a lot of feedback from users who are
- 31:45sending us and we're very, you know, aware of that and really
- 31:48seeking for that activity, you know, going to people and
- 31:50saying, OK, what are the pain points right now?
- 31:53Like if, if you had, if you had the magic wand, you could like
- 31:57solve something in bite or make something easier, what would you
- 32:00do? And usually it balls on to what
- 32:01you were saying, you know, like burger plate code.
- 32:04I, I, every time I'm doing this, I'm going in the, in the dark or
- 32:08in some tutorial and copy pasting those 5 lines.
- 32:10If people tell you that it's not good, like that means that
- 32:13you're missing a point. There's something easier that
- 32:16you that you should provide as an API and and we we try to
- 32:20engage with people to understand what those things could be.
- 32:24So that brings up another really great point is where have you
- 32:30seen some challenges that you haven't gotten to fix or like
- 32:36debugging challenges or things that you just feel like, oof,
- 32:42these are some hairy problems. We haven't made the developer
- 32:45experience perfect here yet, but we are maybe going to or we're
- 32:49thinking about it. And here's a a few best
- 32:52practises that you can share with us right now that you've
- 32:55seen others doing. I, I mentioned a couple of times
- 32:59already, Torso compile, I think torso compile is getting to a
- 33:02stage right now where it's very mature, you know, and actually I
- 33:06was really surprised in RL, you know, I, I, I, I tried to use
- 33:11it, you know, about six months ago for the various things that
- 33:14we have. And we saw some amazing speed
- 33:18UPS when using compiled correctly.
- 33:21I think that the real learning curve here was how to use
- 33:23compiled correctly. So there are two sides to that
- 33:26story. The first side is compile is
- 33:29being actively developed. So there are, you know, the way
- 33:32compile works in a nutshell is that it looks like at your code,
- 33:37it goes through your code and try to interpret your Python
- 33:40code to to compile it. And if you have things that are
- 33:43not accounted for by compile because the operation is not
- 33:46registered, compile is going to graph break.
- 33:48So it's going to say, OK here I don't know what to do.
- 33:50I'm going to fall back on Python And everything that comes before
- 33:53that is going to be 1 graph and everything that goes after that
- 33:56is going to be another graph. Obviously assuming that
- 34:00everything that comes after has the graph break.
- 34:03No, you, you compile those two things and you have a graph
- 34:05break in the middle. So the game for both the
- 34:09developers and the user is to have as few graph breaks as
- 34:12possible. So the first thing is from the
- 34:14developer side, what we like is having people coming to us and
- 34:17say, hey guys, I looked at, you know, the report of my compile
- 34:21code and it seems that you did not account for that.
- 34:24A good example is something that we pinpoint to to our our
- 34:28friends side in the compile team a few weeks ago, which was, you
- 34:31know, there is this thing called Hydra.
- 34:33You probably know of Hydra. We know it's a it's a library to
- 34:36do configurations of, of experiments and things like
- 34:39that. Hydra realised on something
- 34:41called Omega con Omega con has like this Dictionary of configs,
- 34:44you know, things like that. And when you call a config a
- 34:48config object dot something. So when you get an attribute of
- 34:51that config, it was gruff breaking.
- 34:53You know, it was it's that that's not very good because
- 34:56sometimes people doing their code, if config dot clip grad,
- 35:00then clip the grad, you know, these kind of things.
- 35:03But that means that every time you reach that point in the
- 35:05ground, you're going to graph break and not ideal.
- 35:08Maybe you, you, you don't want to do that.
- 35:10So we realise that they were there were graph breaks at this
- 35:12point and that was slowing the code, you know, for the users
- 35:15and, and we fixed that. So right now our friends to go
- 35:19from towards Dynamo, fix that thing And, and if, if you have a
- 35:22hydra config that has been called in your graph, it's not a
- 35:25good graph break anymore. So that's on our end, but on the
- 35:28user end, there might also be the, it might also be the case
- 35:30that like, OK, I'm going to report to them that this thing
- 35:34and that thing could be optimised.
- 35:35But in the meantime, I'm going to try to find a workaround, you
- 35:38know, find a version of my code that does not 'cause this kind
- 35:40of graphic. And so we have something called
- 35:43Torch underscore logs. So if you Google that torch
- 35:45logs, you're going to find, you know, all the flags that you can
- 35:48put. So this is basically an
- 35:49environment variable that you that you set before running your
- 35:52code. And it basically tells Pythors
- 35:55to tell you all of the things, for instance, that cause graph
- 35:59breaks. So it's going to tell you at
- 36:02this line in your code, it's something that was not
- 36:04registered. So I'm going to put a graph
- 36:06break there. And you read that and you're
- 36:07like, OK, that seems like something I could do
- 36:10differently. You know, typical example is an
- 36:14if statement or this kind of things.
- 36:17An if statement can be sometimes for return with like tors dot
- 36:20wire, you know, and that's probably going to help, you
- 36:23know, you to to to to solve your graph break.
- 36:26But you have a lot of other things that you can see.
- 36:28You know, the other thing that that tors dot compiled does is
- 36:32that it puts a certain number of guards on your code.
- 36:34So when you execute the code the first time within tors dot
- 36:37compiled, it's going to say, OK, I have this kind of inputs, you
- 36:39know, for instance, an integer, and there's somewhere in the
- 36:43code if the integer equals 5, you know, I'm like making this
- 36:48up, but it could be the case, you know, if this integer is
- 36:50five, do something and then it puts a guard on the integer and
- 36:53says, OK, before executing the compiled code, I'm going to
- 36:56check that the integer is five. If the integer is five, I don't
- 36:59need to put any graph back because I'm happy I can do a
- 37:00single graph. But then you change your integer
- 37:03and the integer becomes 4. Then compiler is going to do 2
- 37:06things. The first thing is that it's
- 37:07going to put a graph break, you know at the if statement.
- 37:10And the other thing is that it's going to recompile things you
- 37:12know for you and do a second version of the compiled code to
- 37:14run this particular use. Here is where the integer is not
- 37:174. Now The thing is you can look at
- 37:20that, you can look at what the guards are and what the
- 37:22recompiles are and you can try to solve these things and say
- 37:26and be proactive basically in making compile happy.
- 37:29So it can be a little bit of work, but once you get to work
- 37:32with it, it becomes very intuitive.
- 37:33Actually, I, I was really surprised because I was like, Oh
- 37:36my gosh, they're really asking me to do other stuff.
- 37:38But it became a little bit funny.
- 37:39You know, I, I, I actually like to optimise my models and make
- 37:42them as performance as possible. So, you know, it, you, you have
- 37:46this boost of dopamine, you know, you, you rerun your model,
- 37:49it's two times faster just because you rewrote one line of
- 37:51code. They're like, Oh my gosh, this
- 37:52is fantastic. So in a real, by doing this kind
- 37:55of stuff, we got models to run sometimes 6 to 8 times faster
- 38:00than what they used to without compile.
- 38:02So that that was very, very rewarding.
- 38:05Well, even just talking about that environment variable, what
- 38:09was that one again? Torch underscore logs.
- 38:12So that is incredible because you can see where you need to
- 38:18change things around. And it's almost like that
- 38:22cliche, you can't track what you don't measure.
- 38:25And so if you're not seeing where it's breaking, then how
- 38:31are you supposed to know how to make your code better and how to
- 38:34compile it better? What is the best way to be a
- 38:39productive community member? And when we see there is
- 38:44something that for sure could be better, bring that to the team
- 38:50so that it at least is seen and hopefully actioned on.
- 38:56Yeah, well, very simply GitHub issues, you go on Pythorch like
- 39:00Pythorch and you submit an issue.
- 39:02If it's not Pythorch, it's similar to library like Torch
- 39:04Vision. Go on Torch Visions GitHub and
- 39:07submit the issue. And one thing also is, well, try
- 39:11to be reasonable with what I'm going to say, but people are
- 39:15very busy. Everyone's busy.
- 39:16You're busy, I'm busy, everyone's busy.
- 39:18So keep in mind that if people do not answer, it's not
- 39:22necessary that they have anything against you or they
- 39:24don't think that this problem is important to address or
- 39:27something. It's probably just that it
- 39:30slipped through or they're busy doing something else.
- 39:33So if there's something that annoys you and you submit an
- 39:36issue and no one has answered or no one has moved the needle,
- 39:39there are two things that you can do.
- 39:42First thing is ping them. You know, you wait two weeks, 3
- 39:45weeks. And if you really see that
- 39:48nothing's moving, you just say, hey, guys, like, you know, you
- 39:51type the person who's like assigned to that issue and you
- 39:54say, hey, guys, I was wondering how are things moving over
- 39:56there? It's usually better to do that
- 39:58than just dropping it, you know, because you're not helping
- 40:02anyone by just saying, Oh, well, I'm going to try to find
- 40:05something else, you know, And the other thing is.
- 40:08You can be an active contributor and you can have a look at that
- 40:11and try to figure out, you know, do a little bit of homework, not
- 40:14necessarily fixing the issue, but dig a little bit more, you
- 40:17know, and say, OK, I'm going to try to narrow it down for them,
- 40:21you know, because one thing is saying if I execute that code is
- 40:27broken. The other thing is to do the
- 40:28extra step, you know, of going through the code and understand
- 40:31what's going on. It's sometimes a little bit
- 40:33harder with the compiler because it's very intricated.
- 40:36And even myself like finding, you know, what we call the
- 40:39minimal reproducible example is not an easy in compile to be
- 40:44honest. It's, it's sometimes very, very
- 40:45difficult because it depends so much on the whole stack of
- 40:50things that you're putting together that producing this
- 40:53minimal reproducible example isn't easy.
- 40:56But fortunately the guys from torture compile have a lot of
- 40:59tooling to understand what's going on.
- 41:00So if you submit an issue with compile, they will probably come
- 41:03back to you and say, install that thing or put towards the
- 41:07logs. You got something and tell me,
- 41:09you know, copy paste the, the print of what you get there.
- 41:12And then you're going to put, copy paste and it will be like,
- 41:14OK, it's this line of code. Can you tell me what this line
- 41:16of code is doing? You know, and like this
- 41:17conversation can can keep on going and then eventually will
- 41:21you will be able to to solve that.
- 41:23So the the, the, the take a message here is really, if
- 41:27you're dealing with Torjot compile and you have an issue
- 41:31and you cannot find a minimal reproducible example, don't
- 41:34worry about that. Submit that issue, Let people
- 41:37know and start the conversation as already as you can.
- 41:40And and there's probably something that can be fixed too.
- 41:44What do you think of when you think of a very well put
- 41:49together GitHub issue and let's take for Torch RL?
- 41:53What really makes you see an issue and go, wow, that is nice
- 41:58that they went through all of that.
- 42:02Yeah. So what I'd like to know is for
- 42:05personal curiosity, but also sometimes it's important for the
- 42:09issue what you're trying to do. Just saying, if I run this, it
- 42:13breaks. OK, but what was your intention?
- 42:16You know, like for instance, if I create the subject and I put
- 42:19this apartment or equals blah, blah, it breaks and blah blah.
- 42:23Doesn't really make sense. You know, if you look at the
- 42:25door string, it's not something that is expected.
- 42:26And you're like, OK, So what was it that you were trying to do?
- 42:30Because maybe we can help you. Maybe what you're trying to do
- 42:33is not like the way we thought about it, and maybe that's
- 42:37totally valid to do it that way. We just didn't think about it.
- 42:39But you know, like try to explain what's the broader
- 42:42context. Once you have done that, if you
- 42:44can, try to find a minimal reproducible example saying if I
- 42:48run Python myscript dot π, it breaks at this point is not
- 42:52going to help me because I don't necessarily want to install a
- 42:56new virtual environment with all of the dependencies that you
- 43:00have on the same machine that you have, you know, like a
- 43:02Docker image or something. And then try to rerun the exact
- 43:05same thing to see where the properties.
- 43:07So if you can, you know, with a minimal amount of dependencies
- 43:11and minimal amount of code, we run the problem and find what
- 43:14the problem was. That's much better.
- 43:16Obviously, it's not like I was saying with the compiler,
- 43:19sometimes it's, it's just not possible And, and that's OK.
- 43:22But just like, let us know, you know, I tried to, to do a
- 43:25minimal, minimal representational example,
- 43:28couldn't do it in like 30 minutes or so or 30 minutes or
- 43:32whatever. So here's the issue.
- 43:34And that's, that's all right. We, we, we can, we can find a
- 43:37way. And the last thing is, if you
- 43:39want and you are interested, try to dig in the code.
- 43:41You know, look at first the doc like make sure that it's not
- 43:45documented already. Like if there's a huge warning
- 43:48in the doc strings that say you should not be doing that and you
- 43:50do that like that's, that's not perfect.
- 43:53So read the doc of the of the class that's breaking and these
- 43:56kind of things. Try to see if it's already
- 43:58documented. Try to see if there's not
- 43:59another issue that documents that that problem.
- 44:02And finally, if you can well, help us identify the problem
- 44:07like that, we don't have to. But, you know, that's, that's
- 44:09already optional, obviously. But I know that a lot of users
- 44:12like to do that because they like to understand what the
- 44:14country doing. And that gives them the sense of
- 44:17mastering your library better. And so that has some value, I
- 44:21think, for users to, you know, to to do this kind of extra
- 44:24step, but it requires time sometimes.
- 44:26So, yeah, yeah. Talk to me about testing pie
- 44:30torch models. I know that we wanted to get
- 44:32into this and I, I'm wondering a little bit about if you yourself
- 44:38have any tips and tricks because up until now this has been just
- 44:42a treasure trove of tips and tricks.
- 44:44I'm learning a tonne, so thanks for that.
- 44:47But when it comes to libraries or frameworks with testing the
- 44:52specific PIE torch models, is there anything that you have to
- 44:56tell us that you can enlighten us with?
- 44:59Yeah, sure. So in in the Pytorch code base,
- 45:04people usually use the built in unit test library.
- 45:07But in in torch vision, in torch L, we like to use pytest.
- 45:11So you in torch vision you have for instance a set of
- 45:13transforms, you know, to transform your image from colour
- 45:17to back grayscale and this kind of things.
- 45:21We have the same kind of transforms in Torch L to do
- 45:23common operations like, you know, reshaping, permuting the
- 45:27dimensions, sending data from 1 device to the other,
- 45:30discounting. So all of those transforms share
- 45:33kind of the same signatures. You know, they usually you want
- 45:36to execute them on single thread or multiple thread.
- 45:39You want them to be, to be used maybe in the repair buffer
- 45:43because we want those transforms, you know, either to,
- 45:45to play with the environment when you're collecting data, but
- 45:47also to transform the data when you're sampling it from the data
- 45:51set. So we want those, those things
- 45:52to work in various scenarios. So what we have is that we have
- 45:56an abstract class that tests the transforms and we ask the users,
- 46:00the developers, sorry, the contributors, when they develop
- 46:03a new transform to basically copy paste that base class and
- 46:07write an example of that for the transformer that they're
- 46:11implementing. And I got to make sure that the
- 46:14transform ticks the boxes that that it needs to, you know, like
- 46:18it needs to work in a single thread, it needs to work in
- 46:20multiple threads, it's to work with a Reaper buffer, it needs
- 46:23to work as a module, etcetera, etcetera.
- 46:25So we, we really ask people to abide by this rule and and, and
- 46:30use that abstract kind of checklist.
- 46:34And we do the same in Tensor Dick.
- 46:36So in the Tensor Dick library, we have the best class called
- 46:39Tensor Dick, you know, and it has all these nice features.
- 46:42But one thing I didn't talk about is that there's a data
- 46:44class version of that, which is called tensor class.
- 46:46So you decorate your data class, instead of doing as data class,
- 46:50you do as tensor class. And then magically your data
- 46:54class now has a lot of attributes like that's to, you
- 46:57know, to send to a certain device.
- 46:59Or you can add tensor classes together or you can do some very
- 47:03fancy stuff like you would do again, you know, with a regular
- 47:05tensor. So when you write test, we have
- 47:09all these battery of tests for tensor dict.
- 47:11And what we do is that we iterate the test over tensor
- 47:14dict and then we iterate the test over a tensor classes.
- 47:18And then we do that again for another type of tensor dig that
- 47:21stores H5 databases. So we we have all of those says
- 47:27that we basically decline over the values instances of density
- 47:32that we had and and that proved to be very useful to catch edge
- 47:35cases, you know, to say, Oh, well, we're designing this new
- 47:39method, you know, like for instance, this arithmetic
- 47:41operation that was not implemented before.
- 47:43Let's test that arithmetic operation over all the tensor
- 47:47classes that we had. And then we do that.
- 47:49And then usually we catch, oh, well, you know, here there's a
- 47:51warning that is being raised. Here's the this behaviour is not
- 47:55really properly defined with, for instance, an H5, typically
- 48:00with a regular tensor leak, Tensor leak dot to CUDA is
- 48:02you're going to send your tensor D to CUDA.
- 48:04And yeah, that makes sense. You know, it was a Tensor D, it
- 48:06is still tensor leak. Now, if your tensor leak is
- 48:08containing an H5 database and you send that H5 database to
- 48:11CUDA, what's the expected behaviour?
- 48:14Like what, what should that thing do?
- 48:17So, you know, by testing things systematically, we kind of like,
- 48:21Oh yeah, I did nothing about that, what should we do there?
- 48:24And then it pushes you to write to the proper dog that goes with
- 48:27it, etcetera, etcetera. So try to be systematic in your
- 48:30test. That's basically the idea, you
- 48:31know, implementing a new feature, writing a new block of
- 48:35tests, and just saying I'm done with it, I'm happy.
- 48:38Usually if you don't have a systematic way to test things
- 48:41and your project is ambitious, it's not going to cut it.
- 48:45And then from the contributor side of things, that's probably
- 48:50something I should add here, which is if you're working on
- 48:52your feature, the proper way to do that is first to raise an
- 48:57issue on the repo. To go on the repo, raise an
- 49:00issue and say, I have this idea about your feature.
- 49:02What do you guys think about that?
- 49:04Because it might be the case that you're going to work a week
- 49:06on that feature. You're going to think, oh, it's
- 49:07marvellous. Everyone needs that.
- 49:08And either it already exists, or people don't think it's actually
- 49:13that useful because there's already a way to do that, or.
- 49:15Whatever so. Yeah, engage with with the
- 49:19maintainers and, and try to, you know, seek goodbyes and once
- 49:23you're done with that, don't hesitate to ask how should I
- 49:25test that? Because then they were going to
- 49:27go to you and say, Oh well, you know we, we have this way of
- 49:29testing things typically, like I was saying in Tesoli torch
- 49:32value, we have this battery of tests that we run automatically.
- 49:35Here's here is where the dock is here is how you should do it.
- 49:38Here is an example of APR that does what you want to do.
- 49:42And by gathering that information, you can save
- 49:45yourself actually a lot of time and save the reviewer a lot of
- 49:48time because that person is going to have to, you know,
- 49:51review a code, then tell you, Oh well, you need to modify that.
- 49:54And that's, you know, sometimes spent for everyone.
- 49:57So if you can avoid that, that's better.
- 50:00What are the things you're most excited about working on in the
- 50:05next six months when it comes to Pytorch?
- 50:08Yeah. So I'm, I'm, I'm really excited
- 50:11about 10 Sodic. I, I, I think that we really
- 50:15have like an API that it's so generic.
- 50:20And, and the, the, the reason why I'm really excited about
- 50:23that is that I'm looking back, I, I try, sometimes try to do
- 50:26that exercise, you know, putting myself like six years ago and
- 50:29looking up by torch in it's early days.
- 50:31And I'm thinking if we had had tensoric at that time, what
- 50:36would have gone differently? Like what kind of thing would
- 50:39have been easier to code? And there's a lot of things like
- 50:42functional codes would have been easier, you know, but I don't
- 50:46know if you notice, but in Pythorch, when you're building
- 50:48an optimizer, you actually don't pass a state deck, but you pass
- 50:51a list of parameters. That's kind of weird because you
- 50:55know, when you represent your parameters to serialise them,
- 50:58you build a state deck. So why don't we use the same
- 51:00thing for both? If you had had tensor deck at
- 51:02the time within Pythorch to bite your ecosystem, we would
- 51:05probably have said a state deck is a tensor deck and the
- 51:08optimizer takes a tensor as input.
- 51:11I guess. I hope so, You know, and that
- 51:12would have been like, you know, everything is like unified.
- 51:16Where would I say represent parameters always as a tensor
- 51:19date. And that simplifies things in
- 51:21terms of writing the optimizer, in terms of passing things, in
- 51:24terms of serialising your optimizer or your model.
- 51:28You know, things would have been, I think probably better
- 51:32for some things. And I come from a field where
- 51:36people do a lot of fancy stuff like high order derivatives and
- 51:39things like that. And again, I think when I work
- 51:41with them, so I think it's so much easier to do some stuff.
- 51:45So I'm really excited about that.
- 51:47And the other thing is one of the things I'm I'm working on
- 51:51right now is basically to to work on the planning side of
- 51:55things. So, you know, planning is
- 51:57something that is super important, obviously in our
- 52:01health, you know, to play games like Go or chess.
- 52:05Also in robotics, you know, your robots needs to plan the kind of
- 52:09the, the movements it's going to do if you don't want it to crash
- 52:11into a row or something. But also obviously in the, in
- 52:14the realm of LLMS and things, planning is becoming, you know,
- 52:19always more important with, you know, strawberry and all this
- 52:22kind of things. We, we, we definitely saw that
- 52:24there's a huge trend there too. And I think torchial through it.
- 52:29So it has like the right API to solve this kind of problems
- 52:33because we deal very easily with things like representation of
- 52:37tree of thoughts and this kind of things.
- 52:40And I'm really excited about seeing where we can go in that
- 52:43space using this kind of primitives.
- 52:45So that's going to be part of my focus in in the next month.
- 52:49But yeah, hopefully we we will be able to ship some exciting
- 52:53stuff in the future. Are there any frameworks or
- 52:56libraries or anything that you're using that we should know
- 52:59about? Let me think about that.
- 53:04And while you're thinking it's just because I'm subscribed to
- 53:08this like tools dot dev or something like a dev tools dot
- 53:12something newsletter. And one of the coolest things is
- 53:16that they just have a bunch of random new frameworks and
- 53:20libraries and tools that come out every week.
- 53:23And it's like, oh, wow, 90% of them are not useful for me, but
- 53:29I still see them and know that they're out there.
- 53:31And it's kind of like, oh, cool, I guess that seems like it's a
- 53:34novel way of doing things, right?
- 53:36And so it's interesting when that happens.
- 53:38And I know that whenever we have meetups, some of the most
- 53:44passionate conversations amongst the people in the meet ups are,
- 53:49have you seen this tool? Oh, it has this feature that you
- 53:52can do and you should really check it out next time.
- 53:55And so that's almost like some of the fun stuff that happens
- 53:58when you get together with people.
- 54:01Yeah. So one thing I'm I'm using a lot
- 54:05for all my experiments in that I mentioned before is Hydra.
- 54:09I really think that it simplifies a lot, you know,
- 54:12experimenting with things. So basically there the one very
- 54:16nice thing about Hydra and one of the reasons I, I it's used a
- 54:19lot in the research community, but I think it's underused.
- 54:22And what I'm trying to say there is with Hydra one very powerful
- 54:26things that can easily do, you know, sweeps off your parameter
- 54:31configuration. So you can easily say, OK, I
- 54:34want to try learning rate of 0.10.010.001, you know, and it's
- 54:40just one line comment. You know, when you're running
- 54:42our experiment, you just say try those three different things and
- 54:45then you can sync that with your one DB account and it's going to
- 54:48run the three experiments and then you get the results too.
- 54:51And it's amazing you get that and and you can look at that and
- 54:54you're like, OK, this one is better than this other one.
- 54:57Another thing that's we're using a lot is this library called
- 55:01submitted. And that's something that I'm
- 55:03using also heavily to run experiments and submitted.
- 55:06The idea there is that it's, if you know about Slurm, you know,
- 55:08on a cluster, you're basically telling Slurm, OK, run those
- 55:11different experiments, submit it as a way to write this kind of
- 55:15stuff, but in Python. And so you can very easily
- 55:18interact with your model and say, OK, I'm going to create
- 55:21this instance of my model, but you're going to run that with
- 55:23these different set of parameters and it becomes very,
- 55:26very handy and much more intuitive for people who are
- 55:29used to use Python. So basically you can like
- 55:31configure things to go with slurm in a very flexible way
- 55:35without having to digest the whole like slurm duck or
- 55:40something like that. Which I've heard it is very
- 55:43painful sometimes. Yeah, it's not always obvious,
- 55:46especially if you look at things like what's defined as a job and
- 55:50as a task and like, it can be, Oh my gosh, what are we talking
- 55:54about? Or how many GPUs per node per
- 55:56task? And you're like, oh, I'm using
- 55:58my mind around that. So hopefully somebody can help
- 56:01you know, to to to simplify these things so you know.
- 56:04And for Hydra you are using it with another like experiment
- 56:09tracker such as one DB or ML flow and that.
- 56:12Yeah. So they're complimentary.
- 56:14Yeah, they're totally complimentary.
- 56:16Yeah, they're actually Hydra integrates very, very well with
- 56:19with these councils. Yeah, fascinating.
- 56:21All right, cool. Well, I got to check that out
- 56:23more. I haven't seen that, man.
- 56:25Vincent. Awesome dude.