Skip to content

Remove Metal feature #993

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

Merged
merged 4 commits into from
Apr 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ jobs:
components: clippy

- name: Run clippy
run: make clippy-metal
run: make clippy

- name: Run tests
run: make test-metal
run: make test
18 changes: 2 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: test clippy docker-shell nix-shell benchmarks benchmark docs build-cuda build-metal clippy-metal test-metal coverage clean
.PHONY: test clippy docker-shell nix-shell benchmarks benchmark docs build-cuda coverage clean

FUZZ_DIR = fuzz/no_gpu_fuzz

Expand Down Expand Up @@ -33,18 +33,8 @@ benchmark:
flamegraph_stark:
CARGO_PROFILE_BENCH_DEBUG=true cargo flamegraph --root --bench stark_benchmarks -- --bench

coverage:
coverage:
cargo llvm-cov nextest --lcov --output-path lcov.info

METAL_DIR = math/src/gpu/metal
build-metal:
xcrun -sdk macosx metal $(METAL_DIR)/all.metal -o $(METAL_DIR)/lib.metallib

clippy-metal:
cargo clippy --workspace --all-targets -F metal -- -D warnings

test-metal:
cargo test -F metal

CUDA_DIR = math/src/gpu/cuda/shaders
CUDA_FILES:=$(wildcard $(CUDA_DIR)/**/*.cu)
Expand All @@ -69,10 +59,6 @@ run-fuzzer:

proof-deserializer-fuzzer:
cargo +nightly fuzz run --fuzz-dir $(FUZZ_DIR) deserialize_stark_proof

run-metal-fuzzer:
cd fuzz/metal_fuzz
cargo +nightly fuzz run --fuzz-dir $(FUZZ_DIR) fft_diff

run-cuda-fuzzer:
cd fuzz/cuda_fuzz
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ This can be used in a multi prover setting for extra security, or as a standalon

### Fuzzers

Fuzzers are divided between the ones that use only the CPU, the ones that use Metal, and the ones that use CUDA.
Fuzzers are divided between the ones that use only the CPU, and the ones that use CUDA.

To use them, make sure you have installed ```cargo fuzzer```

Expand All @@ -153,7 +153,7 @@ make run-fuzzer FUZZER=stark252

The list of fuzzers can be found in `fuzz/no_gpu_fuzz`

Fuzzers for FTT in Metal and Cuda can be run with `make run-metal-fuzzer` and `make run-cuda-fuzzer`
Fuzzers for FTT in Cuda can be run with `make run-cuda-fuzzer`


Run a specific fuzzer from the ones contained in **fuzz/fuzz_targets/** folder with`cargo`, for example to run the one for the target `field_from_hex`:
Expand Down Expand Up @@ -222,7 +222,7 @@ The following links, repos, companies and projects have been important in the de

# Security

We take security seriously. If you discover a vulnerability in this project, please report it responsibly.
We take security seriously. If you discover a vulnerability in this project, please report it responsibly.

- You can report vulnerabilities directly via the **[GitHub "Report a Vulnerability" feature](../../security/advisories/new)**.
- Alternatively, send an email to **[security@lambdaclass.com](mailto:security@lambdaclass.com)**.
Expand Down
3 changes: 0 additions & 3 deletions crates/gpu/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ license.workspace = true

[dependencies]
thiserror = "1.0.38"
metal = { version = "0.24.0", optional = true }
objc = { version = "0.2.7", optional = true }

[dev-dependencies]
proptest = "1.1.0"
Expand All @@ -20,7 +18,6 @@ rand = "0.8.5"
walkdir = { version = "2.3.3", optional = true }

[features]
metal = ["dep:metal", "dep:objc"]
cuda = ["dep:walkdir"]

# Some features activate compilation of code which isn't
Expand Down
36 changes: 0 additions & 36 deletions crates/gpu/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,43 +50,7 @@ fn compile_cuda_shaders() {
});
}

#[cfg(feature = "metal")]
fn compile_metal_shaders() {
use std::process::Command;
let source_dir = env!("CARGO_MANIFEST_DIR").to_string() + "/../math/src/gpu/metal";

// Tell cargo to invalidate the built crate whenever the source changes
println!("cargo:rerun-if-changed={source_dir}");

let input = source_dir.clone() + "/all.metal";
let output = source_dir + "/lib.metallib";

println!("cargo:warning=compiling:'{input}'->'{output}'");

let cmd = Command::new("xcrun")
.args(["-sdk", "macosx", "metal"])
.arg(&input)
.arg("-o")
.arg(&output)
.spawn()
.expect("Failed to spawn process");

let res = cmd.wait_with_output().expect("Command waiting failed");

if !res.status.success() {
println!();
println!("{}", String::from_utf8(res.stdout).unwrap());
println!();
eprintln!("{}", String::from_utf8(res.stderr).unwrap());
println!();
panic!("Compilation failed for source '{}'", input);
}
}

fn main() {
#[cfg(feature = "cuda")]
compile_cuda_shaders();

#[cfg(feature = "metal")]
compile_metal_shaders();
}
9 changes: 0 additions & 9 deletions crates/gpu/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,2 @@
#[cfg(all(feature = "metal", feature = "cuda"))]
compile_error!(
"Can't enable both \"metal\" and \"cuda\" features at the same time.
If you were using the `--all-features` flag please read this crate's Cargo.toml"
);

#[cfg(feature = "metal")]
pub mod metal;

#[cfg(feature = "cuda")]
pub mod cuda;
17 changes: 0 additions & 17 deletions crates/gpu/src/metal/abstractions/errors.rs

This file was deleted.

2 changes: 0 additions & 2 deletions crates/gpu/src/metal/abstractions/mod.rs

This file was deleted.

115 changes: 0 additions & 115 deletions crates/gpu/src/metal/abstractions/state.rs

This file was deleted.

1 change: 0 additions & 1 deletion crates/gpu/src/metal/mod.rs

This file was deleted.

15 changes: 0 additions & 15 deletions crates/math/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ rand = { version = "0.8.5", default-features = false }
# rayon
rayon = { version = "1.7", optional = true }

# metal
metal = { version = "0.24.0", optional = true }
objc = { version = "0.2.7", optional = true }

# cuda
cudarc = { version = "0.9.7", optional = true }

Expand Down Expand Up @@ -55,12 +51,6 @@ instruments = []


# gpu
metal = [
"dep:metal",
"dep:objc",
"dep:lambdaworks-gpu",
"lambdaworks-gpu?/metal",
]
cuda = ["dep:cudarc", "dep:lambdaworks-gpu"]

[target.wasm32-unknown-unknown.dependencies]
Expand Down Expand Up @@ -102,8 +92,3 @@ harness = false
[[bench]]
name = "iai_fft"
harness = false

[[bench]]
name = "criterion_metal"
harness = false
required-features = ["metal"]
4 changes: 2 additions & 2 deletions crates/math/benches/criterion_fft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ fn poly_interpolation_benchmarks(c: &mut Criterion) {
group.finish();
}

#[cfg(not(any(feature = "metal", feature = "cuda")))]
#[cfg(not(feature = "cuda"))]
criterion_group!(
name = seq_fft;
config = Criterion::default().sample_size(10);
Expand All @@ -152,7 +152,7 @@ criterion_group!(
poly_interpolation_benchmarks,
);

#[cfg(any(feature = "metal", feature = "cuda"))]
#[cfg(feature = "cuda")]
criterion_group!(
name = seq_fft;
config = Criterion::default().sample_size(10);
Expand Down
Loading
Loading