Skip to content

Commit 9f1b474

Browse files
committed
feat(coprocessor): add new scheduling infrastructure for multi-GPU
1 parent adbb42c commit 9f1b474

21 files changed

+4110
-410
lines changed

.github/workflows/coprocessor-benchmark-cpu.yml

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,23 @@ on:
1010
type: choice
1111
options:
1212
- "erc20"
13+
- "dex"
1314
- "synthetics"
1415
- "all"
1516
batch_size:
1617
description: "Batch sizes (# FHE operations executed per batch)"
1718
required: true
1819
type: string
1920
default: "5000"
21+
scheduling_policy:
22+
description: "Scheduling policy"
23+
required: true
24+
type: choice
25+
options:
26+
- "MAX_PARALLELISM"
27+
- "MAX_LOCALITY"
28+
- "LOOP"
29+
- "FINE_GRAIN"
2030

2131
env:
2232
CARGO_TERM_COLOR: always
@@ -54,6 +64,7 @@ jobs:
5464
timeout-minutes: 720 # 12 hours
5565
permissions:
5666
contents: 'read'
67+
packages: 'read'
5768
strategy:
5869
fail-fast: false
5970
# explicit include-based build matrix, of known valid options
@@ -64,11 +75,12 @@ jobs:
6475
gcc: 11
6576

6677
steps:
67-
- name: Install git LFS
78+
- name: Wait for unattended upgrades to complete
6879
run: |
69-
sudo systemctl stop unattended-upgrades
70-
sleep 10
7180
sudo apt-get update
81+
82+
- name: Install git LFS
83+
run: |
7284
sudo apt-get install -y git-lfs
7385
git lfs install
7486
@@ -91,13 +103,16 @@ jobs:
91103
} >> "${GITHUB_ENV}"
92104
93105
- name: Install rust
94-
uses: dtolnay/rust-toolchain@888c2e1ea69ab0d4330cbf0af1ecc7b68f368cc1
106+
uses: dtolnay/rust-toolchain@a54c7afa936fefeb4456b2dd8068152669aa8203
95107
with:
96108
toolchain: nightly
97109

98110
- name: Install cargo dependencies
99111
run: |
100112
sudo systemctl stop docker
113+
DEBIAN_FRONTEND=noninteractive sudo apt-get remove -y docker docker-engine docker.io containerd runc
114+
DEBIAN_FRONTEND=noninteractive sudo apt-get purge -y docker-ce docker-ce-cli containerd.io docker-compose-plugin docker-compose
115+
sudo rm -rf /etc/bash_completion.d/docker /usr/local/bin/docker-compose /etc/bash_completion.d/docker-compose
101116
DEBIAN_FRONTEND=noninteractive sudo apt-get install -y protobuf-compiler cmake \
102117
pkg-config libssl-dev \
103118
libclang-dev docker-compose-v2 \
@@ -118,6 +133,13 @@ jobs:
118133
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
119134
restore-keys: ${{ runner.os }}-cargo-
120135

136+
- name: Login to GitHub Container Registry
137+
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
138+
with:
139+
registry: ghcr.io
140+
username: ${{ github.actor }}
141+
password: ${{ secrets.GITHUB_TOKEN }}
142+
121143
- name: Init database
122144
run: make init_db
123145
working-directory: coprocessor/fhevm-engine/coprocessor
@@ -127,17 +149,13 @@ jobs:
127149
with:
128150
node-version: 20.x
129151

130-
- name: Build contracts
131-
env:
132-
HARDHAT_NETWORK: hardhat
152+
- name: Start localstack
133153
run: |
134-
cp ./host-contracts/.env.example ./host-contracts/.env
135-
npm --prefix ./host-contracts ci --include=optional
136-
cd host-contracts && npm install && npm run deploy:emptyProxies && npx hardhat compile
154+
docker run --rm -d -p 4566:4566 --name localstack localstack/localstack:latest
137155
138156
- name: Run benchmarks on CPU
139157
run: |
140-
BENCHMARK_BATCH_SIZE="${{ inputs.batch_size }}" make "benchmark_${{ inputs.benchmarks }}_cpu"
158+
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/coprocessor TXN_SENDER_TEST_GLOBAL_LOCALSTACK=1 BENCHMARK_BATCH_SIZE="${{ inputs.batch_size }}" FHEVM_DF_SCHEDULE="${{ inputs.scheduling_policy }}" make -e "benchmark_${{ inputs.benchmarks }}_cpu"
141159
working-directory: coprocessor/fhevm-engine/coprocessor
142160

143161
- name: Parse results
@@ -151,7 +169,7 @@ jobs:
151169
--commit-date "${{ env.COMMIT_DATE }}" \
152170
--bench-date "${{ env.BENCH_DATE }}" \
153171
--walk-subdirs \
154-
--name-suffix "operation_batch_size_${{ inputs.batch_size }}"
172+
--name-suffix "operation_batch_size_${{ inputs.batch_size }}-schedule_${{ inputs.scheduling_policy }}"
155173
156174
- name: Upload parsed results artifact
157175
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02

.github/workflows/coprocessor-benchmark-gpu.yml

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,40 @@ on:
2323
type: choice
2424
options:
2525
- "erc20"
26+
- "dex"
2627
- "synthetics"
2728
- "all"
2829
batch_size:
2930
description: "Batch sizes (# FHE operations executed per batch)"
3031
required: true
3132
type: string
3233
default: "5000"
34+
scheduling_policy:
35+
description: "Scheduling policy"
36+
required: true
37+
type: choice
38+
options:
39+
- "MAX_PARALLELISM"
40+
- "MAX_LOCALITY"
41+
- "LOOP"
42+
- "FINE_GRAIN"
43+
optimization_target:
44+
description: "Optimization target"
45+
required: false
46+
type: choice
47+
options:
48+
- "throughput"
49+
- "latency"
50+
default: "throughput"
51+
benchmark_type:
52+
description: "Benchmark type"
53+
required: false
54+
type: choice
55+
options:
56+
- "ALL"
57+
- "THROUGHPUT"
58+
- "LATENCY"
59+
default: "ALL"
3360

3461
env:
3562
CARGO_TERM_COLOR: always
@@ -87,6 +114,7 @@ jobs:
87114
timeout-minutes: 720 # 12 hours
88115
permissions:
89116
contents: 'read'
117+
packages: 'read'
90118
strategy:
91119
fail-fast: false
92120
# explicit include-based build matrix, of known valid options
@@ -125,7 +153,7 @@ jobs:
125153
{
126154
echo "BENCH_DATE=$(date --iso-8601=seconds)";
127155
echo "COMMIT_DATE=$(git --no-pager show -s --format=%cd --date=iso8601-strict ${{ github.sha }})";
128-
echo "COMMIT_HASH=$(git describe --tags --dirty)";
156+
echo "COMMIT_HASH=$(git rev-parse HEAD)";
129157
} >> "${GITHUB_ENV}"
130158
131159
- name: Install rust
@@ -155,6 +183,13 @@ jobs:
155183
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
156184
restore-keys: ${{ runner.os }}-cargo-
157185

186+
- name: Login to GitHub Container Registry
187+
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
188+
with:
189+
registry: ghcr.io
190+
username: ${{ github.actor }}
191+
password: ${{ secrets.GITHUB_TOKEN }}
192+
158193
- name: Init database
159194
run: make init_db
160195
working-directory: coprocessor/fhevm-engine/coprocessor
@@ -174,7 +209,7 @@ jobs:
174209
175210
- name: Run benchmarks on GPU
176211
run: |
177-
BENCHMARK_BATCH_SIZE="${{ inputs.batch_size }}" make "benchmark_${{ inputs.benchmarks }}_gpu"
212+
BENCHMARK_BATCH_SIZE="${{ inputs.batch_size }}" FHEVM_DF_SCHEDULE="${{ inputs.scheduling_policy }}" BENCHMARK_TYPE="${{ inputs.benchmark_type }}" OPTIMIZATION_TARGET="${{ inputs.optimization_target }}" make -e "benchmark_${{ inputs.benchmarks }}_gpu"
178213
working-directory: coprocessor/fhevm-engine/coprocessor
179214

180215
- name: Parse results
@@ -188,7 +223,8 @@ jobs:
188223
--commit-date "${{ env.COMMIT_DATE }}" \
189224
--bench-date "${{ env.BENCH_DATE }}" \
190225
--walk-subdirs \
191-
--name-suffix "operation_batch_size_${{ inputs.batch_size }}"
226+
--crate "coprocessor/fhevm-engine/coprocessor" \
227+
--name-suffix "operation_batch_size_${{ inputs.batch_size }}-schedule_${{ inputs.scheduling_policy }}-optimization_target_${{ inputs.optimization_target }}"
192228
193229
- name: Upload parsed results artifact
194230
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02

ci/benchmark_parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999
parser.add_argument(
100100
"--crate",
101101
dest="crate",
102-
default="fhevm-engine/coprocessor",
102+
default="coprocessor/fhevm-engine/coprocessor",
103103
help="Crate for which benchmarks have run",
104104
)
105105

coprocessor/fhevm-engine/coprocessor/.sqlx/query-103001177adaa90e37caa70082f41b06b89191305b8431eeecefb63286a04830.json

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coprocessor/fhevm-engine/coprocessor/.sqlx/query-514d2ee9ff416b42cc48b33df6a2ef5bb25f3ed9abdd2a03957d42252812278a.json

