Skip to content

Commit eb271d4

Browse files
authored
Feat/rsqulacs (#186)
* Replacing ProjectQ and BasicSV with Rusty PECOS's StateVec * Replacing Python implementation of CoinToss with Rust implementation * expand PauliProp functionality * add pecos-rslib/PyO3 wrappimgs * Export Rust PauliProp. Convert PauliFaultProp to PauliProp and replace implementation with mostly Rust * Replace Qulacs implementation with the Rust based one
1 parent 2322fd3 commit eb271d4

File tree

33 files changed

+5077
-1707
lines changed

33 files changed

+5077
-1707
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,12 @@ ndarray = "0.16"
8585
anyhow = "1"
8686
cxx = "1"
8787
cxx-build = "1"
88-
reqwest = { version = "0.12", default-features = false, features = ["blocking", "native-tls"] }
88+
reqwest = { version = "0.12", default-features = false, features = ["blocking", "rustls-tls"] }
8989
tar = "0.4"
9090
flate2 = "1"
91+
bzip2 = "0.4"
9192
sha2 = "0.10"
9293
dirs = "6"
93-
petgraph = "0.6"
9494

9595
pecos-core = { version = "0.1.1", path = "crates/pecos-core" }
9696
pecos-qsim = { version = "0.1.1", path = "crates/pecos-qsim" }

crates/pecos-build-utils/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ sha2.workspace = true
1414
dirs.workspace = true
1515
tar.workspace = true
1616
flate2.workspace = true
17+
bzip2.workspace = true

crates/pecos-build-utils/src/dependencies.rs

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,21 @@ pub const CHROMOBIUS_COMMIT: &str = "35e289570fdc1d71e73582e1fd4e0c8e29298ef5";
3131
pub const CHROMOBIUS_SHA256: &str =
3232
"da73d819e67572065fd715db45fabb342c2a2a1e961d2609df4f9864b9836054";
3333

34+
/// Qulacs library constants
35+
/// Used by Qulacs quantum simulator
36+
pub const QULACS_VERSION: &str = "0.6.12";
37+
pub const QULACS_SHA256: &str = "b9e5422e0bb2b07725b0c62f7827326b5a1486facb30cf68d12b4ef119c485e9";
38+
39+
/// Eigen library constants
40+
/// Used by Qulacs quantum simulator
41+
pub const EIGEN_VERSION: &str = "3.4.0";
42+
pub const EIGEN_SHA256: &str = "8586084f71f9bde545ee7fa6d00288b264a2b7ac3607b974e54d13e7162c1c72";
43+
44+
/// Boost library constants
45+
/// Used by Qulacs quantum simulator (for property_tree and dynamic_bitset)
46+
pub const BOOST_VERSION: &str = "1.83.0";
47+
pub const BOOST_SHA256: &str = "6478edfe2f3305127cffe8caf73ea0176c53769f4bf1585be237eb30798c3b8e";
48+
3449
/// Helper functions to create DownloadInfo structs for each dependency
3550
use crate::DownloadInfo;
3651

@@ -82,3 +97,37 @@ pub fn chromobius_download_info() -> DownloadInfo {
8297
name: format!("chromobius-{}", &CHROMOBIUS_COMMIT[..8]),
8398
}
8499
}
100+
101+
/// Create DownloadInfo for Qulacs
102+
pub fn qulacs_download_info() -> DownloadInfo {
103+
DownloadInfo {
104+
url: format!("https://github.com/qulacs/qulacs/archive/v{QULACS_VERSION}.tar.gz"),
105+
sha256: QULACS_SHA256,
106+
name: format!("qulacs-{}", QULACS_VERSION),
107+
}
108+
}
109+
110+
/// Create DownloadInfo for Eigen
111+
pub fn eigen_download_info() -> DownloadInfo {
112+
DownloadInfo {
113+
url: format!(
114+
"https://gitlab.com/libeigen/eigen/-/archive/{}/eigen-{}.tar.gz",
115+
EIGEN_VERSION, EIGEN_VERSION
116+
),
117+
sha256: EIGEN_SHA256,
118+
name: format!("eigen-{}", EIGEN_VERSION),
119+
}
120+
}
121+
122+
/// Create DownloadInfo for Boost
123+
pub fn boost_download_info() -> DownloadInfo {
124+
let version_underscore = BOOST_VERSION.replace('.', "_");
125+
DownloadInfo {
126+
url: format!(
127+
"https://archives.boost.io/release/{}/source/boost_{}.tar.bz2",
128+
BOOST_VERSION, version_underscore
129+
),
130+
sha256: BOOST_SHA256,
131+
name: format!("boost-{}", BOOST_VERSION),
132+
}
133+
}

