-
Notifications
You must be signed in to change notification settings - Fork 318
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Suggesting a roadmap for v0.1 #12
Comments
Thanks for putting this together, indeed there is quite a bit of polishing needed to reach v0.1. To me the most important point is improving tutorials/examples (and documentation). This should help defining the good patterns for the library. I think good starting points are trying to port existing pytorch tutorials or the examples that I've put together in the ocaml version - this includes GAN, RL, finetuning models, etc... I feel that design choices should be defined by usage/feedback - and hopefully the api in its current form could already be used to do pretty nice things.
As per the scope, I feel that More specific points:
I've also posted on users.rust-lang.org to see if we can get more feedback. |
I general, I'd like to help make the crate more idiomatic. Several conversions, error handling, more test coverage, Rust ndarray integration (added to the list above) etc. can be improved and I've already started it from the most important ground-level improvements :)
I haven't used the torch C++ API (still unstable I think!). I thought you're targeting more of Python APIs, since this is what people are more interested in and the selling point for Python-DL community to come to Rust could be much greater that C++-Pytorch coming to Rust.
Absolutely! I'm working on this part now along with other idiomatic improvements that I see.
Well, comparing to PyTorch Python API there're a lot to be covered, but step by step :)
Great! yes, CI won't be free AFAIK.
That'd be great to test out and add some tutorials! It seems evcxr is the most promising though I haven't used it. |
Re rust ndarray integration, to start with I think it should probably be done in a separate crate that would have dependencies on both ndarray and tch. I would like to only have as few dependencies as possible for now - maybe if the result is small it could be integrated though (or if tch ends up having lots of dependencies anyway). Re being more idiomatic, that's probably a good goal. Would you have some pointers on what is not idiomatic enough yet ? I already made some change to use the Re C++ vs Python, I think it's probably easier to convince C++ people to use Rust than Python folks but that's a minor point. The main point is that as we're binding to the C++ api, it's simpler to mimic this. That being said the two apis are not that different. Happy to know which bits of the python api you're missing the most. On tensor operations I would think that it's already decently covered, same for optimizers, And just to emphasize again: I think that more examples/tutorials would be a great way to show what can be done with this in rust and also give us more insights on how to structure things. Finally a point I forgot in my previous message is writing extensions. There is a C++ tutorial on how to do this and if it's possible to do it in rust it seems like a nice selling point as it's difficult for python to compete here. |
One thing that can help is making
Adding some conversion supports should be enough like PyTorch, Numpy conversions. If you worry about dependencies, it can be behind a feature at least.
I'll send you a WIP PR soon showing exactly what I mean.
In broader scope, yes! I think there're folks (me included) who have already used PyTorch Python but not happy when it comes to statically typed, type/memory safety, deployment issues, etc. That was also mentioned by Yann LaCun's in his recent interview about programming language, type safety etc. So my point is this crate has a great potential of adoption by those folks.
Absolutely! I'm 100% with you. Examples/tutorials are great, no doubt and as much as reimplementations we can have in Rust, it'd make it even more awesome :)
Sure! that'd be great. I have some idea, though need to test their feasibility first, as it can lead to some new-ish territories. |
@LaurentMazare I'm now better familiar with the code base, so just updated the proposed list above. Sorry, if I wasn't specific enough initially. I started with little stuff to familiarize myself in the meantime. Please let me know if these're helpful and whether you want me to continue on this. |
@ehsanmok Thanks for all your work on this. Overall I feel that it's a bit early days to have that much of a detailed roadmap. I think I need one or two more weeks playing with the library and porting examples to understand better the proper use cases/abstractions. |
Closing this as things have diverged substantially since this list was created. I think a lot of the list made it and it's pretty usable right now and up to date with PyTorch v1.1.0 so I'll craft a 0.1 release soonish. |
Does tsh-rs support rayon (aka multi-threading) i.e for getting the probability of an image like in the sample from a pre-trained net? For example can this code (ripped part from the Readme) can run from many threads or does it need a Mutex to wrap the access to resnet? // Apply the forward pass of the model to get the logits and convert them // Finally print the top 5 categories and their associated probabilities. Thanks, |
Going to answer my self here that the answer is no because Tensor is !Sync Is there any reason not to make it Sync? |
I'm not sure there would much to be gained by applying something like rayon on top of a forward pass: the operations there would already be parallelized by the torch c++ api to use all available cores on your machine. As noted in this thread, it could actually get the other way around and harm performance. |
I see, thank you for the fast reply :) (I'm new to the ML stuff) I was wondering considering the thread you linked. If I have a per-trained model for image classifications, then there is no need for me to parallel the work per-image (I have thousands of images i want to classify), instead the parallelism will happen during the classification phase (working with the pre-trained model) did I understand things correct? |
I think that's right, all the operations done by your model (matrix multiplications, convolutions, etc) will run in parallel already using all the cores of your CPU (or potentially the execution units of your GPU), and you can also process a large number of images in the same batch to ensure that the overhead of going from an image to the other is not too large. |
Thanks! I will give it a try |
Hi Laurent
First of all, I wanted to thank you again for making this happen. Given the pace of the developments and I would love to see an amazing NN crate for Rust, below are my suggestions for v0.1 release.
failure
crate for error handle.unsafe_torch_err!
more often.//!
ndarray
.nn
.rayon
.core
,vision
,model_zoo
,ffi
insidetch
through vitual workspace manifest.Since you've put a lot of efforts so far and I guess functionality-wise you want to make this crate mimic your other similar projects, please let us know of any other plans to be on the same page.
The text was updated successfully, but these errors were encountered: