What
Expose the existing Rust Preprocessor (qdp-core/src/preprocessing.rs) to Python via PyO3, so Python users can call its validation and L2-norm helpers directly instead of reimplementing them.
Why
Preprocessor already exists and is tested in Rust, but it is invisible from Python — qumat_qdp users currently have no supported way to validate or compute norms on input before handing it to the encoder, so they either skip validation or duplicate the logic in Python. Binding the existing API closes that gap with no new core logic.
How
- Add a PyO3 wrapper (in the
qdp-python crate) exposing Preprocessor and its four current methods:
validate_input(host_data: &[f64], num_qubits: usize) -> Result<()>
calculate_l2_norm(host_data: &[f64]) -> Result<f64>
validate_batch(...)
calculate_batch_l2_norms(...) -> Result<Vec<f64>>
- Bind
f64 — the current Rust API is f64-only. Leave any f32 variant as a follow-up rather than widening the core here.
- Map Rust validation errors to Python exceptions (e.g.
ValueError) preserving the original message, so a failed validate_input raises cleanly in Python.
- Keep method names and signatures aligned with the Rust API to minimize surprise; defer public re-export and docs to C2.
Note: Preprocessor currently has no normalize/standardize method (its struct doc mentions "normalization" aspirationally, but only the four methods above exist). This issue binds what exists; do not invent normalize/standardize here.
Out of scope: Public-API export from __init__.py and docstrings (C2), f32 variants, any change to the preprocessing algorithms, adding new normalize/standardize methods.
What
Expose the existing Rust
Preprocessor(qdp-core/src/preprocessing.rs) to Python via PyO3, so Python users can call its validation and L2-norm helpers directly instead of reimplementing them.Why
Preprocessoralready exists and is tested in Rust, but it is invisible from Python —qumat_qdpusers currently have no supported way to validate or compute norms on input before handing it to the encoder, so they either skip validation or duplicate the logic in Python. Binding the existing API closes that gap with no new core logic.How
qdp-pythoncrate) exposingPreprocessorand its four current methods:validate_input(host_data: &[f64], num_qubits: usize) -> Result<()>calculate_l2_norm(host_data: &[f64]) -> Result<f64>validate_batch(...)calculate_batch_l2_norms(...) -> Result<Vec<f64>>f64— the current Rust API isf64-only. Leave anyf32variant as a follow-up rather than widening the core here.ValueError) preserving the original message, so a failedvalidate_inputraises cleanly in Python.Note:
Preprocessorcurrently has nonormalize/standardizemethod (its struct doc mentions "normalization" aspirationally, but only the four methods above exist). This issue binds what exists; do not invent normalize/standardize here.Out of scope: Public-API export from
__init__.pyand docstrings (C2),f32variants, any change to the preprocessing algorithms, adding new normalize/standardize methods.