crates/pecos-build-utils/src/extract.rs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,30 @@ use crate::errors::{BuildError, Result};
44
use std::fs;
55
use std::path::{Path, PathBuf};
66

7-
/// Extract a tar.gz archive and emit rerun-if-changed for all extracted files
7+
/// Extract a tar.gz or tar.bz2 archive and emit rerun-if-changed for all extracted files
88
pub fn extract_archive(
99
data: &[u8],
1010
out_dir: &Path,
1111
expected_dir_name: Option<&str>,
1212
) -> Result<PathBuf> {
13-
use flate2::read::GzDecoder;
1413
use tar::Archive;
1514

16-
let tar = GzDecoder::new(data);
17-
let mut archive = Archive::new(tar);
15+
// Try to detect if this is gzip or bzip2 by checking magic bytes
16+
let mut archive = if data.len() >= 3 && data[0] == 0x1f && data[1] == 0x8b && data[2] == 0x08 {
17+
// gzip magic bytes
18+
use flate2::read::GzDecoder;
19+
let tar = GzDecoder::new(data);
20+
Archive::new(Box::new(tar) as Box<dyn std::io::Read>)
21+
} else if data.len() >= 3 && &data[0..3] == b"BZh" {
22+
// bzip2 magic bytes
23+
use bzip2::read::BzDecoder;
24+
let tar = BzDecoder::new(data);
25+
Archive::new(Box::new(tar) as Box<dyn std::io::Read>)
26+
} else {
27+
return Err(BuildError::Archive(
28+
"Unknown archive format - not gzip or bzip2".to_string(),
29+
));
30+
};
1831

1932
// Extract to temporary directory first
2033
let temp_dir = out_dir.join(format!("extract_temp_{}", std::process::id()));

crates/pecos-cppsparsesim/Cargo.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,7 @@ readme = "README.md"
1313

1414
[dependencies]
1515
cxx.workspace = true
16-
pecos-core.workspace = true
1716
pecos-qsim.workspace = true
18-
rand.workspace = true
19-
rand_chacha.workspace = true
2017

2118
[build-dependencies]
2219
cxx-build.workspace = true

crates/pecos-decoders/Cargo.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@ default = []
2020
ldpc = ["dep:pecos-ldpc-decoders"]
2121
all = ["ldpc"]
2222

23-
[dev-dependencies]
24-
ndarray.workspace = true
25-
2623
[lib]
2724
name = "pecos_decoders"
2825

crates/pecos-ldpc-decoders/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ cxx.workspace = true
2020
[build-dependencies]
2121
pecos-build-utils.workspace = true
2222
cxx-build.workspace = true
23-
cc.workspace = true
2423

2524
[dev-dependencies]
2625
rand.workspace = true

crates/pecos-qulacs/Cargo.toml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
[package]
2+
name = "pecos-qulacs"
3+
version.workspace = true
4+
edition.workspace = true
5+
authors.workspace = true
6+
homepage.workspace = true
7+
repository.workspace = true
8+
license.workspace = true
9+
keywords.workspace = true
10+
categories.workspace = true
11+
description = "Qulacs quantum simulator bindings for PECOS"
12+
readme.workspace = true
13+
14+
[dependencies]
15+
pecos-core.workspace = true
16+
pecos-qsim.workspace = true
17+
num-complex.workspace = true
18+
rand.workspace = true
19+
rand_chacha.workspace = true
20+
cxx.workspace = true
21+
22+
23+
[dev-dependencies]
24+
rand.workspace = true
25+
26+
[build-dependencies]
27+
cxx-build.workspace = true
28+
pecos-build-utils.workspace = true
29+
cc = "1.0"
30+
31+
[lib]
32+
name = "pecos_qulacs"
33+
34+
[lints]
35+
workspace = true

0 commit comments

Comments
 (0)