A Yocto experience: Workshop with Michael Opdenacker
Note
TL;DR In this workshop with Micheal Opdenacker, we were able to perform LLM inference on a powerful device using RISC-V with custom additional AI cores. As the task was partially successful, it cleared the way for bringing the findings to Yocto distributions.
First of all, we would like to thank Michael Opdenacker for this workshop. His insights were useful beyond Yocto itself, and the workshop would have been worth even just for his kind personality.
The problem
Michael Opdenacker brought us a new board based on the K3 RISC-V-based CPU from Spacemit. The board is the Pico-ITX machine, and it features 32 GB of RAM.
The K3 CPU has an A100 AI accelerator. Our project wants to make use of those to provide a fast LLM inference setup on this machine.
The first steps: Yocto, hardware support and inference
In the beginning, we used Yocto to build the first images that need to be flashed. Thankfully, the meta-riscv layer already supports this CPU, as the Linux kernel itself does. We used Yocto with Kas as a build environment, enabling us to have a safe and reproducible virtual environment. There was one issue: as the support for the CPU is there, there is no support for the AI cores!
This was tested in the workshop through the use of ollama.cpp, a program providing a common interface for LLM models to be downloaded, stored and used on a local machine. Using ollama.cpp allows us to perform almost effortless (on the human side) inferences. We tested one small “reasoning” model inside the device, as our first objective was to assess the tokens evaluated per second. In this stage, the thgoughput was of about 3~4 tokens/sec.
The other OS: Ubuntu Core
Ubuntu Core is a distribution provided by Canonical, mainly aimed at IOT devices. However, we know that the Linux kernel supports RISC-V and this board in particular. Ubuntu Core also provides us with a live environment, able to download Ubuntu-compatible packages from its package managers (such as Snap and Apt).
Through Apt, we were able to download ollama.cpp. However, there was probably some build misconfiguration, as the packet itself was built without the integration with OpenSSL, thus being unable to perform HTTPS requests. However, here shines the open-source nature of the project: we can have good documentation through the internet!
Together we found where the models are stored and were able to download and resize the same one we already used before, fitting the size of the board memory and capabilities. Through this, we were able to understand that Ubuntu Core has the logic to, at least partially, use the AI cores, as the throughput went up to about 14 tokens/sec.
What we can do from now
As clearly Ubuntu Core is doing something that we are not, it is possible to learn from it and port the new fidings to Yocto, making them available on this machine even using different Linux distributions.
Tip
Amarula Solutions hosts frequent talks and workshops with in-field experts. Interested in joining our team or learning more about us? Contact us