Let LLM empowered the operator optimization.
The project name may be changed later.
Explore the docs »
View Demo
·
Report Bug
·
Request Feature
This project is a research project by C4Y, who is a student of Optima Research Group, and aims to use LLM to automatically optimize mathmetical calculating operators towards hardware design.
To get a local copy up and running follow these simple example steps.
The author strongly recommand to run the project in a Linux environment and use online LLM API services.
This project is mainly divided into two parts: the operator library implemented in C language and the automatic optimizer implemented in Python. These two parts need to be configured separately.
Additionally, a remote or local operator performance evaluation program is required, which also needs to be configured separately.
This project also utilizes a large language model for optimization, which requires access to an LLM service that complies with the OpenAI API SDK. In the actual code implementation, the Deepseek API is used.
sudo apt update
sudo apt install build-essential bison flex libgmp3-dev libmpc-dev libmpfr-dev texinfo
./configure --target=riscv64-unknown-elf --prefix=/opt/riscv --enable-languages=c,c++ --with-arch=rv64gc --with-abi=lp64d --enable-multilib --with-vector=$riscv_rvv_version
sudo apt install cmake
curl -sSL https://pdm-project.org/install-pdm.py | python3 - pdm --version
git clone https://github.com/c4yg70/LLM4Opt.git
cd python_process
pdm install
export DS_API_KEY = 'ENTER YOUR API'
export DS_API_URL = 'ENTER YOUR URL';
export SC_API_KEY = 'ENTER YOUR API';
export SC_API_URL = 'ENTER YOUR URL';
pdm check llm pdm check riscv-cloud
pdm check riscv-local
pdm start-opti --cycle 1 --llm 1 --cloud_eval 1
Now we could use LLM4Opt to optimize 20+ operators (BasicFunctions and ActivationFunctions) in both CMSIS-NN projects, which is the ARM-optimized NN Lib developed by the ARM officially, and muRISCV-NN, which is the RISCV-optimized NN Lib developed by project Scale4Edge, and evaluate the performance of the optimized operators.
Performance are tested both in lib level and application level. Lib level tests, which show the efficiency of single operator's optimization, are provided in eval_test. Application level tests, which show the efficiency of operator's optimization affecting the real-world application, are used MLPerfTiny, proposed by C. Banbury in 2021. All results are evaluated in Spacemit K1 processor provided by Bianbu Cloud, and provided in results.
Normally, a successful optimization will cost about 8-20 million tokens, depends on CoT length.
See the open issues for a full list of proposed features (and known issues).
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
git checkout -b feature/AmazingFeature)git commit -m 'Add some AmazingFeature')git push origin feature/AmazingFeature)Distributed under the project_license. See LICENSE.txt for more information.
CHEN Siyuan - siyuan.chen@cityu.edu.hk
Project Link: https://github.com/c4yg70/LLM4Opt