Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: experimental gpu support #1219

Merged
merged 26 commits into from
Aug 2, 2024
642 changes: 409 additions & 233 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ members = [
"recursion/gnark-cli",
"recursion/gnark-ffi",
"recursion/program",
"server",
"sdk",
"zkvm/*",
]
Expand Down
3 changes: 2 additions & 1 deletion core/src/runtime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ use std::io::BufWriter;
use std::io::Write;
use std::sync::Arc;

use serde::{Deserialize, Serialize};
use thiserror::Error;

use crate::alu::create_alu_lookup_id;
Expand Down Expand Up @@ -118,7 +119,7 @@ pub struct Runtime<'a> {
pub max_cycles: Option<u64>,
}

#[derive(Error, Debug)]
#[derive(Error, Debug, Serialize, Deserialize)]
pub enum ExecutionError {
#[error("execution failed with exit code {0}")]
HaltWithNonZeroExitCode(u32),
Expand Down
2 changes: 1 addition & 1 deletion core/src/runtime/record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ pub struct ExecutionRecord {
pub nonce_lookup: HashMap<u128, u32>,
}

#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct SplitOpts {
pub deferred_shift_threshold: usize,
pub keccak_split_threshold: usize,
Expand Down
6 changes: 4 additions & 2 deletions core/src/utils/options.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use std::env;

use serde::{Deserialize, Serialize};

use crate::runtime::{SplitOpts, DEFERRED_SPLIT_THRESHOLD};

const DEFAULT_SHARD_SIZE: usize = 1 << 22;
Expand All @@ -8,7 +10,7 @@ const DEFAULT_TRACE_GEN_WORKERS: usize = 1;
const DEFAULT_CHECKPOINTS_CHANNEL_CAPACITY: usize = 128;
const DEFAULT_RECORDS_AND_TRACES_CHANNEL_CAPACITY: usize = 1;

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub struct SP1ProverOpts {
pub core_opts: SP1CoreOpts,
pub recursion_opts: SP1CoreOpts,
Expand All @@ -23,7 +25,7 @@ impl Default for SP1ProverOpts {
}
}

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub struct SP1CoreOpts {
pub shard_size: usize,
pub shard_batch_size: usize,
Expand Down
30 changes: 16 additions & 14 deletions examples/Cargo.lock

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

35 changes: 35 additions & 0 deletions server/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
[package]
name = "sp1-server"
description = "SP1 is a performant, 100% open-source, contributor-friendly zkVM."
readme = "../README.md"
version = { workspace = true }
edition = { workspace = true }
license = { workspace = true }
repository = { workspace = true }
keywords = { workspace = true }
categories = { workspace = true }

[dependencies]
sp1-core = { workspace = true }
sp1-prover = { workspace = true }
prost = "0.13"
prost-types = "0.13"
bincode = "1.3.3"
serde = { version = "1.0.197", features = ["derive"] }
serde_json = "1.0.114"
tokio = { version = "^1.38.0", features = ["full"] }
tracing = "0.1.40"
tracing-subscriber = "0.3.18"
twirp = { git = "https://github.com/github/twirp-rs.git" }
ctrlc = "3.4.4"

[build-dependencies]
prost-build = { version = "0.13", optional = true }
twirp-build = { git = "https://github.com/github/twirp-rs.git", optional = true }

[dev-dependencies]
sp1-core = { workspace = true, features = ["programs"] }

[features]
default = []
protobuf = ["dep:prost-build", "dep:twirp-build"]
12 changes: 12 additions & 0 deletions server/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
fn main() {
// This is commented out because it requires for the protobuf-compiler to be installed.
//
// println!("cargo:rerun-if-changed=.");
// let mut config = prost_build::Config::new();
// config
// .out_dir("src/proto")
// .type_attribute(".", "#[derive(serde::Serialize,serde::Deserialize)]")
// .service_generator(twirp_build::service_generator())
// .compile_protos(&["./proto/api.proto"], &["./proto"])
// .unwrap();
}
24 changes: 24 additions & 0 deletions server/proto/api.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
syntax = "proto3";

package api;

service ProverService {
rpc ProveCore(ProveCoreRequest) returns (ProveCoreResponse) {}
rpc Compress(CompressRequest) returns (CompressResponse) {}
}

message ProveCoreRequest {
bytes data = 1;
}

message ProveCoreResponse {
bytes result = 1;
}

message CompressRequest {
bytes data = 1;
}

message CompressResponse {
bytes result = 1;
}
Loading
Loading