Skip to content

cmu-cryptosystems/BOLT

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BOLT

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.


1. Install dependencies (Ubuntu/Debian)

sudo apt-get install g++ cmake make libgmp-dev libssl-dev

Requires g++ ≥ 8 (C++17). OpenMP ships with g++. git with network access is needed to fetch SEAL/Eigen.

2. Get the code

git clone --recursive https://github.com/cmu-cryptosystems/BOLT.git
cd BOLT
# if you already cloned without --recursive:
git submodule update --init --recursive

3. Build

cd SCI
mkdir build && cd build
cmake -DCMAKE_INSTALL_PREFIX=./install ..
cmake --build . --target install --parallel

Binaries land in SCI/build/bin/.

4. Get the model weights

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.

5. Run secure inference

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=1

Client — 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=1

On a single machine use ip=127.0.0.1. The default port is 8000 (the run also uses 8001).

With word-elimination optimization (input pruning)

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

Common flags

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)

Plaintext accuracy reference

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-learn
python bert.py --data_dir <data> --task_name mrpc --sample_num 100   # add --online_prune for word elimination

Citation

@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}}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages