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/more sims #120

Open
wants to merge 39 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
1865590
Initial Pauli prop code add
ciaranra Dec 10, 2024
c290c75
Merge branch 'development' into feat/rs-pauli-prop
ciaranra Dec 14, 2024
899330d
Merge branch 'development' into feat/rs-pauli-prop
ciaranra Dec 18, 2024
00a9064
Add Rust state vector
ciaranra Dec 18, 2024
bbaa88e
Making clippy happy
ciaranra Dec 18, 2024
e6c430a
Small tweaks
ciaranra Dec 18, 2024
7aaa226
Merge branch 'feat/rs-statevec' into feat/more-sims
ciaranra Dec 18, 2024
7f95894
Merge branch 'feat/rs-pauli-prop' into feat/more-sims
ciaranra Dec 18, 2024
ef6b257
More documentation for stab sim
ciaranra Dec 18, 2024
eec20ec
More docs
ciaranra Dec 18, 2024
0cade4c
qsim documenting + tweaks
ciaranra Dec 20, 2024
e39cf4c
Refactoring: CliffordGateable
ciaranra Dec 21, 2024
bda321b
Refactor state-vec
ciaranra Dec 21, 2024
1fc111d
Adding MeasurementResult struct
ciaranra Dec 21, 2024
f2e45d0
small tweaks
ciaranra Dec 21, 2024
c3dd2ad
Improved testing of RX, RY, RZ.
ciaranra Dec 21, 2024
27d60bc
test doc tweaks
ciaranra Dec 21, 2024
c727061
adding r1xy
ciaranra Dec 21, 2024
c989843
Adding initial Rust state-vec Python bindings
ciaranra Dec 21, 2024
4581a91
refactor sparse_sim.rs to sparse_stab_bindings.rs
ciaranra Dec 21, 2024
06144a1
Adding missing gates for Python wrapper of RS state vec
ciaranra Dec 22, 2024
722c21e
Refactor QuantumStateSimulator -> QuantumSimulator + more PauliProp docs
ciaranra Dec 22, 2024
03dac2c
Add iSWAP to CliffordGateable
ciaranra Dec 22, 2024
21af974
CliffordGateable cleanup
ciaranra Dec 22, 2024
67239da
Update docs. Introduce mp*()
ciaranra Dec 23, 2024
4d42b10
Updating documentation
ciaranra Jan 2, 2025
c943eed
Merge branch 'development' into feat/more-sims
ciaranra Jan 2, 2025
86848b0
Merge branch 'development' into feat/more-sims
ciaranra Jan 12, 2025
204baf2
Adding general Rng to state_vec
ciaranra Jan 12, 2025
dbf706d
Update state-vector docs
ciaranra Jan 12, 2025
3959be0
Unifying safety notification in state-vec docs
ciaranra Jan 12, 2025
fd044e7
Updated the test doc for state-vec
ciaranra Jan 12, 2025
ff415f2
Renaming rxxryyrzz gate base on actual gate application
ciaranra Jan 12, 2025
3116264
Updating state-vec docs
ciaranra Jan 12, 2025
5dd8496
Fix RXRYYRZZ -> RZZRYYRXX
ciaranra Jan 12, 2025
88ddbf7
more tests for state-vec + small doc improvement
ciaranra Jan 13, 2025
cb2055e
Reorganizing tests
ciaranra Jan 13, 2025
5abf95c
cleanup target and control arguments
ciaranra Jan 22, 2025
6b0a360
fixing license header typo
ciaranra Jan 24, 2025
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
13 changes: 13 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ pyo3 = "0.23"
rand = "0.8"
rand_chacha = "0.3"
rand_xoshiro = "0.6"
num-complex = "0.4"

