1515// limitations under the License.
1616
1717use crate :: error:: { MahoutError , Result } ;
18+ use crate :: gpu:: encodings:: validate_qubit_count;
1819use rayon:: prelude:: * ;
1920
2021/// Shared CPU-based pre-processing pipeline for quantum encoding.
@@ -27,22 +28,12 @@ impl Preprocessor {
2728 /// Validates standard quantum input constraints.
2829 ///
2930 /// Checks:
30- /// - Qubit count within practical limits (1-30 )
31+ /// - Qubit count within practical limits (1-MAX_QUBITS )
3132 /// - Data availability
3233 /// - Data length against state vector size
3334 pub fn validate_input ( host_data : & [ f64 ] , num_qubits : usize ) -> Result < ( ) > {
34- // Validate qubits (max 30 = 16GB GPU memory)
35- if num_qubits == 0 {
36- return Err ( MahoutError :: InvalidInput (
37- "Number of qubits must be at least 1" . to_string ( ) ,
38- ) ) ;
39- }
40- if num_qubits > 30 {
41- return Err ( MahoutError :: InvalidInput ( format ! (
42- "Number of qubits {} exceeds practical limit of 30" ,
43- num_qubits
44- ) ) ) ;
45- }
35+ // Validate qubits using shared validation function (max MAX_QUBITS = 16GB GPU memory)
36+ validate_qubit_count ( num_qubits) ?;
4637
4738 // Validate input data
4839 if host_data. is_empty ( ) {
@@ -116,12 +107,8 @@ impl Preprocessor {
116107 ) ) ) ;
117108 }
118109
119- if num_qubits == 0 || num_qubits > 30 {
120- return Err ( MahoutError :: InvalidInput ( format ! (
121- "Number of qubits {} must be between 1 and 30" ,
122- num_qubits
123- ) ) ) ;
124- }
110+ // Validate qubits using shared validation function
111+ validate_qubit_count ( num_qubits) ?;
125112
126113 let state_len = 1 << num_qubits;
127114 if sample_size > state_len {
0 commit comments