Lines changed: 46 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coprocessor/fhevm-engine/coprocessor/.sqlx/query-9d7dd33f60a053cf0f7e9a480d32ae6aaf684011580f0534afb25e0dd39d50a9.json

Lines changed: 0 additions & 46 deletions
This file was deleted.

coprocessor/fhevm-engine/coprocessor/Cargo.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ scheduler = { path = "../scheduler" }
5050
[features]
5151
nightly-avx512 = ["tfhe/nightly-avx512"]
5252
gpu = ["tfhe/gpu", "scheduler/gpu", "fhevm-engine-common/gpu"]
53+
bench = []
54+
latency = ["fhevm-engine-common/latency"]
55+
throughput = ["fhevm-engine-common/throughput"]
5356

5457
[dev-dependencies]
5558
testcontainers = { workspace = true }
@@ -81,3 +84,8 @@ harness = false
8184
name = "synthetics"
8285
path = "benches/synthetics.rs"
8386
harness = false
87+
88+
[[bench]]
89+
name = "dex"
90+
path = "benches/dex.rs"
91+
harness = false

coprocessor/fhevm-engine/coprocessor/Makefile

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11

22
DB_URL ?= DATABASE_URL=postgres://postgres:postgres@127.0.0.1:5432/coprocessor
3+
OPTIMIZATION_TARGET ?= throughput
34

45
.PHONY: build
56
build:
@@ -41,25 +42,33 @@ clean_run:
4142

4243
.PHONY: benchmark_erc20_gpu # Run ECR20 transfer benchmarks on GPU
4344
benchmark_erc20_gpu:
44-
RUSTFLAGS="-C target-cpu=native" $(DB_URL) cargo +nightly bench --bench erc20 --features=gpu --
45+
RUSTFLAGS="-C target-cpu=native" $(DB_URL) cargo +nightly bench --bench erc20 --features=gpu,bench,$(OPTIMIZATION_TARGET) --
46+
47+
.PHONY: benchmark_dex_gpu # Run DEX benchmarks on GPU
48+
benchmark_dex_gpu:
49+
RUSTFLAGS="-C target-cpu=native" $(DB_URL) cargo +nightly bench --bench dex --features=gpu,bench,$(OPTIMIZATION_TARGET) --
4550

4651
.PHONY: benchmark_synthetics_gpu # Run all benchmarks on GPU
4752
benchmark_synthetics_gpu:
48-
RUSTFLAGS="-C target-cpu=native" $(DB_URL) cargo +nightly bench --bench synthetics --features=gpu --
53+
RUSTFLAGS="-C target-cpu=native" $(DB_URL) cargo +nightly bench --bench synthetics --features=gpu,bench,$(OPTIMIZATION_TARGET) --
4954

5055
.PHONY: benchmark_all_gpu # Run all benchmarks on GPU
5156
benchmark_all_gpu:
52-
RUSTFLAGS="-C target-cpu=native" $(DB_URL) cargo +nightly bench --bench erc20 --bench synthetics --features=gpu --
57+
RUSTFLAGS="-C target-cpu=native" $(DB_URL) cargo +nightly bench --bench erc20 --bench dex --bench synthetics --features=gpu,bench,$(OPTIMIZATION_TARGET) --
5358

5459

5560
.PHONY: benchmark_erc20_cpu # Run ECR20 transfer benchmarks on CPU
5661
benchmark_erc20_cpu:
57-
RUSTFLAGS="-C target-cpu=native" $(DB_URL) cargo +nightly bench --bench erc20 --
62+
RUSTFLAGS="-C target-cpu=native" $(DB_URL) cargo +nightly bench --bench erc20 --features=bench --
63+
64+
.PHONY: benchmark_dex_cpu # Run DEX benchmarks on CPU
65+
benchmark_dex_cpu:
66+
RUSTFLAGS="-C target-cpu=native" $(DB_URL) cargo +nightly bench --bench dex --features=bench --
5867

5968
.PHONY: benchmark_synthetics_cpu # Run all benchmarks on CPU
6069
benchmark_synthetics_cpu:
61-
RUSTFLAGS="-C target-cpu=native" $(DB_URL) cargo +nightly bench --bench synthetics --
70+
RUSTFLAGS="-C target-cpu=native" $(DB_URL) cargo +nightly bench --bench synthetics --features=bench --
6271

6372
.PHONY: benchmark_all_cpu # Run all benchmarks on CPU
6473
benchmark_all_cpu:
65-
RUSTFLAGS="-C target-cpu=native" $(DB_URL) cargo +nightly bench --bench erc20 --bench synthetics --
74+
RUSTFLAGS="-C target-cpu=native" $(DB_URL) cargo +nightly bench --bench erc20 --bench dex --bench synthetics --features=bench --

0 commit comments

Comments
 (0)