This repository contains the code for the paper "Explore Activation Sparsity in Recurrent LLMs for Energy-Efficient Neuromorphic Computing". Currently, the algorithm is implemented by cloning RWKV and Metaseq repositories.
Download Minipile dataset by running LLM-activation-sparsity/datasets/minipile_download.py
Install required packages from LLM-activation-sparsity/requirements.txt
Download the needed RWKV-4 models using LLM-activation-sparsity/RWKV-LM/download_models.sh
- Execute
run_preprocess.shfrom./minipile_preprocessing. NOTE: To tokenize train subset changetokenize_splits.sh
- Execute
experiment_run.shto run sparsification. Specify the dense RWKV model. Setstart_k,step,k_num,loss_incsparsification parameters corresponding to the article. - Execute
run_lm_eval.shto evaluate the sparsified model including validation on a test subset and the main benchmarks. Specify the evaluated model and the benchmarks in the script.
Download the needed OPT models using LLM-activation-sparsity/metaseq/test_run_dir/models/download_models.sh
Requirements (from LLM-activation-sparsity/metaseq)
Make sure that RWKV required packages are installed.
Install needed packages (can be found in metaseq)
# installing metaseq
pip3 install -e .
# installing fairscale
git clone https://github.com/facebookresearch/fairscale.git
cd fairscale
git checkout fixing_memory_issues_with_keeping_overlap_may24
pip3 install -e .
- Execute
prepare_opt_dataset.pyto preprocess the dataset. Changeinit_size_multto change the size of the initialization subset.
- Execute
experiment_run.shto run sparsification. Specify the dense model and set sparsification parameters the same way as for RWKV. - Execute
run_lm_eval.shto evaluate OPT models.