Skip to content

Commit

Permalink
feat(prover): add GPU feature for compressor (#1838)
Browse files Browse the repository at this point in the history
## What ❔

Integrate GPU proof compressors into monorepo.
GPU compressors can be run with `gpu` feature.

## Why ❔

Running compressors with GPU significantly improves efficiency.
CPU compressor average proving time - 15 minutes
GPU compressor average proving time - 2 minutes

## Checklist

<!-- Check your PR fulfills the following items. -->
<!-- For draft PRs check the boxes as you complete them. -->

- [x] PR title corresponds to the body of PR (we generate changelog
entries from PRs).
- [x] Tests for the changes have been added / updated.
- [x] Documentation comments have been added / updated.
- [x] Code has been formatted via `zk fmt` and `zk lint`.
- [x] Spellcheck has been run via `zk spellcheck`.
- [x] Linkcheck has been run via `zk linkcheck`.
  • Loading branch information
Artemka374 authored May 21, 2024
1 parent fc2fe4e commit e9a2213
Show file tree
Hide file tree
Showing 17 changed files with 346 additions and 78 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ keys/setup
!Cargo.toml
!contracts/
!setup_2\^26.key
!setup_2\^24.key
# It's required to remove .git from contracts,
# otherwise yarn tries to use .git parent directory that
# doesn't exist.
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/build-contract-verifier-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ jobs:
runs-on: ${{ fromJSON('["matterlabs-ci-runner", "matterlabs-ci-runner-arm"]')[contains(matrix.platforms, 'arm')] }}
strategy:
matrix:
components:
- contract-verifier
- verified-sources-fetcher
platforms:
- linux/amd64
components:
- contract-verifier
- verified-sources-fetcher
platforms:
- linux/amd64

steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4
Expand Down
18 changes: 9 additions & 9 deletions .github/workflows/build-core-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ jobs:
runs-on: ${{ fromJSON('["matterlabs-ci-runner", "matterlabs-ci-runner-arm"]')[contains(matrix.platforms, 'arm')] }}
strategy:
matrix:
components:
- server-v2
- external-node
- snapshots-creator
platforms:
- linux/amd64
include:
- components: external-node
platforms: linux/arm64
components:
- server-v2
- external-node
- snapshots-creator
platforms:
- linux/amd64
include:
- components: external-node
platforms: linux/arm64

steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4
Expand Down
13 changes: 10 additions & 3 deletions .github/workflows/build-prover-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
RUNNER_COMPOSE_FILE: "docker-compose-runner-nightly.yml"
ERA_BELLMAN_CUDA_RELEASE: ${{ inputs.ERA_BELLMAN_CUDA_RELEASE }}
CUDA_ARCH: ${{ inputs.CUDA_ARCH }}
runs-on: [matterlabs-ci-runner]
runs-on: [ matterlabs-ci-runner ]
strategy:
matrix:
component:
Expand All @@ -51,6 +51,7 @@ jobs:
- witness-vector-generator
- prover-fri-gateway
- proof-fri-compressor
- proof-fri-gpu-compressor
steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4
with:
Expand Down Expand Up @@ -80,11 +81,17 @@ jobs:
ci_run zk
# We need the CRS only for the fri compressor.
- name: download CRS
- name: download CRS for CPU compressor
if: matrix.component == 'proof-fri-compressor'
run: |
ci_run curl --retry 5 -LO https://storage.googleapis.com/matterlabs-setup-keys-us/setup-keys/setup_2\^26.key
- name: download CRS for GPU compressor
if: matrix.component == 'proof-fri-gpu-compressor'
run: |
ci_run curl --retry 5 -LO https://storage.googleapis.com/matterlabs-setup-keys-us/setup-keys/setup_2\^24.key
- name: login to Docker registries
if: github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/'))
run: |
Expand Down Expand Up @@ -138,7 +145,7 @@ jobs:
env:
DOCKER_ACTION: ${{ inputs.action }}
COMPONENT: ${{ matrix.component }}
run: |
run: |
PASSED_ENV_VARS="ERA_BELLMAN_CUDA_RELEASE,CUDA_ARCH" \
ci_run zk docker $DOCKER_ACTION $COMPONENT
Expand Down
10 changes: 5 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions checks-config/era.dic
Original file line number Diff line number Diff line change
Expand Up @@ -961,3 +961,6 @@ vec
zksync_merkle_tree
TreeMetadata
delegator
Bbellman
Sbellman
DCMAKE
2 changes: 1 addition & 1 deletion core/lib/config/src/configs/fri_proof_compressor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub struct FriProofCompressorConfig {

/// Path to universal setup key file
pub universal_setup_path: String,
/// https://storage.googleapis.com/matterlabs-setup-keys-us/setup-keys/setup_2\^26.key
/// https://storage.googleapis.com/matterlabs-setup-keys-us/setup-keys/setup_2\^24.key
pub universal_setup_download_url: String,

// Whether to verify wrapper proof or not.
Expand Down
48 changes: 48 additions & 0 deletions docker/proof-fri-gpu-compressor/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Will work locally only after prior universal setup key download
FROM nvidia/cuda:12.2.0-devel-ubuntu22.04 as builder

ARG DEBIAN_FRONTEND=noninteractive

ARG CUDA_ARCH=89
ENV CUDAARCHS=${CUDA_ARCH}

RUN apt-get update && apt-get install -y curl clang openssl libssl-dev gcc g++ git \
pkg-config build-essential libclang-dev && \
rm -rf /var/lib/apt/lists/*

ENV RUSTUP_HOME=/usr/local/rustup \
CARGO_HOME=/usr/local/cargo \
PATH=/usr/local/cargo/bin:$PATH

RUN curl https://sh.rustup.rs -sSf | bash -s -- -y && \
rustup install nightly-2023-08-21 && \
rustup default nightly-2023-08-21

RUN curl -Lo cmake-3.24.2-linux-x86_64.sh https://github.com/Kitware/CMake/releases/download/v3.24.2/cmake-3.24.2-linux-x86_64.sh && \
chmod +x cmake-3.24.2-linux-x86_64.sh && \
./cmake-3.24.2-linux-x86_64.sh --skip-license --prefix=/usr/local

WORKDIR /usr/src/zksync
COPY . .

RUN cd prover && \
git clone https://github.com/matter-labs/era-bellman-cuda.git --branch main bellman-cuda && \
cmake -Bbellman-cuda/build -Sbellman-cuda/ -DCMAKE_BUILD_TYPE=Release && \
cmake --build bellman-cuda/build/

RUN cd prover && BELLMAN_CUDA_DIR=$PWD/bellman-cuda cargo build --features "gpu" --release --bin zksync_proof_fri_compressor

FROM nvidia/cuda:12.2.0-runtime-ubuntu22.04

RUN apt-get update && apt-get install -y curl libpq5 ca-certificates && rm -rf /var/lib/apt/lists/*

# copy VK required for proof wrapping
COPY prover/vk_setup_data_generator_server_fri/data/ /prover/vk_setup_data_generator_server_fri/data/

COPY setup_2\^24.key /setup_2\^24.key

ENV CRS_FILE=/setup_2\^24.key

COPY --from=builder /usr/src/zksync/prover/target/release/zksync_proof_fri_compressor /usr/bin/

ENTRYPOINT ["zksync_proof_fri_compressor"]
18 changes: 9 additions & 9 deletions etc/env/base/fri_proof_compressor.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[fri_proof_compressor]
compression_mode=1
prometheus_listener_port=3321
prometheus_pushgateway_url="http://127.0.0.1:9091"
prometheus_push_interval_ms=100
generation_timeout_in_secs=3600
max_attempts=5
universal_setup_path="../keys/setup/setup_2^26.key"
universal_setup_download_url="https://storage.googleapis.com/matterlabs-setup-keys-us/setup-keys/setup_2^26.key"
verify_wrapper_proof=true
compression_mode = 1
prometheus_listener_port = 3321
prometheus_pushgateway_url = "http://127.0.0.1:9091"
prometheus_push_interval_ms = 100
generation_timeout_in_secs = 3600
max_attempts = 5
universal_setup_path = "../keys/setup/setup_2^24.key"
universal_setup_download_url = "https://storage.googleapis.com/matterlabs-setup-keys-us/setup-keys/setup_2^24.key"
verify_wrapper_proof = true
4 changes: 2 additions & 2 deletions etc/env/file_based/general.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,8 @@ proof_compressor:
prometheus_push_interval_ms: 100
generation_timeout_in_secs: 3600
max_attempts: 5
universal_setup_path: keys/setup/setup_2^26.key
universal_setup_download_url: https://storage.googleapis.com/matterlabs-setup-keys-us/setup-keys/setup_2^26.key
universal_setup_path: keys/setup/setup_2^24.key
universal_setup_download_url: https://storage.googleapis.com/matterlabs-setup-keys-us/setup-keys/setup_2^24.key
verify_wrapper_proof: true
prover_group:
group_0:
Expand Down
2 changes: 2 additions & 0 deletions infrastructure/zk/src/docker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const IMAGES = [
'witness-vector-generator',
'prover-fri-gateway',
'proof-fri-compressor',
'proof-fri-gpu-compressor',
'snapshots-creator',
'verified-sources-fetcher'
];
Expand Down Expand Up @@ -79,6 +80,7 @@ function defaultTagList(image: string, imageTagSha: string, imageTagShaTS: strin
'witness-vector-generator',
'prover-fri-gateway',
'proof-fri-compressor',
'proof-fri-gpu-compressor',
'snapshots-creator'
].includes(image)
? ['latest', 'latest2.0', `2.0-${imageTagSha}`, `${imageTagSha}`, `2.0-${imageTagShaTS}`, `${imageTagShaTS}`]
Expand Down
Loading

0 comments on commit e9a2213

Please sign in to comment.