Implementation of BOLT: Privacy-Preserving, Accurate and Efficient Inference for Transformers (IEEE S&P 2024).
This repo bundles the SCI 2PC library (from the EzPC bert branch);
SEAL and Eigen are git submodules and build automatically.
sudo apt-get install g++ cmake make libgmp-dev libssl-devRequires g++ ≥ 8 (C++17). OpenMP ships with g++. git with network access is needed to fetch SEAL/Eigen.
git clone --recursive https://github.com/cmu-cryptosystems/BOLT.git
cd BOLT
# if you already cloned without --recursive:
git submodule update --init --recursivecd SCI
mkdir build && cd build
cmake -DCMAKE_INSTALL_PREFIX=./install ..
cmake --build . --target install --parallelBinaries land in SCI/build/bin/.
Download the prepared weights_txt/ bundle for your task from Google Drive:
https://drive.google.com/drive/u/1/folders/13bBok39UevQ-6hDWHtBVtLJrYVo5VnsR
Place it under a directory of your choice so the files live at <data>/weights_txt/….
BOLT_BERT loads the model from <path>/weights_txt/ and reads each sample's
inputs_<i>_data.txt / inputs_<i>_mask.txt from the same folder.
Run one process per party (two terminals on one host, or two machines).
Server — ALICE (holds the weights):
cd SCI/build/bin
./BOLT_BERT r=1 path=<data> num_sample=1Client — BOB (holds the input, connects to the server):
cd SCI/build/bin
./BOLT_BERT r=2 ip=<server-ip> path=<data> output=<results.txt> num_sample=1On a single machine use ip=127.0.0.1. The default port is 8000 (the run also uses 8001).
Word elimination is built into BOLT_BERT and enabled with prune=1 (point path at the pruned-weights bundle):
./BOLT_BERT r=1 prune=1 path=<prune-data> num_sample=1 # server
./BOLT_BERT r=2 prune=1 ip=<server-ip> path=<prune-data> output=<results.txt> num_sample=1 # client| Flag | Meaning |
|---|---|
r |
Role: 1 = server (ALICE), 2 = client (BOB) — required |
path |
Directory containing weights_txt/ — always set |
ip |
Server address (client only) |
p |
Port (also uses p+1) |
num_sample |
Number of samples to run |
id |
Index of the first sample |
prune |
Word elimination / input pruning (1/0) |
output |
Output file (client only) |
bert.py runs the quantized model in the clear against the same weights to report accuracy.
Pass the data root with --data_dir — it reads <data_dir>/{quantize,prune}/<task>/weights_txt/:
pip install numpy torch transformers tqdm scipy scikit-learnpython bert.py --data_dir <data> --task_name mrpc --sample_num 100 # add --online_prune for word elimination@INPROCEEDINGS{bolt24,
author={Pang, Qi and Zhu, Jinhao and Möllering, Helen and Zheng, Wenting and Schneider, Thomas},
booktitle={2024 IEEE Symposium on Security and Privacy (SP)},
title={BOLT: Privacy-Preserving, Accurate and Efficient Inference for Transformers},
year={2024},
pages={4753-4771},
doi={10.1109/SP54263.2024.00130}}