-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
[RFC] Rust Support #1601
Comments
From an organizational perspective, we can have
the |
Please also comment on official code-styles that we should generally follow in rust package |
The |
I would be happy to jump in and do some Rust hacking in the future with you guys, but am pretty busy with some new TVM stuff @tqchen and I have been working on. I'm happy to provide feedback and code review though, until I have a few more cycles available. Current incremental plan to getting started with Rust sounds good to me. |
rust runtime is merged in #1597 |
Here are a few next steps:
|
regarding docs, the conventional approach is to simply upload each release of the |
OK, we can do that then if that is the conventional approach of rust |
Rust CI is up and running |
@tqchen Sorry, I was quite detached for some time and trying to finish it as soon as I can in my free time. I'm working on ergonimic registration of callbacks in Rust, when that's done I'd probably need help for the RPC as looking at the python and java RPC it's seems they have been sort of done from scratch! |
Now that we're on the topic, might it be a good time to start experimenting with a more established framework like grpc? There's even a nice crate for it! I may be completely incorrect in saying this, but I think that many of the roll-your-own components are a result of C++ having a terrible package ecosystem. For instance, the dmlc-core json parser, the memory stream reader used for params serdes, the thread-local store. In Rust, these become In some version of reality, the TVM compiler is rewritten in Rust (with clear separation from the python components!) and is much more maintainable because of it. |
We roll out our own RPC because the requirement is somewhat different from grpc. We need a lightweight stateful session that persists over multiple function calls, it also helps porting into devices like android. So there is a reason for rolling out the rpc module. I agree that json parser and thread local are somewhat unnecessary(thread_local is already supported in c++11 and it is there only for old compilers) |
On the topic of TVM compiler in Rust, I have seriously thought about it and discussed with @jroesch on possibilities. My current take is that the things would be fine if everything is in Rust, but that is not what we really want. We want something that can interop (i.e. a good runtime system) and still enables writing pass in python, things might break in that land because of that ventures into a new territory. We will need a clear C data structure, and rust wrappers that gives you the safety guarantee you want. In the most ideal world, we want the following thing:
|
@nhynes right! I already looked a little into tarpc and jsonrpc to get some ideas. Given
I cannot find a Rust lib that we can leverage so probably should write our own! Do you know such a lib and what do you suggest? @tqchen I like the most ideal case, but since
is a major requirement, maybe I'm wrong but I don't think using some promising Rust python bindings such as pyo3 can handle that easily yet! |
Of
rust-python programming isn't bad if there's a C repr. Unfortunately, that's the really hard part since it'd need yet another IR, as the HalideIR is also C++. The real issue I have with python-c++ is that even if the ops are written in C++, the schedules and patterns are still in python! |
I won't worry about the IR, but what we really want is a node system(like the one we had in tvm::Node), once we have that, we can always build an IR around |
Hopefully before the end of this week, I'll complete writing the docs and be ready for PR. In the meantime, you can checkout the resnet example. @nhynes I'd like to know in the proposed setup
shall we have a common, unified Also for the @tqchen Btw I don't want to go through impl of RPC as I haven't found a good Rust option satisfying the requirements yet. It needs separate work after the frontend is merged as well as contrib graph runtime support. |
Unfortunately, no because bindgen doesn't work when the target is exotic (e.g., wasm or sgx). That's why the headers are checked in as code. You're welcome to keep it as a top-level crate, though Let's see how else your implementation looks, though. We might want a top-level
Two spaces is also common. At Google, 2 is used to make deeply nested code more readable. I'll defer to other community members here, but my strong preference is two spaces since it makes code more readable (esp. for rust where functional patterns encourage deep nesting). Again, let's see how your PR looks before we make a final decision. We should update (and stabilize on) rustfmt 1.0 at the same time, too. |
@tqchen This can be closed now. |
What is the current status of Rust support? The current bindings don't work, and the |
There are two parts of the things that can be done in rust:
Both have values and I think we should have a good discussion on how can we organize them.
cc @jroesch @nhynes @ehsanmok
The text was updated successfully, but these errors were encountered: