This is an automated email from the ASF dual-hosted git repository.
richhuang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/mahout.git
The following commit(s) were added to refs/heads/main by this push:
new 2dc9a02fa Added the run_throughput_pipeline_py PyO3 binding function
so make test_python passes (#1098)
2dc9a02fa is described below
commit 2dc9a02faf87b1d431147e890bc59a3fcfd5cf38
Author: Ryan Huang <[email protected]>
AuthorDate: Sun Mar 1 19:55:13 2026 +0800
Added the run_throughput_pipeline_py PyO3 binding function so make
test_python passes (#1098)
---
qdp/qdp-python/src/lib.rs | 36 ++++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/qdp/qdp-python/src/lib.rs b/qdp/qdp-python/src/lib.rs
index 34facaedb..758ff2833 100644
--- a/qdp/qdp-python/src/lib.rs
+++ b/qdp/qdp-python/src/lib.rs
@@ -21,12 +21,46 @@ mod pytorch;
mod tensor;
use engine::QdpEngine;
+use pyo3::exceptions::PyRuntimeError;
use pyo3::prelude::*;
use tensor::QuantumTensor;
#[cfg(target_os = "linux")]
use loader::PyQuantumLoader;
+#[cfg(target_os = "linux")]
+#[pyfunction]
+#[pyo3(signature = (device_id, num_qubits, batch_size, total_batches,
encoding_method, warmup_batches=0, seed=None))]
+#[allow(clippy::too_many_arguments)]
+fn run_throughput_pipeline_py(
+ py: Python<'_>,
+ device_id: usize,
+ num_qubits: u32,
+ batch_size: usize,
+ total_batches: usize,
+ encoding_method: String,
+ warmup_batches: usize,
+ seed: Option<u64>,
+) -> PyResult<(f64, f64, f64)> {
+ let config = qdp_core::PipelineConfig {
+ device_id,
+ num_qubits,
+ batch_size,
+ total_batches,
+ encoding_method,
+ seed,
+ warmup_batches,
+ };
+ let result = py
+ .detach(|| qdp_core::run_throughput_pipeline(&config))
+ .map_err(|e| PyRuntimeError::new_err(format!("Pipeline failed:
{e}")))?;
+ Ok((
+ result.duration_sec,
+ result.vectors_per_sec,
+ result.latency_ms_per_vector,
+ ))
+}
+
/// Quantum Data Plane (QDP) Python module
///
/// GPU-accelerated quantum data encoding with DLPack integration.
@@ -39,5 +73,7 @@ fn _qdp(m: &Bound<'_, PyModule>) -> PyResult<()> {
m.add_class::<QuantumTensor>()?;
#[cfg(target_os = "linux")]
m.add_class::<PyQuantumLoader>()?;
+ #[cfg(target_os = "linux")]
+ m.add_function(wrap_pyfunction!(run_throughput_pipeline_py, m)?)?;
Ok(())
}