pecos-core = { version = "0.1.1", path = "crates/pecos-core" }
pecos-qsim = { version = "0.1.1", path = "crates/pecos-qsim" }
Expand Down
2 changes: 2 additions & 0 deletions crates/pecos-python/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ crate-type = ["cdylib"]
[dependencies]
pyo3 = { workspace=true, features = ["extension-module"] }
pecos = { workspace = true }
num-complex = { workspace = true }
rand = { workspace = true }

[lints]
workspace = true
8 changes: 6 additions & 2 deletions crates/pecos-python/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,17 @@
// or implied. See the License for the specific language governing permissions and limitations under
// the License.

mod sparse_sim;
use sparse_sim::SparseSim;
mod sparse_stab_bindings;
mod state_vec_bindings;

use sparse_stab_bindings::SparseSim;
use state_vec_bindings::RsStateVec;

use pyo3::prelude::*;

#[pymodule]
fn _pecos_rslib(_py: Python<'_>, m: &Bound<'_, PyModule>) -> PyResult<()> {
m.add_class::<SparseSim>()?;
m.add_class::<RsStateVec>()?;
Ok(())
}
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,48 @@ impl SparseSim {
self.inner.szdg(location);
Ok(None)
}
"MZ" | "MX" | "MY" | "MZForced" | "PZ" | "PX" | "PY" | "PZForced" | "PnZ" | "PnX"
| "PnY" => {
let (result, _) = match symbol {
"PZ" => {
self.inner.pz(location);
Ok(None)
}
"PX" => {
self.inner.px(location);
Ok(None)
}
"PY" => {
self.inner.py(location);
Ok(None)
}
"PnZ" => {
self.inner.pnz(location);
Ok(None)
}
"PnX" => {
self.inner.pnx(location);
Ok(None)
}
"PnY" => {
self.inner.pny(location);
Ok(None)
}
"PZForced" => {
let forced_value = params
.ok_or_else(|| {
PyErr::new::<pyo3::exceptions::PyValueError, _>("PZForced requires params")
})?
.get_item("forced_outcome")?
.ok_or_else(|| {
PyErr::new::<pyo3::exceptions::PyValueError, _>(
"PZForced requires a 'forced_outcome' parameter",
)
})?
.call_method0("__bool__")?
.extract::<bool>()?;
self.inner.pz_forced(location, forced_value);
Ok(None)
}
"MZ" | "MX" | "MY" | "MZForced" => {
let result = match symbol {
"MZ" => self.inner.mz(location),
"MX" => self.inner.mx(location),
"MY" => self.inner.my(location),
Expand All @@ -156,32 +195,9 @@ impl SparseSim {
.extract::<bool>()?;
self.inner.mz_forced(location, forced_value)
}
"PZ" => self.inner.pz(location),
"PX" => self.inner.px(location),
"PY" => self.inner.py(location),
"PZForced" => {
let forced_value = params
.ok_or_else(|| {
PyErr::new::<pyo3::exceptions::PyValueError, _>(
"PZForced requires params",
)
})?
.get_item("forced_outcome")?
.ok_or_else(|| {
PyErr::new::<pyo3::exceptions::PyValueError, _>(
"PZForced requires a 'forced_outcome' parameter",
)
})?
.call_method0("__bool__")?
.extract::<bool>()?;
self.inner.pz_forced(location, forced_value)
}
"PnZ" => self.inner.pnz(location),
"PnX" => self.inner.pnx(location),
"PnY" => self.inner.pny(location),
_ => unreachable!(),
};
Ok(Some(u8::from(result)))
Ok(Some(u8::from(result.outcome)))
}
_ => Err(PyErr::new::<pyo3::exceptions::PyValueError, _>(
"Unsupported single-qubit gate",
Expand Down Expand Up @@ -247,7 +263,7 @@ impl SparseSim {
Ok(None)
}
"G2" => {
self.inner.g2(q1, q2);
self.inner.g(q1, q2);
Ok(None)
}
_ => Err(PyErr::new::<pyo3::exceptions::PyValueError, _>(
Expand Down
Loading
Loading