Skip to content

Commit be89b98

Browse files
committed
Merge branch 'feat/hyrbid-engine-rs' into rng-refactor
2 parents 451adda + bc6da1b commit be89b98

File tree

16 files changed

+83
-72
lines changed

16 files changed

+83
-72
lines changed

.github/workflows/python-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: Python Artifacts
22

33
env:
4-
TRIGGER_ON_PR_PUSH: false # Set to true to enable triggers on PR pushes
4+
TRIGGER_ON_PR_PUSH: true # Set to true to enable triggers on PR pushes
55
PYTHON_VERSION: '3.10'
66

77
on:

.github/workflows/python-test.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
name: Python test / linting
2+
3+
env:
4+
TRIGGER_ON_PR_PUSH: true # Set to true to enable triggers on PR pushes
5+
RUSTFLAGS: -C debuginfo=0
6+
RUST_BACKTRACE: 1
7+
PYTHONUTF8: 1
8+
29
on:
310
push:
411
branches: [ "master", "development" ]
@@ -21,11 +28,6 @@ concurrency:
2128
group: ${{ github.workflow }}-${{ github.ref }}
2229
cancel-in-progress: true
2330

24-
env:
25-
RUSTFLAGS: -C debuginfo=0
26-
RUST_BACKTRACE: 1
27-
PYTHONUTF8: 1
28-
2931
defaults:
3032
run:
3133
shell: bash

.github/workflows/rust-test.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
name: Rust test / linting
22

33
env:
4-
TRIGGER_ON_PR_PUSH: false # Set to true to enable triggers on PR pushes
5-
4+
TRIGGER_ON_PR_PUSH: true # Set to true to enable triggers on PR pushes
65
RUSTFLAGS: -C debuginfo=0
76
RUST_BACKTRACE: 1
87

Cargo.lock

Lines changed: 26 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ categories = ["science", "simulation"]
2424
rand = "0.9"
2525
rand_chacha = "0.9"
2626
pyo3 = { version = "0.24", features = ["extension-module"] }
27+
pyo3-build-config = { version = "0.24", features = ["resolve-config"] }
2728
rayon = "1"
2829
clap = { version = "4", features = ["derive"] }
2930
log = "0.4"

Makefile

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,7 @@ lint: fmt clippy
7474

7575
.PHONY: rstest
7676
rstest: ## Run Rust tests
77-
ifeq ($(OS),Windows_NT)
78-
cargo test --workspace --exclude pecos-rslib --doc false
79-
else
80-
cargo test
81-
endif
77+
cargo test --workspace
8278

8379
.PHONY: pytest
8480
pytest: ## Run tests on the Python package (not including optional dependencies). ASSUMES: previous build command

build.sh

Lines changed: 0 additions & 4 deletions
This file was deleted.

crates/pecos-engines/src/engines/noise/general.rs

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -902,31 +902,33 @@ impl GeneralNoiseModel {
902902
for &qubit in &gate.qubits {
903903
if has_leakage {
904904
add_original_gate = false;
905+
}
905906

906-
// If qubit has leaked and spontaneous emission has occurred... seep the qubit
907-
if self.rng.occurs(self.p1_emission_ratio) {
908-
if let Some(gates) = self.seep(qubit) {
909-
noise.extend(gates);
910-
}
911-
}
912-
} else if self.rng.occurs(self.p1) {
907+
if self.rng.occurs(self.p1) {
913908
// Spontaneous emission
914909
if self.rng.occurs(self.p1_emission_ratio) {
915-
add_original_gate = false;
910+
// If qubit has leaked and spontaneous emission has occurred... seep the qubit
911+
if has_leakage {
912+
if let Some(gates) = self.seep(qubit) {
913+
noise.extend(gates);
914+
}
915+
} else {
916+
add_original_gate = false;
916917

917918
let result = self.p1_emission_model.sample_gates(&mut self.rng, qubit);
918919

919-
if result.has_leakage() {
920-
// Handle leakage
921-
if let Some(gate) = self.leak(qubit) {
920+
if result.has_leakage() {
921+
// Handle leakage
922+
if let Some(gate) = self.leak(qubit) {
923+
noise.push(gate);
924+
}
925+
} else if let Some(gate) = result.gate {
926+
// Handle Pauli gate
922927
noise.push(gate);
928+
trace!("Applied Pauli error to qubit {}", qubit);
923929
}
924-
} else if let Some(gate) = result.gate {
925-
// Handle Pauli gate
926-
noise.push(gate);
927-
trace!("Applied Pauli error to qubit {}", qubit);
928930
}
929-
} else {
931+
} else if !has_leakage {
930932
// Pauli noise
931933
let result = self.p1_pauli_model.sample_gates(&mut self.rng, qubit);
932934
if let Some(gate) = result.gate {

crates/pecos/src/prelude.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,12 @@ pub use pecos_engines::{
2323
// Re-exporting specific implementations that aren't at the crate root
2424
pub use pecos_engines::engines::{
2525
classical::{ProgramType, detect_program_type, get_program_path, setup_engine},
26-
quantum::{StateVecEngine, new_quantum_engine_arbitrary_qgate},
26+
quantum::{SparseStabEngine, StateVecEngine, new_quantum_engine_arbitrary_qgate},
2727
};
2828

29+
// Re-exporting byte_message functions
30+
pub use pecos_engines::byte_message::dump_batch;
31+
2932
// re-exporting pecos-qsim
3033
pub use pecos_qsim::{
3134
ArbitraryRotationGateable, CliffordGateable, QuantumSimulator, SparseStab, StateVec,

python/pecos-rslib/rust/Cargo.toml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,19 @@ publish = false
1515
[lib]
1616
name = "pecos_rslib"
1717
crate-type = ["cdylib", "rlib"]
18+
# Skip doc tests as they won't work properly in this setup
19+
doctest = false
20+
# Skip unit tests as well - all testing should be done through Python
21+
test = false
1822

1923
[dependencies]
20-
pyo3 = { workspace=true, features = ["extension-module", "abi3-py37"] }
24+
pyo3 = { workspace=true, features = ["extension-module", "abi3-py310", "generate-import-lib"] }
2125
pecos = { workspace = true }
22-
pecos-engines = { workspace = true }
26+
# Removing pecos-engines dependency, using pecos prelude instead
2327
parking_lot = { workspace = true}
2428

2529
[lints]
2630
workspace = true
31+
32+
[build-dependencies]
33+
pyo3-build-config = { workspace = true }

0 commit comments

Comments
 (0)