Skip to content

Commit 8711c0c

Browse files
authored
fix QuantumCircuit (#257)
* fix QuantumCircuit
1 parent 27889d0 commit 8711c0c

50 files changed

Lines changed: 3737 additions & 499 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Cargo.lock

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

Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pest = "2"
4141
pest_derive = "2"
4242
tempfile = "3"
4343
assert_cmd = "2"
44-
wasmtime = { version = "41", default-features = false, features = [
44+
wasmtime = { version = "42", default-features = false, features = [
4545
"cranelift",
4646
"runtime",
4747
"wat",
@@ -51,6 +51,7 @@ wat = "1"
5151
ron = "0.12"
5252
tket = { version = "0.17", default-features = false }
5353
tket-qsystem = { version = "0.23", default-features = false }
54+
bindgen = "0.72"
5455
cc = "1"
5556
cxx = "1"
5657
cxx-build = "1"
@@ -98,6 +99,7 @@ bitvec = { version = "1", features = ["serde"] }
9899
ndarray = "0.17"
99100

100101
# RNG
102+
fastrand = "2"
101103
rand = "0.10"
102104
rand_core = "0.10"
103105
rand_xoshiro = "0.8"
@@ -145,6 +147,7 @@ pecos-num = { version = "0.1.1", path = "crates/pecos-num" }
145147
pecos-quantum = { version = "0.1.1", path = "crates/pecos-quantum" }
146148
pecos-gpu-sims = { version = "0.1.1", path = "crates/pecos-gpu-sims" }
147149
pecos-cuquantum = { version = "0.1.1", path = "crates/pecos-cuquantum" }
150+
pecos-cuquantum-sys = { version = "0.1.1", path = "crates/pecos-cuquantum-sys" }
148151

149152
# Decoder crates
150153
pecos-decoder-core = { version = "0.1.1", path = "crates/pecos-decoder-core" }

crates/benchmarks/Cargo.toml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,17 @@ all-sims = ["gpu-sims", "cuquantum", "quest", "qulacs", "cppsparsesim"]
2525

2626
[dependencies]
2727
# Optional simulator dependencies for benchmarking
28-
pecos-gpu-sims = { path = "../pecos-gpu-sims", optional = true }
29-
pecos-cuquantum = { path = "../pecos-cuquantum", optional = true }
30-
pecos-quest = { path = "../pecos-quest", optional = true }
31-
pecos-qulacs = { path = "../pecos-qulacs", optional = true }
28+
pecos-gpu-sims = { workspace = true, optional = true }
29+
pecos-cuquantum = { workspace = true, optional = true }
30+
pecos-quest = { workspace = true, optional = true }
31+
pecos-qulacs = { workspace = true, optional = true }
3232
pecos-cppsparsesim = { workspace = true, optional = true }
3333
pecos-core.workspace = true
3434
pecos-qsim.workspace = true
3535

3636
[dev-dependencies]
3737
criterion.workspace = true
38+
cxx.workspace = true
3839
num-complex.workspace = true
3940
pecos = { workspace = true, features = ["runtime"] }
4041
pecos-engines.workspace = true

crates/benchmarks/benches/benchmarks.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,12 @@ mod modules {
1818
pub mod dem_sampler;
1919
pub mod dod_statevec;
2020
// TODO: pub mod hadamard_ops;
21+
#[cfg(feature = "cuquantum")]
22+
pub mod cuquantum;
2123
#[cfg(feature = "gpu-sims")]
2224
pub mod gpu_influence_sampler;
2325
pub mod measurement_sampling;
26+
pub mod native_statevec_comparison;
2427
pub mod noise_models;
2528
#[cfg(feature = "cppsparsesim")]
2629
pub mod sparse_stab_vs_cpp;
@@ -34,24 +37,29 @@ mod modules {
3437
pub mod trig;
3538
}
3639

40+
#[cfg(feature = "cuquantum")]
41+
use modules::cuquantum;
3742
#[cfg(feature = "gpu-sims")]
3843
use modules::gpu_influence_sampler;
3944
#[cfg(feature = "cppsparsesim")]
4045
use modules::sparse_stab_vs_cpp;
4146
use modules::{
4247
allocation_overhead, cpu_stabilizer_comparison, dem_sampler, dod_statevec,
43-
measurement_sampling, noise_models, rng, set_ops, sparse_state_vec, stabilizer_sims,
44-
state_vec_sims, surface_code, trig,
48+
measurement_sampling, native_statevec_comparison, noise_models, rng, set_ops, sparse_state_vec,
49+
stabilizer_sims, state_vec_sims, surface_code, trig,
4550
};
4651

4752
fn all_benchmarks(c: &mut Criterion) {
4853
allocation_overhead::benchmarks(c);
4954
cpu_stabilizer_comparison::benchmarks(c);
55+
#[cfg(feature = "cuquantum")]
56+
cuquantum::benchmarks(c);
5057
dem_sampler::benchmarks(c);
5158
dod_statevec::benchmarks(c);
5259
#[cfg(feature = "gpu-sims")]
5360
gpu_influence_sampler::benchmarks(c);
5461
measurement_sampling::benchmarks(c);
62+
native_statevec_comparison::benchmarks(c);
5563
noise_models::benchmarks(c);
5664
rng::benchmarks(c);
5765
set_ops::benchmarks(c);

crates/pecos-cuquantum/benches/cuquantum_benchmark.rs renamed to crates/benchmarks/benches/modules/cuquantum.rs

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,29 @@
1-
//! Benchmarks for pecos-cuquantum GPU simulators
1+
// Copyright 2026 The PECOS Developers
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
4+
// in compliance with the License.You may obtain a copy of the License at
5+
//
6+
// https://www.apache.org/licenses/LICENSE-2.0
7+
//
8+
// Unless required by applicable law or agreed to in writing, software distributed under the License
9+
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
10+
// or implied. See the License for the specific language governing permissions and limitations under
11+
// the License.
12+
13+
//! Benchmarks for pecos-cuquantum GPU simulators.
214
//!
3-
//! These benchmarks compare cuQuantum GPU simulation performance against
4-
//! other backends (e.g., wgpu-based simulators).
15+
//! Benchmarks cuQuantum state vector and stabilizer simulation performance.
516
//!
6-
//! Run with: `cargo bench -p pecos-cuquantum --features integration-tests`
17+
//! Run with: `cargo bench -p benchmarks --features cuquantum`
718
//!
819
//! **Requires cuQuantum to be installed.**
920
10-
use criterion::{BenchmarkId, Criterion, Throughput, black_box, criterion_group, criterion_main};
21+
use criterion::{BenchmarkId, Criterion, Throughput};
1122
use pecos_core::Angle64;
1223
use pecos_cuquantum::{CuStabilizer, CuStateVec, QubitId, TryClone, is_cuquantum_available};
1324
use pecos_qsim::{ArbitraryRotationGateable, CliffordGateable, QuantumSimulator};
1425
use std::f64::consts::PI;
26+
use std::hint::black_box;
1527

1628
/// Benchmark state vector simulation for different qubit counts
1729
fn bench_statevec_gates(c: &mut Criterion) {
@@ -368,7 +380,7 @@ fn bench_sampling(c: &mut Criterion) {
368380
group.finish();
369381
}
370382

371-
/// Benchmark Clone and TryClone operations
383+
/// Benchmark Clone and `TryClone` operations
372384
fn bench_clone(c: &mut Criterion) {
373385
if !is_cuquantum_available() {
374386
eprintln!("Skipping clone benchmarks: cuQuantum not available");
@@ -424,15 +436,13 @@ fn bench_clone(c: &mut Criterion) {
424436
group.finish();
425437
}
426438

427-
criterion_group!(
428-
benches,
429-
bench_statevec_gates,
430-
bench_stabilizer_gates,
431-
bench_bell_state,
432-
bench_surface_code_syndrome,
433-
bench_rotation_gates,
434-
bench_two_qubit_rotation_gates,
435-
bench_sampling,
436-
bench_clone,
437-
);
438-
criterion_main!(benches);
439+
pub fn benchmarks(c: &mut Criterion) {
440+
bench_statevec_gates(c);
441+
bench_stabilizer_gates(c);
442+
bench_bell_state(c);
443+
bench_surface_code_syndrome(c);
444+
bench_rotation_gates(c);
445+
bench_two_qubit_rotation_gates(c);
446+
bench_sampling(c);
447+
bench_clone(c);
448+
}

0 commit comments

Comments
 (0)