Hugging Face has written a new ML framework in Rust, now open-sourced!

<p>Recently, Hugging Face open sourced a heavyweight ML framework,&nbsp;<a href="https://github.com/huggingface/candle" rel="noopener ugc nofollow" target="_blank">Candle</a>, which is a departure from the usual Python approach to machine learning, written in Rust with a focus on performance (including GPU support) and ease of use.</p> <p>According to Hugging Face, Candle&rsquo;s core goal is to make Serverless inference possible. Full machine learning frameworks like PyTorch are very large, which makes it slow to create instances on a cluster; Candle allows for the deployment of lightweight binaries. Additionally, Candle allows users to remove Python from production workloads. Python overhead can have a serious impact on performance, and&nbsp;<a href="https://www.backblaze.com/blog/the-python-gil-past-present-and-future/" rel="noopener ugc nofollow" target="_blank">GIL</a>&nbsp;is a known headache.</p> <h1>Is Rust really possible?</h1> <p>The Pytorch framework is written in Python, and the API is based on Python, which makes getting started very fast. In addition, Python itself is a simple and easy-to-learn programming language, which makes it suitable for both beginners and professional developers.</p> <p>However, the Python-based Pytorch framework has obvious problems. Python can cause performance problems in some cases compared to some static graph frameworks such as TensorFlow, Python&rsquo;s Global Interpreter Lock (GIL) can affect performance in multi-threaded situations, especially when it comes to CPU-intensive tasks, and Python&rsquo;s interpreted nature can also introduce some runtime overhead. Additionally, deploying Python-based PyTorch models into a production environment may require some extra steps that are not as convenient as other compiled languages.</p> <p>Apparently, Hugging Face has been looking for a solution, and its answer is to rewrite an ML framework in Rust, the fastest language available today. &ldquo;What&rsquo;s cool is that this is from Hugging Face, not just someone&rsquo;s hobby project.&rdquo; One user exclaimed. In fact, many HF ecosystems already use Rust, such as&nbsp;<a href="https://github.com/huggingface/safetensors" rel="noopener ugc nofollow" target="_blank">safetensors</a>,&nbsp;<a href="https://github.com/huggingface/tokenizers" rel="noopener ugc nofollow" target="_blank">tokenizer</a>.</p> <p>However, the difficulty of Rust has also put some developers off, &ldquo;Writing Rust is a tough thing to do, you have to jump around and spend more time thinking about the abstractions of the programming language than you do thinking about the problem to be solved. So I&rsquo;m in no hurry to rewrite anything in Python just yet.&rdquo;</p> <p><a href="https://medium.com/@Aaron0928/hugging-face-has-written-a-new-ml-framework-in-rust-now-open-sourced-1afea2113410"><strong>Website</strong></a></p>