1use serde::{Deserialize, Serialize};
4use std::collections::HashMap;
5use std::time::Duration;
6
7use super::types::{BaselineMetric, QuantumPlatform};
8
9#[derive(Debug, Clone, Serialize, Deserialize)]
11pub struct UnifiedBenchmarkConfig {
12 pub target_platforms: Vec<QuantumPlatform>,
14 pub benchmark_suite: BenchmarkSuiteConfig,
16 pub scirs2_config: SciRS2AnalysisConfig,
18 pub reporting_config: ReportingConfig,
20 pub optimization_config: ResourceOptimizationConfig,
22 pub tracking_config: HistoricalTrackingConfig,
24 pub custom_benchmarks: Vec<CustomBenchmarkDefinition>,
26 pub performance_targets: PerformanceTargets,
28}
29
30#[derive(Debug, Clone, Serialize, Deserialize)]
32pub struct BenchmarkSuiteConfig {
33 pub gate_benchmarks: GateBenchmarkConfig,
35 pub circuit_benchmarks: CircuitBenchmarkConfig,
37 pub algorithm_benchmarks: AlgorithmBenchmarkConfig,
39 pub system_benchmarks: SystemBenchmarkConfig,
41 pub execution_params: BenchmarkExecutionParams,
43}
44
45#[derive(Debug, Clone, Serialize, Deserialize)]
47pub struct GateBenchmarkConfig {
48 pub single_qubit_gates: Vec<SingleQubitGate>,
50 pub two_qubit_gates: Vec<TwoQubitGate>,
52 pub multi_qubit_gates: Vec<MultiQubitGate>,
54 pub repetitions_per_gate: usize,
56 pub enable_random_sequences: bool,
58 pub fidelity_methods: Vec<FidelityMeasurementMethod>,
60}
61
62#[derive(Debug, Clone, Serialize, Deserialize)]
64pub struct CircuitBenchmarkConfig {
65 pub depth_range: (usize, usize),
67 pub width_range: (usize, usize),
69 pub circuit_types: Vec<CircuitType>,
71 pub random_circuits_per_config: usize,
73 pub parametric_configs: Vec<ParametricCircuitConfig>,
75}
76
77#[derive(Debug, Clone, Serialize, Deserialize)]
79pub struct AlgorithmBenchmarkConfig {
80 pub algorithms: Vec<QuantumAlgorithm>,
82 pub problem_sizes: HashMap<String, Vec<usize>>,
84 pub algorithm_params: HashMap<String, AlgorithmParams>,
86 pub enable_nisq_optimizations: bool,
88}
89
90#[derive(Debug, Clone, Serialize, Deserialize, Default)]
92pub struct SystemBenchmarkConfig {
93 pub enable_cross_platform: bool,
95 pub enable_resource_benchmarks: bool,
97 pub enable_cost_benchmarks: bool,
99 pub enable_scalability_benchmarks: bool,
101 pub enable_reliability_benchmarks: bool,
103}
104
105#[derive(Debug, Clone, Serialize, Deserialize)]
107pub struct SciRS2AnalysisConfig {
108 pub statistical_analysis: StatisticalAnalysisConfig,
110 pub ml_analysis: MLAnalysisConfig,
112 pub optimization_analysis: OptimizationAnalysisConfig,
114 pub graph_analysis: GraphAnalysisConfig,
116}
117
118#[derive(Debug, Clone, Serialize, Deserialize)]
120pub struct StatisticalAnalysisConfig {
121 pub confidence_level: f64,
123 pub enable_bayesian: bool,
125 pub enable_nonparametric: bool,
127 pub enable_multivariate: bool,
129 pub bootstrap_samples: usize,
131 pub hypothesis_testing: HypothesisTestingConfig,
133}
134
135#[derive(Debug, Clone, Serialize, Deserialize)]
137pub struct MLAnalysisConfig {
138 pub enable_prediction: bool,
140 pub enable_clustering: bool,
142 pub enable_anomaly_detection: bool,
144 pub model_types: Vec<MLModelType>,
146 pub feature_engineering: FeatureEngineeringConfig,
148}
149
150#[derive(Debug, Clone, Serialize, Deserialize)]
152pub struct OptimizationAnalysisConfig {
153 pub enable_optimization: bool,
155 pub objectives: Vec<OptimizationObjective>,
157 pub algorithms: Vec<OptimizationAlgorithm>,
159 pub enable_multi_objective: bool,
161}
162
163#[derive(Debug, Clone, Serialize, Deserialize)]
165pub struct GraphAnalysisConfig {
166 pub enable_connectivity: bool,
168 pub enable_topology_optimization: bool,
170 pub enable_community_detection: bool,
172 pub metrics: Vec<GraphMetric>,
174}
175
176#[derive(Debug, Clone, Serialize, Deserialize)]
178pub struct ReportingConfig {
179 pub formats: Vec<ReportFormat>,
181 pub visualizations: Vec<VisualizationType>,
183 pub export_destinations: Vec<ExportDestination>,
185 pub dashboard_config: DashboardConfig,
187 pub automated_reports: AutomatedReportConfig,
189}
190
191#[derive(Debug, Clone, Serialize, Deserialize)]
193pub struct ResourceOptimizationConfig {
194 pub enable_intelligent_allocation: bool,
196 pub cost_optimization: CostOptimizationConfig,
198 pub performance_optimization: PerformanceOptimizationConfig,
200 pub load_balancing: LoadBalancingConfig,
202 pub scheduling_optimization: SchedulingOptimizationConfig,
204}
205
206#[derive(Debug, Clone, Serialize, Deserialize)]
208pub struct HistoricalTrackingConfig {
209 pub enable_tracking: bool,
211 pub retention_period_days: u32,
213 pub trend_analysis: TrendAnalysisConfig,
215 pub baseline_tracking: BaselineTrackingConfig,
217 pub comparative_analysis: ComparativeAnalysisConfig,
219}
220
221#[derive(Debug, Clone, Serialize, Deserialize)]
224pub enum SingleQubitGate {
225 X,
226 Y,
227 Z,
228 H,
229 S,
230 T,
231 SqrtX,
232 RX(f64),
233 RY(f64),
234 RZ(f64),
235}
236
237impl PartialEq for SingleQubitGate {
239 fn eq(&self, other: &Self) -> bool {
240 match (self, other) {
241 (Self::X, Self::X) => true,
242 (Self::Y, Self::Y) => true,
243 (Self::Z, Self::Z) => true,
244 (Self::H, Self::H) => true,
245 (Self::S, Self::S) => true,
246 (Self::T, Self::T) => true,
247 (Self::SqrtX, Self::SqrtX) => true,
248 (Self::RX(a), Self::RX(b)) => (a - b).abs() < 1e-10,
249 (Self::RY(a), Self::RY(b)) => (a - b).abs() < 1e-10,
250 (Self::RZ(a), Self::RZ(b)) => (a - b).abs() < 1e-10,
251 _ => false,
252 }
253 }
254}
255
256impl Eq for SingleQubitGate {}
257
258impl std::hash::Hash for SingleQubitGate {
259 fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
260 match self {
261 Self::X => 0u8.hash(state),
262 Self::Y => 1u8.hash(state),
263 Self::Z => 2u8.hash(state),
264 Self::H => 3u8.hash(state),
265 Self::S => 4u8.hash(state),
266 Self::T => 5u8.hash(state),
267 Self::SqrtX => 6u8.hash(state),
268 Self::RX(f) => {
269 7u8.hash(state);
270 (*f as u64).hash(state);
271 }
272 Self::RY(f) => {
273 8u8.hash(state);
274 (*f as u64).hash(state);
275 }
276 Self::RZ(f) => {
277 9u8.hash(state);
278 (*f as u64).hash(state);
279 }
280 }
281 }
282}
283
284#[derive(Debug, Clone, Serialize, Deserialize)]
285pub enum TwoQubitGate {
286 CNOT,
287 CZ,
288 SWAP,
289 ISwap,
290 CRX(f64),
291 CRY(f64),
292 CRZ(f64),
293}
294
295impl PartialEq for TwoQubitGate {
297 fn eq(&self, other: &Self) -> bool {
298 match (self, other) {
299 (Self::CNOT, Self::CNOT) => true,
300 (Self::CZ, Self::CZ) => true,
301 (Self::SWAP, Self::SWAP) => true,
302 (Self::ISwap, Self::ISwap) => true,
303 (Self::CRX(a), Self::CRX(b)) => (a - b).abs() < 1e-10,
304 (Self::CRY(a), Self::CRY(b)) => (a - b).abs() < 1e-10,
305 (Self::CRZ(a), Self::CRZ(b)) => (a - b).abs() < 1e-10,
306 _ => false,
307 }
308 }
309}
310
311impl Eq for TwoQubitGate {}
312
313impl std::hash::Hash for TwoQubitGate {
314 fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
315 match self {
316 Self::CNOT => 0u8.hash(state),
317 Self::CZ => 1u8.hash(state),
318 Self::SWAP => 2u8.hash(state),
319 Self::ISwap => 3u8.hash(state),
320 Self::CRX(f) => {
321 4u8.hash(state);
322 (*f as u64).hash(state); }
324 Self::CRY(f) => {
325 5u8.hash(state);
326 (*f as u64).hash(state);
327 }
328 Self::CRZ(f) => {
329 6u8.hash(state);
330 (*f as u64).hash(state);
331 }
332 }
333 }
334}
335
336#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
337pub enum MultiQubitGate {
338 Toffoli,
339 Fredkin,
340 CCZ,
341 Controlled(Box<SingleQubitGate>, usize),
342}
343
344#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
345pub enum FidelityMeasurementMethod {
346 ProcessTomography,
347 RandomizedBenchmarking,
348 SimultaneousRandomizedBenchmarking,
349 CycleBenchmarking,
350 GateSetTomography,
351}
352
353#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
354pub enum CircuitType {
355 Random,
356 QFT,
357 Grover,
358 Supremacy,
359 QAOA,
360 VQE,
361 Arithmetic,
362 ErrorCorrection,
363 Custom(String),
364}
365
366#[derive(Debug, Clone, Serialize, Deserialize)]
367pub struct ParametricCircuitConfig {
368 pub circuit_type: CircuitType,
369 pub parameter_ranges: HashMap<String, (f64, f64)>,
370 pub parameter_steps: HashMap<String, usize>,
371}
372
373#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
374pub enum QuantumAlgorithm {
375 Shor { bit_length: usize },
376 Grover { database_size: usize },
377 QFT { num_qubits: usize },
378 VQE { molecule: String },
379 QAOA { graph_size: usize },
380 QuantumWalk { graph_type: String },
381 HHL { matrix_size: usize },
382 QuantumCounting { target_states: usize },
383}
384
385#[derive(Debug, Clone, Serialize, Deserialize)]
386pub struct AlgorithmParams {
387 pub parameters: HashMap<String, f64>,
388 pub options: HashMap<String, String>,
389}
390
391#[derive(Debug, Clone, Serialize, Deserialize)]
392pub struct BenchmarkExecutionParams {
393 pub shots: usize,
395 pub max_execution_time: Duration,
397 pub repetitions: usize,
399 pub parallelism: ParallelismConfig,
401 pub error_handling: ErrorHandlingConfig,
403}
404
405#[derive(Debug, Clone, Serialize, Deserialize)]
406pub struct ParallelismConfig {
407 pub enable_parallel: bool,
409 pub max_concurrent: usize,
411 pub batch_size: usize,
413}
414
415#[derive(Debug, Clone, Serialize, Deserialize)]
416pub struct ErrorHandlingConfig {
417 pub retry_config: RetryConfig,
419 pub timeout_handling: TimeoutHandling,
421 pub recovery_strategies: Vec<ErrorRecoveryStrategy>,
423}
424
425#[derive(Debug, Clone, Serialize, Deserialize)]
426pub struct RetryConfig {
427 pub max_retries: usize,
428 pub retry_delay: Duration,
429 pub exponential_backoff: bool,
430}
431
432#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
433pub enum TimeoutHandling {
434 AbortOnTimeout,
435 ContinueWithPartialResults,
436 ExtendTimeoutOnce,
437}
438
439#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
440pub enum ErrorRecoveryStrategy {
441 RetryOnDifferentDevice,
442 ReduceCircuitComplexity,
443 FallbackToSimulator,
444 SkipFailedBenchmark,
445}
446
447#[derive(Debug, Clone, Serialize, Deserialize)]
448pub struct HypothesisTestingConfig {
449 pub tests: Vec<StatisticalTest>,
450 pub multiple_comparisons_correction: MultipleComparisonsCorrection,
451 pub effect_size_measures: Vec<EffectSizeMeasure>,
452}
453
454#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
455pub enum StatisticalTest {
456 TTest,
457 MannWhitneyU,
458 KolmogorovSmirnov,
459 ChiSquare,
460 ANOVA,
461 KruskalWallis,
462}
463
464#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
465pub enum MultipleComparisonsCorrection {
466 Bonferroni,
467 FDR,
468 Holm,
469 Hochberg,
470}
471
472#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
473pub enum EffectSizeMeasure {
474 CohenD,
475 HedgeG,
476 GlassD,
477 EtaSquared,
478}
479
480#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
481pub enum MLModelType {
482 LinearRegression,
483 RandomForest,
484 GradientBoosting,
485 SupportVectorMachine,
486 SupportVector, NeuralNetwork,
488 GaussianProcess,
489 EnsembleMethod,
490}
491
492#[derive(Debug, Clone, Serialize, Deserialize)]
493pub struct FeatureEngineeringConfig {
494 pub polynomial_features: bool,
495 pub interaction_features: bool,
496 pub feature_selection: bool,
497 pub dimensionality_reduction: bool,
498}
499
500#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
501pub enum OptimizationObjective {
502 MinimizeExecutionTime,
503 MaximizeFidelity,
504 MinimizeCost,
505 MaximizeReliability,
506 MinimizeErrorRate,
507 MaximizeThroughput,
508}
509
510#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
511pub enum OptimizationAlgorithm {
512 GradientDescent,
513 ParticleSwarm,
514 GeneticAlgorithm,
515 DifferentialEvolution,
516 BayesianOptimization,
517 SimulatedAnnealing,
518}
519
520#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
521pub enum GraphMetric {
522 Betweenness,
523 Closeness,
524 Eigenvector,
525 PageRank,
526 ClusteringCoefficient,
527 Diameter,
528 AveragePathLength,
529}
530
531#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
532pub enum ReportFormat {
533 PDF,
534 HTML,
535 JSON,
536 CSV,
537 LaTeX,
538 Markdown,
539}
540
541#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
542pub enum VisualizationType {
543 PerformanceCharts,
544 StatisticalPlots,
545 TopologyGraphs,
546 CostAnalysis,
547 TrendAnalysis,
548 ComparisonMatrices,
549 Heatmaps,
550 TimeSeries,
551}
552
553#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
554pub enum ExportDestination {
555 LocalFile(String),
556 S3Bucket(String),
557 Database(String),
558 APIEndpoint(String),
559 Email(String),
560}
561
562#[derive(Debug, Clone, Serialize, Deserialize)]
563pub struct DashboardConfig {
564 pub enable_realtime: bool,
565 pub update_interval: Duration,
566 pub dashboard_port: u16,
567 pub authentication: DashboardAuth,
568}
569
570#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
571pub enum DashboardAuth {
572 None,
573 Basic { username: String, password: String },
574 Token { token: String },
575 OAuth { provider: String },
576}
577
578#[derive(Debug, Clone, Serialize, Deserialize)]
579pub struct AutomatedReportConfig {
580 pub enable_automated: bool,
581 pub report_schedule: ReportSchedule,
582 pub recipients: Vec<String>,
583 pub report_types: Vec<AutomatedReportType>,
584}
585
586#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
587pub enum ReportSchedule {
588 Daily,
589 Weekly,
590 Monthly,
591 Custom(String), }
593
594#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
595pub enum AutomatedReportType {
596 PerformanceSummary,
597 CostAnalysis,
598 TrendReport,
599 AnomalyReport,
600 ComparisonReport,
601}
602
603#[derive(Debug, Clone, Serialize, Deserialize)]
604pub struct CostOptimizationConfig {
605 pub enable_cost_optimization: bool,
606 pub cost_targets: CostTargets,
607 pub optimization_strategies: Vec<CostOptimizationStrategy>,
608}
609
610#[derive(Debug, Clone, Serialize, Deserialize)]
611pub struct CostTargets {
612 pub max_cost_per_shot: Option<f64>,
613 pub max_daily_cost: Option<f64>,
614 pub max_monthly_cost: Option<f64>,
615 pub cost_efficiency_target: Option<f64>,
616}
617
618#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
619pub enum CostOptimizationStrategy {
620 PreferLowerCostPlatforms,
621 OptimizeShotAllocation,
622 BatchExecutions,
623 UseSpotInstances,
624 ScheduleForOffPeakHours,
625}
626
627#[derive(Debug, Clone, Serialize, Deserialize)]
628pub struct PerformanceOptimizationConfig {
629 pub enable_performance_optimization: bool,
630 pub performance_targets: PerformanceTargets,
631 pub optimization_strategies: Vec<PerformanceOptimizationStrategy>,
632}
633
634#[derive(Debug, Clone, Serialize, Deserialize)]
635pub struct PerformanceTargets {
636 pub min_fidelity: f64,
637 pub max_error_rate: f64,
638 pub max_execution_time: Duration,
639 pub min_throughput: f64,
640}
641
642#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
643pub enum PerformanceOptimizationStrategy {
644 OptimizeCircuitMapping,
645 UseErrorMitigation,
646 ImplementDynamicalDecoupling,
647 OptimizeGateSequences,
648 AdaptiveCalibration,
649}
650
651#[derive(Debug, Clone, Serialize, Deserialize)]
652pub struct LoadBalancingConfig {
653 pub enable_load_balancing: bool,
654 pub balancing_strategy: LoadBalancingStrategy,
655 pub health_checks: HealthCheckConfig,
656}
657
658#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
659pub enum LoadBalancingStrategy {
660 RoundRobin,
661 WeightedRoundRobin,
662 LeastConnections,
663 ResourceBased,
664 PerformanceBased,
665}
666
667#[derive(Debug, Clone, Serialize, Deserialize)]
668pub struct HealthCheckConfig {
669 pub enable_health_checks: bool,
670 pub check_interval: Duration,
671 pub timeout: Duration,
672 pub failure_threshold: usize,
673}
674
675#[derive(Debug, Clone, Serialize, Deserialize)]
676pub struct SchedulingOptimizationConfig {
677 pub enable_scheduling: bool,
678 pub scheduling_strategy: SchedulingStrategy,
679 pub priority_handling: PriorityHandling,
680}
681
682#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
683pub enum SchedulingStrategy {
684 FIFO,
685 SJF, Priority,
687 Deadline,
688 ResourceAware,
689}
690
691#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
692pub enum PriorityHandling {
693 Strict,
694 WeightedFair,
695 TimeSlicing,
696}
697
698#[derive(Debug, Clone, Serialize, Deserialize)]
699pub struct TrendAnalysisConfig {
700 pub enable_trend_analysis: bool,
701 pub analysis_window: Duration,
702 pub trend_detection_methods: Vec<TrendDetectionMethod>,
703 pub forecast_horizon: Duration,
704}
705
706#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
707pub enum TrendDetectionMethod {
708 LinearRegression,
709 ARIMA,
710 ExponentialSmoothing,
711 ChangePointDetection,
712}
713
714#[derive(Debug, Clone, Serialize, Deserialize)]
715pub struct BaselineTrackingConfig {
716 pub enable_baseline_tracking: bool,
717 pub baseline_update_frequency: Duration,
718 pub baseline_metrics: Vec<BaselineMetric>,
719}
720
721#[derive(Debug, Clone, Serialize, Deserialize)]
722pub struct ComparativeAnalysisConfig {
723 pub enable_comparative_analysis: bool,
724 pub comparison_methods: Vec<ComparisonMethod>,
725 pub significance_testing: bool,
726}
727
728#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
729pub enum ComparisonMethod {
730 PairwiseComparison,
731 RankingAnalysis,
732 PerformanceMatrix,
733 CostBenefitAnalysis,
734}
735
736#[derive(Debug, Clone, Serialize, Deserialize)]
737pub struct CustomBenchmarkDefinition {
738 pub name: String,
739 pub description: String,
740 pub circuit_definition: CustomCircuitDefinition,
741 pub execution_parameters: CustomExecutionParameters,
742 pub success_criteria: SuccessCriteria,
743}
744
745#[derive(Debug, Clone, Serialize, Deserialize)]
746pub struct CustomCircuitDefinition {
747 pub circuit_type: CustomCircuitType,
748 pub parameters: HashMap<String, f64>,
749 pub constraints: Vec<CircuitConstraint>,
750}
751
752#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
753pub enum CustomCircuitType {
754 QASM(String),
755 PythonFunction(String),
756 ParametricTemplate(String),
757 CircuitGenerator(String),
758}
759
760#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
761pub enum CircuitConstraint {
762 MaxDepth(usize),
763 MaxQubits(usize),
764 AllowedGates(Vec<String>),
765 ConnectivityConstraint(String),
766}
767
768#[derive(Debug, Clone, Serialize, Deserialize)]
769pub struct CustomExecutionParameters {
770 pub shots: usize,
771 pub repetitions: usize,
772 pub timeout: Duration,
773 pub platforms: Vec<QuantumPlatform>,
774}
775
776#[derive(Debug, Clone, Serialize, Deserialize)]
777pub struct SuccessCriteria {
778 pub min_fidelity: Option<f64>,
779 pub max_error_rate: Option<f64>,
780 pub max_execution_time: Option<Duration>,
781 pub custom_metrics: HashMap<String, f64>,
782}