This repository implements secure, handy, accurate, and fast transformer inference based on CrypTen.
The following commands run successfully on Ubuntu 22.04 with Python 3.10.12.
python3 -m venv ~/env/shaft
source ~/env/shaft/bin/activatepip install torch==2.0.1 torchvision==0.15.2 torchaudio==2.0.2 --index-url https://download.pytorch.org/whl/cu118
pip install wheel==0.40.0git clone [https://github.com/andeskyl/SHAFT](https://github.com/Misat0N/SHAFT.git)
cd SHAFT
pip install .git clone -b 'v4.45.0' --depth 1 https://github.com/huggingface/transformers
pip install ./transformersWe have a set of sub-directories in the examples directory for reproducible experimental results. Additional dependencies for the experiments are included in the requirements.txt file in each subdirectory under the folder. Please refer to the README.md file in the sub-directories for instructions on how to set up and run the experiments.
unit-test- Costs of private softmax and GELU protocols.text-classification- Private inference costs of BERT-base and BERT-large.text-generation- Private inference cost of GPT-2.image-classification- Private inference cost of ViT-base.
You can cite our paper as follows:
@inproceedings{ndss/KeiC25,
author = {Andes Y. L. Kei and Sherman S. M. Chow},
title = {{SHAFT}: {Secure}, Handy, Accurate, and Fast Transformer Inference},
booktitle = {{NDSS}},
year = {2025}
}SHAFT is MIT licensed, as found in the LICENSE file.