Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Discussion options

Hey all,

First off, would like to say this is probably near the top, if not at the top, of my favourite DL books to read. I personally appreciated the careful explanations in every aspect of building an LLM -- I learned a lot in reading this book.

Second, I'm just about finished translating nearly all of the book's code into Rust using the Candle ML/DL framework. So, I thought it'd be a good time to share here in case there are others that might be interested in following this fantastic text with Rust "equivalent" code. Link to the repo and the docs are provided below. Contributions are welcome 馃

Cheers!

  • github repo
  • docs (NOTE: I will publish a new version of the docs probably by end of this week that will include all of the ch07 translations, which are already merged in the main branch of the github repo.)
You must be logged in to vote

Replies: 2 comments · 10 replies

Comment options

Glad you enjoyed the book. And wow, your repo is an amazing project! Haven't dabbled with Rust, yet, but now there's one more reason to get into it 馃槉. Thanks for sharing!!

You must be logged in to vote
9 replies
@nerdai
Comment options

馃挴 on your note dev vs. prod

So the rust translation is also able to run on cuda-enabled devices! (Candle also supports metal backend, but I haven't tested out Metal in my project).

# with cuda
cargo run --features cuda example 05.07

# without cuda
cargo run example 05.07

If you try and run with the cuda feature flag and you don't have a cuda device, then it should default to CPU. Similar to PyTorch, Candle has this device mapping logic Device::cuda_if_available().

@rasbt
Comment options

Oh that's great!

Btw regarding Metal, it works pretty well now as of a few months ago, but it you'll still see some numerical discrepancies vs CUDA or CPU. This becomes especially apparent during training runs where small rounding/precision differences add up over time. During inference, there's a non-noticeable difference though.

@nerdai
Comment options

Oh interesting! Thanks for this information. In that case, I should probably test these translations on Metal.

@rasbt
Comment options

I must say it got better in recent months though. And it mostly only affected training where numerical differences add up during backprop.

But yeah, here are some relevant discussions/observations from the Manning reader forum (you may have to be logged in to see the full reader comments; if you got the book from Amazon, there should be instructions on the first page on how to connect the book to the Manning account):

@nerdai
Comment options

Oh this is great! I'll give this a look. Thanks

Comment options

Related FWIW. Huggingface's TGI is written in Rust: https://huggingface.co/docs/text-generation-inference/en/index

You must be logged in to vote
1 reply
@rasbt
Comment options

Whoa, I had no idea! Thanks for sharing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.