pub struct DistributedExecutor {
pub backends: Vec<ExecutionBackend>,
pub load_balancer: LoadBalancer,
pub fault_tolerance: FaultToleranceConfig,
pub scheduler: ExecutionScheduler,
pub resource_manager: ResourceManager,
}
Expand description
A distributed quantum circuit execution engine
This manages execution of quantum circuits across multiple backends, handling load balancing, fault tolerance, and result aggregation.
Fields§
§backends: Vec<ExecutionBackend>
Available execution backends
load_balancer: LoadBalancer
Load balancing strategy
fault_tolerance: FaultToleranceConfig
Fault tolerance configuration
scheduler: ExecutionScheduler
Execution scheduling policy
resource_manager: ResourceManager
Resource management
Implementations§
Source§impl DistributedExecutor
impl DistributedExecutor
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new distributed executor
Examples found in repository?
examples/distributed_demo.rs (line 20)
12fn main() -> Result<(), Box<dyn std::error::Error>> {
13 println!("🌐 Distributed Circuit Execution Demo");
14 println!("====================================\n");
15
16 // Example 1: Setting up a distributed executor
17 println!("1. Creating Distributed Executor");
18 println!("--------------------------------");
19
20 let mut executor = DistributedExecutor::new();
21 println!("Created distributed executor with default configuration");
22 println!(" Load balancing: {:?}", executor.load_balancer.strategy);
23 println!(" Scheduling policy: {:?}", executor.scheduler.policy);
24 println!(
25 " Fault tolerance enabled: {}",
26 executor.fault_tolerance.enable_failover
27 );
28 println!(
29 " Redundancy level: {}",
30 executor.fault_tolerance.redundancy_level
31 );
32
33 // Example 2: Adding different types of backends
34 println!("\n2. Adding Execution Backends");
35 println!("----------------------------");
36
37 // Add a quantum hardware backend
38 let hardware_backend = create_hardware_backend();
39 println!("Adding hardware backend: {}", hardware_backend.id);
40 executor.add_backend(hardware_backend)?;
41
42 // Add a simulator backend
43 let simulator_backend = create_simulator_backend();
44 println!("Adding simulator backend: {}", simulator_backend.id);
45 executor.add_backend(simulator_backend)?;
46
47 // Add a cloud service backend
48 let cloud_backend = create_cloud_backend();
49 println!("Adding cloud backend: {}", cloud_backend.id);
50 executor.add_backend(cloud_backend)?;
51
52 // Add a hybrid backend
53 let hybrid_backend = create_hybrid_backend();
54 println!("Adding hybrid backend: {}", hybrid_backend.id);
55 executor.add_backend(hybrid_backend)?;
56
57 println!("Total backends added: {}", executor.backends.len());
58
59 // Example 3: System health status
60 println!("\n3. System Health Status");
61 println!("-----------------------");
62
63 let health = executor.get_health_status();
64 println!("System health:");
65 println!(" Total backends: {}", health.total_backends);
66 println!(" Available backends: {}", health.available_backends);
67 println!(" Total qubits: {}", health.total_qubits);
68 println!(
69 " Average queue time: {:.2} seconds",
70 health.average_queue_time
71 );
72 println!(" System load: {:.1}%", health.system_load * 100.0);
73
74 // Example 4: Creating and submitting jobs
75 println!("\n4. Creating and Submitting Jobs");
76 println!("-------------------------------");
77
78 // Create different types of circuits for testing
79 let jobs = create_test_jobs();
80
81 for (i, job) in jobs.iter().enumerate() {
82 println!(
83 "Job {}: {} ({} qubits, {} gates, priority: {:?})",
84 i + 1,
85 job.id,
86 job.circuit.num_qubits(),
87 job.circuit.num_gates(),
88 job.priority
89 );
90
91 match executor.submit_job(job.clone()) {
92 Ok(job_id) => println!(" ✅ Submitted successfully: {}", job_id),
93 Err(e) => println!(" ❌ Submission failed: {}", e),
94 }
95 }
96
97 // Example 5: Different load balancing strategies
98 println!("\n5. Load Balancing Strategies");
99 println!("----------------------------");
100
101 let strategies = vec![
102 ("Round Robin", LoadBalancingStrategy::RoundRobin),
103 ("Least Connections", LoadBalancingStrategy::LeastConnections),
104 ("Least Queue Time", LoadBalancingStrategy::LeastQueueTime),
105 ("Best Performance", LoadBalancingStrategy::BestPerformance),
106 ];
107
108 for (name, strategy) in strategies {
109 executor.load_balancer.strategy = strategy.clone();
110 println!(" {}: {:?}", name, strategy);
111 }
112
113 // Example 6: Backend types and capabilities
114 println!("\n6. Backend Types and Capabilities");
115 println!("---------------------------------");
116
117 for backend in &executor.backends {
118 println!("Backend: {} ({:?})", backend.id, backend.status);
119 match &backend.backend_type {
120 BackendType::Hardware {
121 vendor,
122 model,
123 location,
124 } => {
125 println!(" Type: Hardware ({} {} in {})", vendor, model, location);
126 }
127 BackendType::Simulator {
128 simulator_type,
129 host,
130 } => {
131 println!(" Type: Simulator ({:?} on {})", simulator_type, host);
132 }
133 BackendType::CloudService {
134 provider,
135 service_name,
136 region,
137 } => {
138 println!(
139 " Type: Cloud ({} {} in {})",
140 provider, service_name, region
141 );
142 }
143 BackendType::Hybrid {
144 quantum_backend: _,
145 classical_resources,
146 } => {
147 println!(
148 " Type: Hybrid ({} CPU cores, {:.1} GB memory)",
149 classical_resources.cpu_cores, classical_resources.memory_gb
150 );
151 }
152 }
153
154 println!(" Capabilities:");
155 println!(" Max qubits: {}", backend.performance.max_qubits);
156 println!(" Max depth: {}", backend.performance.max_depth);
157 println!(
158 " Supported gates: {:?}",
159 backend.capabilities.supported_gates
160 );
161 println!(
162 " Mid-circuit measurements: {}",
163 backend.capabilities.mid_circuit_measurements
164 );
165 println!(
166 " Queue length: {}/{}",
167 backend.queue_info.queue_length, backend.queue_info.max_queue_size
168 );
169 println!(
170 " Estimated wait time: {:.1} seconds",
171 backend.queue_info.estimated_wait_time
172 );
173 println!();
174 }
175
176 // Example 7: Execution parameters and error mitigation
177 println!("7. Execution Parameters and Error Mitigation");
178 println!("--------------------------------------------");
179
180 let error_mitigation_techniques = vec![
181 (
182 "Readout Error Mitigation",
183 ErrorMitigation::ReadoutErrorMitigation,
184 ),
185 (
186 "Zero Noise Extrapolation",
187 ErrorMitigation::ZeroNoiseExtrapolation,
188 ),
189 (
190 "Clifford Data Regression",
191 ErrorMitigation::CliffordDataRegression,
192 ),
193 (
194 "Symmetry Verification",
195 ErrorMitigation::SymmetryVerification,
196 ),
197 ];
198
199 for (name, technique) in error_mitigation_techniques {
200 println!(" {}: {:?}", name, technique);
201 }
202
203 let result_formats = vec![
204 ("Counts", ResultFormat::Counts),
205 ("Probabilities", ResultFormat::Probabilities),
206 ("Statevector", ResultFormat::Statevector),
207 ("Expectation Values", ResultFormat::ExpectationValues),
208 ];
209
210 println!("\nResult formats:");
211 for (name, format) in result_formats {
212 println!(" {}: {:?}", name, format);
213 }
214
215 // Example 8: Fault tolerance and redundancy
216 println!("\n8. Fault Tolerance and Redundancy");
217 println!("---------------------------------");
218
219 println!("Current fault tolerance configuration:");
220 println!(
221 " Failover enabled: {}",
222 executor.fault_tolerance.enable_failover
223 );
224 println!(
225 " Redundancy level: {}",
226 executor.fault_tolerance.redundancy_level
227 );
228 println!(
229 " Error correction: {:?}",
230 executor.fault_tolerance.error_correction
231 );
232
233 // Demonstrate different error correction strategies
234 let error_correction_strategies = vec![
235 ("None", ErrorCorrectionStrategy::None),
236 ("Majority Voting", ErrorCorrectionStrategy::MajorityVoting),
237 (
238 "Quantum Error Correction",
239 ErrorCorrectionStrategy::QuantumErrorCorrection,
240 ),
241 (
242 "Classical Post-processing",
243 ErrorCorrectionStrategy::ClassicalPostProcessing,
244 ),
245 ];
246
247 println!("\nAvailable error correction strategies:");
248 for (name, strategy) in error_correction_strategies {
249 println!(" {}: {:?}", name, strategy);
250 }
251
252 // Example 9: Resource management and allocation
253 println!("\n9. Resource Management and Allocation");
254 println!("------------------------------------");
255
256 println!("Resource pool:");
257 println!(
258 " Total qubits: {}",
259 executor.resource_manager.resource_pool.total_qubits
260 );
261 println!(
262 " Available slots: {}",
263 executor.resource_manager.resource_pool.available_slots
264 );
265 println!(
266 " Memory pool: {:.1} GB",
267 executor.resource_manager.resource_pool.memory_pool
268 );
269 println!(
270 " Compute pool: {:.1} CPU hours",
271 executor.resource_manager.resource_pool.compute_pool
272 );
273
274 println!("\nAllocation policies:");
275 if let Some(max_qubits) = executor
276 .resource_manager
277 .allocation_policies
278 .max_qubits_per_user
279 {
280 println!(" Max qubits per user: {}", max_qubits);
281 }
282 if let Some(max_time) = executor
283 .resource_manager
284 .allocation_policies
285 .max_execution_time
286 {
287 println!(" Max execution time: {:.1} seconds", max_time);
288 }
289 println!(
290 " Fair share: {}",
291 executor.resource_manager.allocation_policies.fair_share
292 );
293 println!(
294 " Reserved resources: {:.1}%",
295 executor
296 .resource_manager
297 .allocation_policies
298 .reserved_resources
299 * 100.0
300 );
301
302 // Example 10: Network configuration and authentication
303 println!("\n10. Network Configuration and Authentication");
304 println!("-------------------------------------------");
305
306 for backend in &executor.backends {
307 println!(
308 "Backend {}: {}",
309 backend.id, backend.network_config.endpoint
310 );
311 println!(
312 " Auth type: {:?}",
313 backend.network_config.credentials.auth_type
314 );
315 println!(
316 " Connection timeout: {:.1}s",
317 backend.network_config.timeouts.connection_timeout
318 );
319 println!(
320 " Request timeout: {:.1}s",
321 backend.network_config.timeouts.request_timeout
322 );
323 println!(
324 " Max retries: {}",
325 backend.network_config.retry_policy.max_retries
326 );
327 println!(
328 " Backoff strategy: {:?}",
329 backend.network_config.retry_policy.backoff_strategy
330 );
331 }
332
333 // Example 11: Job status and results (mock)
334 println!("\n11. Job Status and Results");
335 println!("--------------------------");
336
337 for job in jobs.iter().take(3) {
338 let status = executor.get_job_status(&job.id)?;
339 println!("Job {}: {:?}", job.id, status);
340
341 // Mock getting results for completed jobs
342 if status == ExecutionStatus::Queued {
343 let result = executor.get_results(&job.id)?;
344 println!(" Status: {:?}", result.status);
345 println!(" Backends used: {:?}", result.metadata.backends_used);
346 println!(" Total time: {:?}", result.metadata.total_time);
347 println!(" Queue time: {:?}", result.metadata.queue_time);
348 println!(" Resource usage:");
349 println!(
350 " CPU hours: {:.3}",
351 result.metadata.resource_usage.cpu_hours
352 );
353 println!(
354 " Memory hours: {:.3}",
355 result.metadata.resource_usage.memory_hours
356 );
357 println!(
358 " Qubit hours: {:.3}",
359 result.metadata.resource_usage.qubit_hours
360 );
361 println!(
362 " Network usage: {:.3} GB",
363 result.metadata.resource_usage.network_usage
364 );
365 }
366 }
367
368 // Example 12: Connectivity topologies
369 println!("\n12. Connectivity Topologies");
370 println!("---------------------------");
371
372 let topologies = vec![
373 ("Linear", distributed::TopologyType::Linear),
374 (
375 "2D Grid (3x3)",
376 distributed::TopologyType::Grid2D { rows: 3, cols: 3 },
377 ),
378 ("All-to-all", distributed::TopologyType::AllToAll),
379 (
380 "Random (70% density)",
381 distributed::TopologyType::Random { density: 0.7 },
382 ),
383 ];
384
385 for (name, topology) in topologies {
386 println!(" {}: {:?}", name, topology);
387 }
388
389 println!("\n✅ Distributed Circuit Execution Demo completed!");
390 println!("\nNote: This demo shows the distributed execution framework structure.");
391 println!("Real distributed execution requires actual quantum backends and networking.");
392
393 Ok(())
394}
Sourcepub fn add_backend(&mut self, backend: ExecutionBackend) -> QuantRS2Result<()>
pub fn add_backend(&mut self, backend: ExecutionBackend) -> QuantRS2Result<()>
Add a backend to the distributed executor
Examples found in repository?
examples/distributed_demo.rs (line 40)
12fn main() -> Result<(), Box<dyn std::error::Error>> {
13 println!("🌐 Distributed Circuit Execution Demo");
14 println!("====================================\n");
15
16 // Example 1: Setting up a distributed executor
17 println!("1. Creating Distributed Executor");
18 println!("--------------------------------");
19
20 let mut executor = DistributedExecutor::new();
21 println!("Created distributed executor with default configuration");
22 println!(" Load balancing: {:?}", executor.load_balancer.strategy);
23 println!(" Scheduling policy: {:?}", executor.scheduler.policy);
24 println!(
25 " Fault tolerance enabled: {}",
26 executor.fault_tolerance.enable_failover
27 );
28 println!(
29 " Redundancy level: {}",
30 executor.fault_tolerance.redundancy_level
31 );
32
33 // Example 2: Adding different types of backends
34 println!("\n2. Adding Execution Backends");
35 println!("----------------------------");
36
37 // Add a quantum hardware backend
38 let hardware_backend = create_hardware_backend();
39 println!("Adding hardware backend: {}", hardware_backend.id);
40 executor.add_backend(hardware_backend)?;
41
42 // Add a simulator backend
43 let simulator_backend = create_simulator_backend();
44 println!("Adding simulator backend: {}", simulator_backend.id);
45 executor.add_backend(simulator_backend)?;
46
47 // Add a cloud service backend
48 let cloud_backend = create_cloud_backend();
49 println!("Adding cloud backend: {}", cloud_backend.id);
50 executor.add_backend(cloud_backend)?;
51
52 // Add a hybrid backend
53 let hybrid_backend = create_hybrid_backend();
54 println!("Adding hybrid backend: {}", hybrid_backend.id);
55 executor.add_backend(hybrid_backend)?;
56
57 println!("Total backends added: {}", executor.backends.len());
58
59 // Example 3: System health status
60 println!("\n3. System Health Status");
61 println!("-----------------------");
62
63 let health = executor.get_health_status();
64 println!("System health:");
65 println!(" Total backends: {}", health.total_backends);
66 println!(" Available backends: {}", health.available_backends);
67 println!(" Total qubits: {}", health.total_qubits);
68 println!(
69 " Average queue time: {:.2} seconds",
70 health.average_queue_time
71 );
72 println!(" System load: {:.1}%", health.system_load * 100.0);
73
74 // Example 4: Creating and submitting jobs
75 println!("\n4. Creating and Submitting Jobs");
76 println!("-------------------------------");
77
78 // Create different types of circuits for testing
79 let jobs = create_test_jobs();
80
81 for (i, job) in jobs.iter().enumerate() {
82 println!(
83 "Job {}: {} ({} qubits, {} gates, priority: {:?})",
84 i + 1,
85 job.id,
86 job.circuit.num_qubits(),
87 job.circuit.num_gates(),
88 job.priority
89 );
90
91 match executor.submit_job(job.clone()) {
92 Ok(job_id) => println!(" ✅ Submitted successfully: {}", job_id),
93 Err(e) => println!(" ❌ Submission failed: {}", e),
94 }
95 }
96
97 // Example 5: Different load balancing strategies
98 println!("\n5. Load Balancing Strategies");
99 println!("----------------------------");
100
101 let strategies = vec![
102 ("Round Robin", LoadBalancingStrategy::RoundRobin),
103 ("Least Connections", LoadBalancingStrategy::LeastConnections),
104 ("Least Queue Time", LoadBalancingStrategy::LeastQueueTime),
105 ("Best Performance", LoadBalancingStrategy::BestPerformance),
106 ];
107
108 for (name, strategy) in strategies {
109 executor.load_balancer.strategy = strategy.clone();
110 println!(" {}: {:?}", name, strategy);
111 }
112
113 // Example 6: Backend types and capabilities
114 println!("\n6. Backend Types and Capabilities");
115 println!("---------------------------------");
116
117 for backend in &executor.backends {
118 println!("Backend: {} ({:?})", backend.id, backend.status);
119 match &backend.backend_type {
120 BackendType::Hardware {
121 vendor,
122 model,
123 location,
124 } => {
125 println!(" Type: Hardware ({} {} in {})", vendor, model, location);
126 }
127 BackendType::Simulator {
128 simulator_type,
129 host,
130 } => {
131 println!(" Type: Simulator ({:?} on {})", simulator_type, host);
132 }
133 BackendType::CloudService {
134 provider,
135 service_name,
136 region,
137 } => {
138 println!(
139 " Type: Cloud ({} {} in {})",
140 provider, service_name, region
141 );
142 }
143 BackendType::Hybrid {
144 quantum_backend: _,
145 classical_resources,
146 } => {
147 println!(
148 " Type: Hybrid ({} CPU cores, {:.1} GB memory)",
149 classical_resources.cpu_cores, classical_resources.memory_gb
150 );
151 }
152 }
153
154 println!(" Capabilities:");
155 println!(" Max qubits: {}", backend.performance.max_qubits);
156 println!(" Max depth: {}", backend.performance.max_depth);
157 println!(
158 " Supported gates: {:?}",
159 backend.capabilities.supported_gates
160 );
161 println!(
162 " Mid-circuit measurements: {}",
163 backend.capabilities.mid_circuit_measurements
164 );
165 println!(
166 " Queue length: {}/{}",
167 backend.queue_info.queue_length, backend.queue_info.max_queue_size
168 );
169 println!(
170 " Estimated wait time: {:.1} seconds",
171 backend.queue_info.estimated_wait_time
172 );
173 println!();
174 }
175
176 // Example 7: Execution parameters and error mitigation
177 println!("7. Execution Parameters and Error Mitigation");
178 println!("--------------------------------------------");
179
180 let error_mitigation_techniques = vec![
181 (
182 "Readout Error Mitigation",
183 ErrorMitigation::ReadoutErrorMitigation,
184 ),
185 (
186 "Zero Noise Extrapolation",
187 ErrorMitigation::ZeroNoiseExtrapolation,
188 ),
189 (
190 "Clifford Data Regression",
191 ErrorMitigation::CliffordDataRegression,
192 ),
193 (
194 "Symmetry Verification",
195 ErrorMitigation::SymmetryVerification,
196 ),
197 ];
198
199 for (name, technique) in error_mitigation_techniques {
200 println!(" {}: {:?}", name, technique);
201 }
202
203 let result_formats = vec![
204 ("Counts", ResultFormat::Counts),
205 ("Probabilities", ResultFormat::Probabilities),
206 ("Statevector", ResultFormat::Statevector),
207 ("Expectation Values", ResultFormat::ExpectationValues),
208 ];
209
210 println!("\nResult formats:");
211 for (name, format) in result_formats {
212 println!(" {}: {:?}", name, format);
213 }
214
215 // Example 8: Fault tolerance and redundancy
216 println!("\n8. Fault Tolerance and Redundancy");
217 println!("---------------------------------");
218
219 println!("Current fault tolerance configuration:");
220 println!(
221 " Failover enabled: {}",
222 executor.fault_tolerance.enable_failover
223 );
224 println!(
225 " Redundancy level: {}",
226 executor.fault_tolerance.redundancy_level
227 );
228 println!(
229 " Error correction: {:?}",
230 executor.fault_tolerance.error_correction
231 );
232
233 // Demonstrate different error correction strategies
234 let error_correction_strategies = vec![
235 ("None", ErrorCorrectionStrategy::None),
236 ("Majority Voting", ErrorCorrectionStrategy::MajorityVoting),
237 (
238 "Quantum Error Correction",
239 ErrorCorrectionStrategy::QuantumErrorCorrection,
240 ),
241 (
242 "Classical Post-processing",
243 ErrorCorrectionStrategy::ClassicalPostProcessing,
244 ),
245 ];
246
247 println!("\nAvailable error correction strategies:");
248 for (name, strategy) in error_correction_strategies {
249 println!(" {}: {:?}", name, strategy);
250 }
251
252 // Example 9: Resource management and allocation
253 println!("\n9. Resource Management and Allocation");
254 println!("------------------------------------");
255
256 println!("Resource pool:");
257 println!(
258 " Total qubits: {}",
259 executor.resource_manager.resource_pool.total_qubits
260 );
261 println!(
262 " Available slots: {}",
263 executor.resource_manager.resource_pool.available_slots
264 );
265 println!(
266 " Memory pool: {:.1} GB",
267 executor.resource_manager.resource_pool.memory_pool
268 );
269 println!(
270 " Compute pool: {:.1} CPU hours",
271 executor.resource_manager.resource_pool.compute_pool
272 );
273
274 println!("\nAllocation policies:");
275 if let Some(max_qubits) = executor
276 .resource_manager
277 .allocation_policies
278 .max_qubits_per_user
279 {
280 println!(" Max qubits per user: {}", max_qubits);
281 }
282 if let Some(max_time) = executor
283 .resource_manager
284 .allocation_policies
285 .max_execution_time
286 {
287 println!(" Max execution time: {:.1} seconds", max_time);
288 }
289 println!(
290 " Fair share: {}",
291 executor.resource_manager.allocation_policies.fair_share
292 );
293 println!(
294 " Reserved resources: {:.1}%",
295 executor
296 .resource_manager
297 .allocation_policies
298 .reserved_resources
299 * 100.0
300 );
301
302 // Example 10: Network configuration and authentication
303 println!("\n10. Network Configuration and Authentication");
304 println!("-------------------------------------------");
305
306 for backend in &executor.backends {
307 println!(
308 "Backend {}: {}",
309 backend.id, backend.network_config.endpoint
310 );
311 println!(
312 " Auth type: {:?}",
313 backend.network_config.credentials.auth_type
314 );
315 println!(
316 " Connection timeout: {:.1}s",
317 backend.network_config.timeouts.connection_timeout
318 );
319 println!(
320 " Request timeout: {:.1}s",
321 backend.network_config.timeouts.request_timeout
322 );
323 println!(
324 " Max retries: {}",
325 backend.network_config.retry_policy.max_retries
326 );
327 println!(
328 " Backoff strategy: {:?}",
329 backend.network_config.retry_policy.backoff_strategy
330 );
331 }
332
333 // Example 11: Job status and results (mock)
334 println!("\n11. Job Status and Results");
335 println!("--------------------------");
336
337 for job in jobs.iter().take(3) {
338 let status = executor.get_job_status(&job.id)?;
339 println!("Job {}: {:?}", job.id, status);
340
341 // Mock getting results for completed jobs
342 if status == ExecutionStatus::Queued {
343 let result = executor.get_results(&job.id)?;
344 println!(" Status: {:?}", result.status);
345 println!(" Backends used: {:?}", result.metadata.backends_used);
346 println!(" Total time: {:?}", result.metadata.total_time);
347 println!(" Queue time: {:?}", result.metadata.queue_time);
348 println!(" Resource usage:");
349 println!(
350 " CPU hours: {:.3}",
351 result.metadata.resource_usage.cpu_hours
352 );
353 println!(
354 " Memory hours: {:.3}",
355 result.metadata.resource_usage.memory_hours
356 );
357 println!(
358 " Qubit hours: {:.3}",
359 result.metadata.resource_usage.qubit_hours
360 );
361 println!(
362 " Network usage: {:.3} GB",
363 result.metadata.resource_usage.network_usage
364 );
365 }
366 }
367
368 // Example 12: Connectivity topologies
369 println!("\n12. Connectivity Topologies");
370 println!("---------------------------");
371
372 let topologies = vec![
373 ("Linear", distributed::TopologyType::Linear),
374 (
375 "2D Grid (3x3)",
376 distributed::TopologyType::Grid2D { rows: 3, cols: 3 },
377 ),
378 ("All-to-all", distributed::TopologyType::AllToAll),
379 (
380 "Random (70% density)",
381 distributed::TopologyType::Random { density: 0.7 },
382 ),
383 ];
384
385 for (name, topology) in topologies {
386 println!(" {}: {:?}", name, topology);
387 }
388
389 println!("\n✅ Distributed Circuit Execution Demo completed!");
390 println!("\nNote: This demo shows the distributed execution framework structure.");
391 println!("Real distributed execution requires actual quantum backends and networking.");
392
393 Ok(())
394}
Sourcepub fn submit_job<const N: usize>(
&mut self,
job: DistributedJob<N>,
) -> QuantRS2Result<String>
pub fn submit_job<const N: usize>( &mut self, job: DistributedJob<N>, ) -> QuantRS2Result<String>
Submit a job for distributed execution
Examples found in repository?
examples/distributed_demo.rs (line 91)
12fn main() -> Result<(), Box<dyn std::error::Error>> {
13 println!("🌐 Distributed Circuit Execution Demo");
14 println!("====================================\n");
15
16 // Example 1: Setting up a distributed executor
17 println!("1. Creating Distributed Executor");
18 println!("--------------------------------");
19
20 let mut executor = DistributedExecutor::new();
21 println!("Created distributed executor with default configuration");
22 println!(" Load balancing: {:?}", executor.load_balancer.strategy);
23 println!(" Scheduling policy: {:?}", executor.scheduler.policy);
24 println!(
25 " Fault tolerance enabled: {}",
26 executor.fault_tolerance.enable_failover
27 );
28 println!(
29 " Redundancy level: {}",
30 executor.fault_tolerance.redundancy_level
31 );
32
33 // Example 2: Adding different types of backends
34 println!("\n2. Adding Execution Backends");
35 println!("----------------------------");
36
37 // Add a quantum hardware backend
38 let hardware_backend = create_hardware_backend();
39 println!("Adding hardware backend: {}", hardware_backend.id);
40 executor.add_backend(hardware_backend)?;
41
42 // Add a simulator backend
43 let simulator_backend = create_simulator_backend();
44 println!("Adding simulator backend: {}", simulator_backend.id);
45 executor.add_backend(simulator_backend)?;
46
47 // Add a cloud service backend
48 let cloud_backend = create_cloud_backend();
49 println!("Adding cloud backend: {}", cloud_backend.id);
50 executor.add_backend(cloud_backend)?;
51
52 // Add a hybrid backend
53 let hybrid_backend = create_hybrid_backend();
54 println!("Adding hybrid backend: {}", hybrid_backend.id);
55 executor.add_backend(hybrid_backend)?;
56
57 println!("Total backends added: {}", executor.backends.len());
58
59 // Example 3: System health status
60 println!("\n3. System Health Status");
61 println!("-----------------------");
62
63 let health = executor.get_health_status();
64 println!("System health:");
65 println!(" Total backends: {}", health.total_backends);
66 println!(" Available backends: {}", health.available_backends);
67 println!(" Total qubits: {}", health.total_qubits);
68 println!(
69 " Average queue time: {:.2} seconds",
70 health.average_queue_time
71 );
72 println!(" System load: {:.1}%", health.system_load * 100.0);
73
74 // Example 4: Creating and submitting jobs
75 println!("\n4. Creating and Submitting Jobs");
76 println!("-------------------------------");
77
78 // Create different types of circuits for testing
79 let jobs = create_test_jobs();
80
81 for (i, job) in jobs.iter().enumerate() {
82 println!(
83 "Job {}: {} ({} qubits, {} gates, priority: {:?})",
84 i + 1,
85 job.id,
86 job.circuit.num_qubits(),
87 job.circuit.num_gates(),
88 job.priority
89 );
90
91 match executor.submit_job(job.clone()) {
92 Ok(job_id) => println!(" ✅ Submitted successfully: {}", job_id),
93 Err(e) => println!(" ❌ Submission failed: {}", e),
94 }
95 }
96
97 // Example 5: Different load balancing strategies
98 println!("\n5. Load Balancing Strategies");
99 println!("----------------------------");
100
101 let strategies = vec![
102 ("Round Robin", LoadBalancingStrategy::RoundRobin),
103 ("Least Connections", LoadBalancingStrategy::LeastConnections),
104 ("Least Queue Time", LoadBalancingStrategy::LeastQueueTime),
105 ("Best Performance", LoadBalancingStrategy::BestPerformance),
106 ];
107
108 for (name, strategy) in strategies {
109 executor.load_balancer.strategy = strategy.clone();
110 println!(" {}: {:?}", name, strategy);
111 }
112
113 // Example 6: Backend types and capabilities
114 println!("\n6. Backend Types and Capabilities");
115 println!("---------------------------------");
116
117 for backend in &executor.backends {
118 println!("Backend: {} ({:?})", backend.id, backend.status);
119 match &backend.backend_type {
120 BackendType::Hardware {
121 vendor,
122 model,
123 location,
124 } => {
125 println!(" Type: Hardware ({} {} in {})", vendor, model, location);
126 }
127 BackendType::Simulator {
128 simulator_type,
129 host,
130 } => {
131 println!(" Type: Simulator ({:?} on {})", simulator_type, host);
132 }
133 BackendType::CloudService {
134 provider,
135 service_name,
136 region,
137 } => {
138 println!(
139 " Type: Cloud ({} {} in {})",
140 provider, service_name, region
141 );
142 }
143 BackendType::Hybrid {
144 quantum_backend: _,
145 classical_resources,
146 } => {
147 println!(
148 " Type: Hybrid ({} CPU cores, {:.1} GB memory)",
149 classical_resources.cpu_cores, classical_resources.memory_gb
150 );
151 }
152 }
153
154 println!(" Capabilities:");
155 println!(" Max qubits: {}", backend.performance.max_qubits);
156 println!(" Max depth: {}", backend.performance.max_depth);
157 println!(
158 " Supported gates: {:?}",
159 backend.capabilities.supported_gates
160 );
161 println!(
162 " Mid-circuit measurements: {}",
163 backend.capabilities.mid_circuit_measurements
164 );
165 println!(
166 " Queue length: {}/{}",
167 backend.queue_info.queue_length, backend.queue_info.max_queue_size
168 );
169 println!(
170 " Estimated wait time: {:.1} seconds",
171 backend.queue_info.estimated_wait_time
172 );
173 println!();
174 }
175
176 // Example 7: Execution parameters and error mitigation
177 println!("7. Execution Parameters and Error Mitigation");
178 println!("--------------------------------------------");
179
180 let error_mitigation_techniques = vec![
181 (
182 "Readout Error Mitigation",
183 ErrorMitigation::ReadoutErrorMitigation,
184 ),
185 (
186 "Zero Noise Extrapolation",
187 ErrorMitigation::ZeroNoiseExtrapolation,
188 ),
189 (
190 "Clifford Data Regression",
191 ErrorMitigation::CliffordDataRegression,
192 ),
193 (
194 "Symmetry Verification",
195 ErrorMitigation::SymmetryVerification,
196 ),
197 ];
198
199 for (name, technique) in error_mitigation_techniques {
200 println!(" {}: {:?}", name, technique);
201 }
202
203 let result_formats = vec![
204 ("Counts", ResultFormat::Counts),
205 ("Probabilities", ResultFormat::Probabilities),
206 ("Statevector", ResultFormat::Statevector),
207 ("Expectation Values", ResultFormat::ExpectationValues),
208 ];
209
210 println!("\nResult formats:");
211 for (name, format) in result_formats {
212 println!(" {}: {:?}", name, format);
213 }
214
215 // Example 8: Fault tolerance and redundancy
216 println!("\n8. Fault Tolerance and Redundancy");
217 println!("---------------------------------");
218
219 println!("Current fault tolerance configuration:");
220 println!(
221 " Failover enabled: {}",
222 executor.fault_tolerance.enable_failover
223 );
224 println!(
225 " Redundancy level: {}",
226 executor.fault_tolerance.redundancy_level
227 );
228 println!(
229 " Error correction: {:?}",
230 executor.fault_tolerance.error_correction
231 );
232
233 // Demonstrate different error correction strategies
234 let error_correction_strategies = vec![
235 ("None", ErrorCorrectionStrategy::None),
236 ("Majority Voting", ErrorCorrectionStrategy::MajorityVoting),
237 (
238 "Quantum Error Correction",
239 ErrorCorrectionStrategy::QuantumErrorCorrection,
240 ),
241 (
242 "Classical Post-processing",
243 ErrorCorrectionStrategy::ClassicalPostProcessing,
244 ),
245 ];
246
247 println!("\nAvailable error correction strategies:");
248 for (name, strategy) in error_correction_strategies {
249 println!(" {}: {:?}", name, strategy);
250 }
251
252 // Example 9: Resource management and allocation
253 println!("\n9. Resource Management and Allocation");
254 println!("------------------------------------");
255
256 println!("Resource pool:");
257 println!(
258 " Total qubits: {}",
259 executor.resource_manager.resource_pool.total_qubits
260 );
261 println!(
262 " Available slots: {}",
263 executor.resource_manager.resource_pool.available_slots
264 );
265 println!(
266 " Memory pool: {:.1} GB",
267 executor.resource_manager.resource_pool.memory_pool
268 );
269 println!(
270 " Compute pool: {:.1} CPU hours",
271 executor.resource_manager.resource_pool.compute_pool
272 );
273
274 println!("\nAllocation policies:");
275 if let Some(max_qubits) = executor
276 .resource_manager
277 .allocation_policies
278 .max_qubits_per_user
279 {
280 println!(" Max qubits per user: {}", max_qubits);
281 }
282 if let Some(max_time) = executor
283 .resource_manager
284 .allocation_policies
285 .max_execution_time
286 {
287 println!(" Max execution time: {:.1} seconds", max_time);
288 }
289 println!(
290 " Fair share: {}",
291 executor.resource_manager.allocation_policies.fair_share
292 );
293 println!(
294 " Reserved resources: {:.1}%",
295 executor
296 .resource_manager
297 .allocation_policies
298 .reserved_resources
299 * 100.0
300 );
301
302 // Example 10: Network configuration and authentication
303 println!("\n10. Network Configuration and Authentication");
304 println!("-------------------------------------------");
305
306 for backend in &executor.backends {
307 println!(
308 "Backend {}: {}",
309 backend.id, backend.network_config.endpoint
310 );
311 println!(
312 " Auth type: {:?}",
313 backend.network_config.credentials.auth_type
314 );
315 println!(
316 " Connection timeout: {:.1}s",
317 backend.network_config.timeouts.connection_timeout
318 );
319 println!(
320 " Request timeout: {:.1}s",
321 backend.network_config.timeouts.request_timeout
322 );
323 println!(
324 " Max retries: {}",
325 backend.network_config.retry_policy.max_retries
326 );
327 println!(
328 " Backoff strategy: {:?}",
329 backend.network_config.retry_policy.backoff_strategy
330 );
331 }
332
333 // Example 11: Job status and results (mock)
334 println!("\n11. Job Status and Results");
335 println!("--------------------------");
336
337 for job in jobs.iter().take(3) {
338 let status = executor.get_job_status(&job.id)?;
339 println!("Job {}: {:?}", job.id, status);
340
341 // Mock getting results for completed jobs
342 if status == ExecutionStatus::Queued {
343 let result = executor.get_results(&job.id)?;
344 println!(" Status: {:?}", result.status);
345 println!(" Backends used: {:?}", result.metadata.backends_used);
346 println!(" Total time: {:?}", result.metadata.total_time);
347 println!(" Queue time: {:?}", result.metadata.queue_time);
348 println!(" Resource usage:");
349 println!(
350 " CPU hours: {:.3}",
351 result.metadata.resource_usage.cpu_hours
352 );
353 println!(
354 " Memory hours: {:.3}",
355 result.metadata.resource_usage.memory_hours
356 );
357 println!(
358 " Qubit hours: {:.3}",
359 result.metadata.resource_usage.qubit_hours
360 );
361 println!(
362 " Network usage: {:.3} GB",
363 result.metadata.resource_usage.network_usage
364 );
365 }
366 }
367
368 // Example 12: Connectivity topologies
369 println!("\n12. Connectivity Topologies");
370 println!("---------------------------");
371
372 let topologies = vec![
373 ("Linear", distributed::TopologyType::Linear),
374 (
375 "2D Grid (3x3)",
376 distributed::TopologyType::Grid2D { rows: 3, cols: 3 },
377 ),
378 ("All-to-all", distributed::TopologyType::AllToAll),
379 (
380 "Random (70% density)",
381 distributed::TopologyType::Random { density: 0.7 },
382 ),
383 ];
384
385 for (name, topology) in topologies {
386 println!(" {}: {:?}", name, topology);
387 }
388
389 println!("\n✅ Distributed Circuit Execution Demo completed!");
390 println!("\nNote: This demo shows the distributed execution framework structure.");
391 println!("Real distributed execution requires actual quantum backends and networking.");
392
393 Ok(())
394}
Sourcepub fn get_job_status(&self, job_id: &str) -> QuantRS2Result<ExecutionStatus>
pub fn get_job_status(&self, job_id: &str) -> QuantRS2Result<ExecutionStatus>
Get execution status for a job
Examples found in repository?
examples/distributed_demo.rs (line 338)
12fn main() -> Result<(), Box<dyn std::error::Error>> {
13 println!("🌐 Distributed Circuit Execution Demo");
14 println!("====================================\n");
15
16 // Example 1: Setting up a distributed executor
17 println!("1. Creating Distributed Executor");
18 println!("--------------------------------");
19
20 let mut executor = DistributedExecutor::new();
21 println!("Created distributed executor with default configuration");
22 println!(" Load balancing: {:?}", executor.load_balancer.strategy);
23 println!(" Scheduling policy: {:?}", executor.scheduler.policy);
24 println!(
25 " Fault tolerance enabled: {}",
26 executor.fault_tolerance.enable_failover
27 );
28 println!(
29 " Redundancy level: {}",
30 executor.fault_tolerance.redundancy_level
31 );
32
33 // Example 2: Adding different types of backends
34 println!("\n2. Adding Execution Backends");
35 println!("----------------------------");
36
37 // Add a quantum hardware backend
38 let hardware_backend = create_hardware_backend();
39 println!("Adding hardware backend: {}", hardware_backend.id);
40 executor.add_backend(hardware_backend)?;
41
42 // Add a simulator backend
43 let simulator_backend = create_simulator_backend();
44 println!("Adding simulator backend: {}", simulator_backend.id);
45 executor.add_backend(simulator_backend)?;
46
47 // Add a cloud service backend
48 let cloud_backend = create_cloud_backend();
49 println!("Adding cloud backend: {}", cloud_backend.id);
50 executor.add_backend(cloud_backend)?;
51
52 // Add a hybrid backend
53 let hybrid_backend = create_hybrid_backend();
54 println!("Adding hybrid backend: {}", hybrid_backend.id);
55 executor.add_backend(hybrid_backend)?;
56
57 println!("Total backends added: {}", executor.backends.len());
58
59 // Example 3: System health status
60 println!("\n3. System Health Status");
61 println!("-----------------------");
62
63 let health = executor.get_health_status();
64 println!("System health:");
65 println!(" Total backends: {}", health.total_backends);
66 println!(" Available backends: {}", health.available_backends);
67 println!(" Total qubits: {}", health.total_qubits);
68 println!(
69 " Average queue time: {:.2} seconds",
70 health.average_queue_time
71 );
72 println!(" System load: {:.1}%", health.system_load * 100.0);
73
74 // Example 4: Creating and submitting jobs
75 println!("\n4. Creating and Submitting Jobs");
76 println!("-------------------------------");
77
78 // Create different types of circuits for testing
79 let jobs = create_test_jobs();
80
81 for (i, job) in jobs.iter().enumerate() {
82 println!(
83 "Job {}: {} ({} qubits, {} gates, priority: {:?})",
84 i + 1,
85 job.id,
86 job.circuit.num_qubits(),
87 job.circuit.num_gates(),
88 job.priority
89 );
90
91 match executor.submit_job(job.clone()) {
92 Ok(job_id) => println!(" ✅ Submitted successfully: {}", job_id),
93 Err(e) => println!(" ❌ Submission failed: {}", e),
94 }
95 }
96
97 // Example 5: Different load balancing strategies
98 println!("\n5. Load Balancing Strategies");
99 println!("----------------------------");
100
101 let strategies = vec![
102 ("Round Robin", LoadBalancingStrategy::RoundRobin),
103 ("Least Connections", LoadBalancingStrategy::LeastConnections),
104 ("Least Queue Time", LoadBalancingStrategy::LeastQueueTime),
105 ("Best Performance", LoadBalancingStrategy::BestPerformance),
106 ];
107
108 for (name, strategy) in strategies {
109 executor.load_balancer.strategy = strategy.clone();
110 println!(" {}: {:?}", name, strategy);
111 }
112
113 // Example 6: Backend types and capabilities
114 println!("\n6. Backend Types and Capabilities");
115 println!("---------------------------------");
116
117 for backend in &executor.backends {
118 println!("Backend: {} ({:?})", backend.id, backend.status);
119 match &backend.backend_type {
120 BackendType::Hardware {
121 vendor,
122 model,
123 location,
124 } => {
125 println!(" Type: Hardware ({} {} in {})", vendor, model, location);
126 }
127 BackendType::Simulator {
128 simulator_type,
129 host,
130 } => {
131 println!(" Type: Simulator ({:?} on {})", simulator_type, host);
132 }
133 BackendType::CloudService {
134 provider,
135 service_name,
136 region,
137 } => {
138 println!(
139 " Type: Cloud ({} {} in {})",
140 provider, service_name, region
141 );
142 }
143 BackendType::Hybrid {
144 quantum_backend: _,
145 classical_resources,
146 } => {
147 println!(
148 " Type: Hybrid ({} CPU cores, {:.1} GB memory)",
149 classical_resources.cpu_cores, classical_resources.memory_gb
150 );
151 }
152 }
153
154 println!(" Capabilities:");
155 println!(" Max qubits: {}", backend.performance.max_qubits);
156 println!(" Max depth: {}", backend.performance.max_depth);
157 println!(
158 " Supported gates: {:?}",
159 backend.capabilities.supported_gates
160 );
161 println!(
162 " Mid-circuit measurements: {}",
163 backend.capabilities.mid_circuit_measurements
164 );
165 println!(
166 " Queue length: {}/{}",
167 backend.queue_info.queue_length, backend.queue_info.max_queue_size
168 );
169 println!(
170 " Estimated wait time: {:.1} seconds",
171 backend.queue_info.estimated_wait_time
172 );
173 println!();
174 }
175
176 // Example 7: Execution parameters and error mitigation
177 println!("7. Execution Parameters and Error Mitigation");
178 println!("--------------------------------------------");
179
180 let error_mitigation_techniques = vec![
181 (
182 "Readout Error Mitigation",
183 ErrorMitigation::ReadoutErrorMitigation,
184 ),
185 (
186 "Zero Noise Extrapolation",
187 ErrorMitigation::ZeroNoiseExtrapolation,
188 ),
189 (
190 "Clifford Data Regression",
191 ErrorMitigation::CliffordDataRegression,
192 ),
193 (
194 "Symmetry Verification",
195 ErrorMitigation::SymmetryVerification,
196 ),
197 ];
198
199 for (name, technique) in error_mitigation_techniques {
200 println!(" {}: {:?}", name, technique);
201 }
202
203 let result_formats = vec![
204 ("Counts", ResultFormat::Counts),
205 ("Probabilities", ResultFormat::Probabilities),
206 ("Statevector", ResultFormat::Statevector),
207 ("Expectation Values", ResultFormat::ExpectationValues),
208 ];
209
210 println!("\nResult formats:");
211 for (name, format) in result_formats {
212 println!(" {}: {:?}", name, format);
213 }
214
215 // Example 8: Fault tolerance and redundancy
216 println!("\n8. Fault Tolerance and Redundancy");
217 println!("---------------------------------");
218
219 println!("Current fault tolerance configuration:");
220 println!(
221 " Failover enabled: {}",
222 executor.fault_tolerance.enable_failover
223 );
224 println!(
225 " Redundancy level: {}",
226 executor.fault_tolerance.redundancy_level
227 );
228 println!(
229 " Error correction: {:?}",
230 executor.fault_tolerance.error_correction
231 );
232
233 // Demonstrate different error correction strategies
234 let error_correction_strategies = vec![
235 ("None", ErrorCorrectionStrategy::None),
236 ("Majority Voting", ErrorCorrectionStrategy::MajorityVoting),
237 (
238 "Quantum Error Correction",
239 ErrorCorrectionStrategy::QuantumErrorCorrection,
240 ),
241 (
242 "Classical Post-processing",
243 ErrorCorrectionStrategy::ClassicalPostProcessing,
244 ),
245 ];
246
247 println!("\nAvailable error correction strategies:");
248 for (name, strategy) in error_correction_strategies {
249 println!(" {}: {:?}", name, strategy);
250 }
251
252 // Example 9: Resource management and allocation
253 println!("\n9. Resource Management and Allocation");
254 println!("------------------------------------");
255
256 println!("Resource pool:");
257 println!(
258 " Total qubits: {}",
259 executor.resource_manager.resource_pool.total_qubits
260 );
261 println!(
262 " Available slots: {}",
263 executor.resource_manager.resource_pool.available_slots
264 );
265 println!(
266 " Memory pool: {:.1} GB",
267 executor.resource_manager.resource_pool.memory_pool
268 );
269 println!(
270 " Compute pool: {:.1} CPU hours",
271 executor.resource_manager.resource_pool.compute_pool
272 );
273
274 println!("\nAllocation policies:");
275 if let Some(max_qubits) = executor
276 .resource_manager
277 .allocation_policies
278 .max_qubits_per_user
279 {
280 println!(" Max qubits per user: {}", max_qubits);
281 }
282 if let Some(max_time) = executor
283 .resource_manager
284 .allocation_policies
285 .max_execution_time
286 {
287 println!(" Max execution time: {:.1} seconds", max_time);
288 }
289 println!(
290 " Fair share: {}",
291 executor.resource_manager.allocation_policies.fair_share
292 );
293 println!(
294 " Reserved resources: {:.1}%",
295 executor
296 .resource_manager
297 .allocation_policies
298 .reserved_resources
299 * 100.0
300 );
301
302 // Example 10: Network configuration and authentication
303 println!("\n10. Network Configuration and Authentication");
304 println!("-------------------------------------------");
305
306 for backend in &executor.backends {
307 println!(
308 "Backend {}: {}",
309 backend.id, backend.network_config.endpoint
310 );
311 println!(
312 " Auth type: {:?}",
313 backend.network_config.credentials.auth_type
314 );
315 println!(
316 " Connection timeout: {:.1}s",
317 backend.network_config.timeouts.connection_timeout
318 );
319 println!(
320 " Request timeout: {:.1}s",
321 backend.network_config.timeouts.request_timeout
322 );
323 println!(
324 " Max retries: {}",
325 backend.network_config.retry_policy.max_retries
326 );
327 println!(
328 " Backoff strategy: {:?}",
329 backend.network_config.retry_policy.backoff_strategy
330 );
331 }
332
333 // Example 11: Job status and results (mock)
334 println!("\n11. Job Status and Results");
335 println!("--------------------------");
336
337 for job in jobs.iter().take(3) {
338 let status = executor.get_job_status(&job.id)?;
339 println!("Job {}: {:?}", job.id, status);
340
341 // Mock getting results for completed jobs
342 if status == ExecutionStatus::Queued {
343 let result = executor.get_results(&job.id)?;
344 println!(" Status: {:?}", result.status);
345 println!(" Backends used: {:?}", result.metadata.backends_used);
346 println!(" Total time: {:?}", result.metadata.total_time);
347 println!(" Queue time: {:?}", result.metadata.queue_time);
348 println!(" Resource usage:");
349 println!(
350 " CPU hours: {:.3}",
351 result.metadata.resource_usage.cpu_hours
352 );
353 println!(
354 " Memory hours: {:.3}",
355 result.metadata.resource_usage.memory_hours
356 );
357 println!(
358 " Qubit hours: {:.3}",
359 result.metadata.resource_usage.qubit_hours
360 );
361 println!(
362 " Network usage: {:.3} GB",
363 result.metadata.resource_usage.network_usage
364 );
365 }
366 }
367
368 // Example 12: Connectivity topologies
369 println!("\n12. Connectivity Topologies");
370 println!("---------------------------");
371
372 let topologies = vec![
373 ("Linear", distributed::TopologyType::Linear),
374 (
375 "2D Grid (3x3)",
376 distributed::TopologyType::Grid2D { rows: 3, cols: 3 },
377 ),
378 ("All-to-all", distributed::TopologyType::AllToAll),
379 (
380 "Random (70% density)",
381 distributed::TopologyType::Random { density: 0.7 },
382 ),
383 ];
384
385 for (name, topology) in topologies {
386 println!(" {}: {:?}", name, topology);
387 }
388
389 println!("\n✅ Distributed Circuit Execution Demo completed!");
390 println!("\nNote: This demo shows the distributed execution framework structure.");
391 println!("Real distributed execution requires actual quantum backends and networking.");
392
393 Ok(())
394}
Sourcepub fn cancel_job(&mut self, job_id: &str) -> QuantRS2Result<()>
pub fn cancel_job(&mut self, job_id: &str) -> QuantRS2Result<()>
Cancel a job
Sourcepub fn get_results(&self, job_id: &str) -> QuantRS2Result<DistributedResult>
pub fn get_results(&self, job_id: &str) -> QuantRS2Result<DistributedResult>
Get results for a completed job
Examples found in repository?
examples/distributed_demo.rs (line 343)
12fn main() -> Result<(), Box<dyn std::error::Error>> {
13 println!("🌐 Distributed Circuit Execution Demo");
14 println!("====================================\n");
15
16 // Example 1: Setting up a distributed executor
17 println!("1. Creating Distributed Executor");
18 println!("--------------------------------");
19
20 let mut executor = DistributedExecutor::new();
21 println!("Created distributed executor with default configuration");
22 println!(" Load balancing: {:?}", executor.load_balancer.strategy);
23 println!(" Scheduling policy: {:?}", executor.scheduler.policy);
24 println!(
25 " Fault tolerance enabled: {}",
26 executor.fault_tolerance.enable_failover
27 );
28 println!(
29 " Redundancy level: {}",
30 executor.fault_tolerance.redundancy_level
31 );
32
33 // Example 2: Adding different types of backends
34 println!("\n2. Adding Execution Backends");
35 println!("----------------------------");
36
37 // Add a quantum hardware backend
38 let hardware_backend = create_hardware_backend();
39 println!("Adding hardware backend: {}", hardware_backend.id);
40 executor.add_backend(hardware_backend)?;
41
42 // Add a simulator backend
43 let simulator_backend = create_simulator_backend();
44 println!("Adding simulator backend: {}", simulator_backend.id);
45 executor.add_backend(simulator_backend)?;
46
47 // Add a cloud service backend
48 let cloud_backend = create_cloud_backend();
49 println!("Adding cloud backend: {}", cloud_backend.id);
50 executor.add_backend(cloud_backend)?;
51
52 // Add a hybrid backend
53 let hybrid_backend = create_hybrid_backend();
54 println!("Adding hybrid backend: {}", hybrid_backend.id);
55 executor.add_backend(hybrid_backend)?;
56
57 println!("Total backends added: {}", executor.backends.len());
58
59 // Example 3: System health status
60 println!("\n3. System Health Status");
61 println!("-----------------------");
62
63 let health = executor.get_health_status();
64 println!("System health:");
65 println!(" Total backends: {}", health.total_backends);
66 println!(" Available backends: {}", health.available_backends);
67 println!(" Total qubits: {}", health.total_qubits);
68 println!(
69 " Average queue time: {:.2} seconds",
70 health.average_queue_time
71 );
72 println!(" System load: {:.1}%", health.system_load * 100.0);
73
74 // Example 4: Creating and submitting jobs
75 println!("\n4. Creating and Submitting Jobs");
76 println!("-------------------------------");
77
78 // Create different types of circuits for testing
79 let jobs = create_test_jobs();
80
81 for (i, job) in jobs.iter().enumerate() {
82 println!(
83 "Job {}: {} ({} qubits, {} gates, priority: {:?})",
84 i + 1,
85 job.id,
86 job.circuit.num_qubits(),
87 job.circuit.num_gates(),
88 job.priority
89 );
90
91 match executor.submit_job(job.clone()) {
92 Ok(job_id) => println!(" ✅ Submitted successfully: {}", job_id),
93 Err(e) => println!(" ❌ Submission failed: {}", e),
94 }
95 }
96
97 // Example 5: Different load balancing strategies
98 println!("\n5. Load Balancing Strategies");
99 println!("----------------------------");
100
101 let strategies = vec![
102 ("Round Robin", LoadBalancingStrategy::RoundRobin),
103 ("Least Connections", LoadBalancingStrategy::LeastConnections),
104 ("Least Queue Time", LoadBalancingStrategy::LeastQueueTime),
105 ("Best Performance", LoadBalancingStrategy::BestPerformance),
106 ];
107
108 for (name, strategy) in strategies {
109 executor.load_balancer.strategy = strategy.clone();
110 println!(" {}: {:?}", name, strategy);
111 }
112
113 // Example 6: Backend types and capabilities
114 println!("\n6. Backend Types and Capabilities");
115 println!("---------------------------------");
116
117 for backend in &executor.backends {
118 println!("Backend: {} ({:?})", backend.id, backend.status);
119 match &backend.backend_type {
120 BackendType::Hardware {
121 vendor,
122 model,
123 location,
124 } => {
125 println!(" Type: Hardware ({} {} in {})", vendor, model, location);
126 }
127 BackendType::Simulator {
128 simulator_type,
129 host,
130 } => {
131 println!(" Type: Simulator ({:?} on {})", simulator_type, host);
132 }
133 BackendType::CloudService {
134 provider,
135 service_name,
136 region,
137 } => {
138 println!(
139 " Type: Cloud ({} {} in {})",
140 provider, service_name, region
141 );
142 }
143 BackendType::Hybrid {
144 quantum_backend: _,
145 classical_resources,
146 } => {
147 println!(
148 " Type: Hybrid ({} CPU cores, {:.1} GB memory)",
149 classical_resources.cpu_cores, classical_resources.memory_gb
150 );
151 }
152 }
153
154 println!(" Capabilities:");
155 println!(" Max qubits: {}", backend.performance.max_qubits);
156 println!(" Max depth: {}", backend.performance.max_depth);
157 println!(
158 " Supported gates: {:?}",
159 backend.capabilities.supported_gates
160 );
161 println!(
162 " Mid-circuit measurements: {}",
163 backend.capabilities.mid_circuit_measurements
164 );
165 println!(
166 " Queue length: {}/{}",
167 backend.queue_info.queue_length, backend.queue_info.max_queue_size
168 );
169 println!(
170 " Estimated wait time: {:.1} seconds",
171 backend.queue_info.estimated_wait_time
172 );
173 println!();
174 }
175
176 // Example 7: Execution parameters and error mitigation
177 println!("7. Execution Parameters and Error Mitigation");
178 println!("--------------------------------------------");
179
180 let error_mitigation_techniques = vec![
181 (
182 "Readout Error Mitigation",
183 ErrorMitigation::ReadoutErrorMitigation,
184 ),
185 (
186 "Zero Noise Extrapolation",
187 ErrorMitigation::ZeroNoiseExtrapolation,
188 ),
189 (
190 "Clifford Data Regression",
191 ErrorMitigation::CliffordDataRegression,
192 ),
193 (
194 "Symmetry Verification",
195 ErrorMitigation::SymmetryVerification,
196 ),
197 ];
198
199 for (name, technique) in error_mitigation_techniques {
200 println!(" {}: {:?}", name, technique);
201 }
202
203 let result_formats = vec![
204 ("Counts", ResultFormat::Counts),
205 ("Probabilities", ResultFormat::Probabilities),
206 ("Statevector", ResultFormat::Statevector),
207 ("Expectation Values", ResultFormat::ExpectationValues),
208 ];
209
210 println!("\nResult formats:");
211 for (name, format) in result_formats {
212 println!(" {}: {:?}", name, format);
213 }
214
215 // Example 8: Fault tolerance and redundancy
216 println!("\n8. Fault Tolerance and Redundancy");
217 println!("---------------------------------");
218
219 println!("Current fault tolerance configuration:");
220 println!(
221 " Failover enabled: {}",
222 executor.fault_tolerance.enable_failover
223 );
224 println!(
225 " Redundancy level: {}",
226 executor.fault_tolerance.redundancy_level
227 );
228 println!(
229 " Error correction: {:?}",
230 executor.fault_tolerance.error_correction
231 );
232
233 // Demonstrate different error correction strategies
234 let error_correction_strategies = vec![
235 ("None", ErrorCorrectionStrategy::None),
236 ("Majority Voting", ErrorCorrectionStrategy::MajorityVoting),
237 (
238 "Quantum Error Correction",
239 ErrorCorrectionStrategy::QuantumErrorCorrection,
240 ),
241 (
242 "Classical Post-processing",
243 ErrorCorrectionStrategy::ClassicalPostProcessing,
244 ),
245 ];
246
247 println!("\nAvailable error correction strategies:");
248 for (name, strategy) in error_correction_strategies {
249 println!(" {}: {:?}", name, strategy);
250 }
251
252 // Example 9: Resource management and allocation
253 println!("\n9. Resource Management and Allocation");
254 println!("------------------------------------");
255
256 println!("Resource pool:");
257 println!(
258 " Total qubits: {}",
259 executor.resource_manager.resource_pool.total_qubits
260 );
261 println!(
262 " Available slots: {}",
263 executor.resource_manager.resource_pool.available_slots
264 );
265 println!(
266 " Memory pool: {:.1} GB",
267 executor.resource_manager.resource_pool.memory_pool
268 );
269 println!(
270 " Compute pool: {:.1} CPU hours",
271 executor.resource_manager.resource_pool.compute_pool
272 );
273
274 println!("\nAllocation policies:");
275 if let Some(max_qubits) = executor
276 .resource_manager
277 .allocation_policies
278 .max_qubits_per_user
279 {
280 println!(" Max qubits per user: {}", max_qubits);
281 }
282 if let Some(max_time) = executor
283 .resource_manager
284 .allocation_policies
285 .max_execution_time
286 {
287 println!(" Max execution time: {:.1} seconds", max_time);
288 }
289 println!(
290 " Fair share: {}",
291 executor.resource_manager.allocation_policies.fair_share
292 );
293 println!(
294 " Reserved resources: {:.1}%",
295 executor
296 .resource_manager
297 .allocation_policies
298 .reserved_resources
299 * 100.0
300 );
301
302 // Example 10: Network configuration and authentication
303 println!("\n10. Network Configuration and Authentication");
304 println!("-------------------------------------------");
305
306 for backend in &executor.backends {
307 println!(
308 "Backend {}: {}",
309 backend.id, backend.network_config.endpoint
310 );
311 println!(
312 " Auth type: {:?}",
313 backend.network_config.credentials.auth_type
314 );
315 println!(
316 " Connection timeout: {:.1}s",
317 backend.network_config.timeouts.connection_timeout
318 );
319 println!(
320 " Request timeout: {:.1}s",
321 backend.network_config.timeouts.request_timeout
322 );
323 println!(
324 " Max retries: {}",
325 backend.network_config.retry_policy.max_retries
326 );
327 println!(
328 " Backoff strategy: {:?}",
329 backend.network_config.retry_policy.backoff_strategy
330 );
331 }
332
333 // Example 11: Job status and results (mock)
334 println!("\n11. Job Status and Results");
335 println!("--------------------------");
336
337 for job in jobs.iter().take(3) {
338 let status = executor.get_job_status(&job.id)?;
339 println!("Job {}: {:?}", job.id, status);
340
341 // Mock getting results for completed jobs
342 if status == ExecutionStatus::Queued {
343 let result = executor.get_results(&job.id)?;
344 println!(" Status: {:?}", result.status);
345 println!(" Backends used: {:?}", result.metadata.backends_used);
346 println!(" Total time: {:?}", result.metadata.total_time);
347 println!(" Queue time: {:?}", result.metadata.queue_time);
348 println!(" Resource usage:");
349 println!(
350 " CPU hours: {:.3}",
351 result.metadata.resource_usage.cpu_hours
352 );
353 println!(
354 " Memory hours: {:.3}",
355 result.metadata.resource_usage.memory_hours
356 );
357 println!(
358 " Qubit hours: {:.3}",
359 result.metadata.resource_usage.qubit_hours
360 );
361 println!(
362 " Network usage: {:.3} GB",
363 result.metadata.resource_usage.network_usage
364 );
365 }
366 }
367
368 // Example 12: Connectivity topologies
369 println!("\n12. Connectivity Topologies");
370 println!("---------------------------");
371
372 let topologies = vec![
373 ("Linear", distributed::TopologyType::Linear),
374 (
375 "2D Grid (3x3)",
376 distributed::TopologyType::Grid2D { rows: 3, cols: 3 },
377 ),
378 ("All-to-all", distributed::TopologyType::AllToAll),
379 (
380 "Random (70% density)",
381 distributed::TopologyType::Random { density: 0.7 },
382 ),
383 ];
384
385 for (name, topology) in topologies {
386 println!(" {}: {:?}", name, topology);
387 }
388
389 println!("\n✅ Distributed Circuit Execution Demo completed!");
390 println!("\nNote: This demo shows the distributed execution framework structure.");
391 println!("Real distributed execution requires actual quantum backends and networking.");
392
393 Ok(())
394}
Sourcepub fn get_health_status(&self) -> SystemHealthStatus
pub fn get_health_status(&self) -> SystemHealthStatus
Get system health status
Examples found in repository?
examples/distributed_demo.rs (line 63)
12fn main() -> Result<(), Box<dyn std::error::Error>> {
13 println!("🌐 Distributed Circuit Execution Demo");
14 println!("====================================\n");
15
16 // Example 1: Setting up a distributed executor
17 println!("1. Creating Distributed Executor");
18 println!("--------------------------------");
19
20 let mut executor = DistributedExecutor::new();
21 println!("Created distributed executor with default configuration");
22 println!(" Load balancing: {:?}", executor.load_balancer.strategy);
23 println!(" Scheduling policy: {:?}", executor.scheduler.policy);
24 println!(
25 " Fault tolerance enabled: {}",
26 executor.fault_tolerance.enable_failover
27 );
28 println!(
29 " Redundancy level: {}",
30 executor.fault_tolerance.redundancy_level
31 );
32
33 // Example 2: Adding different types of backends
34 println!("\n2. Adding Execution Backends");
35 println!("----------------------------");
36
37 // Add a quantum hardware backend
38 let hardware_backend = create_hardware_backend();
39 println!("Adding hardware backend: {}", hardware_backend.id);
40 executor.add_backend(hardware_backend)?;
41
42 // Add a simulator backend
43 let simulator_backend = create_simulator_backend();
44 println!("Adding simulator backend: {}", simulator_backend.id);
45 executor.add_backend(simulator_backend)?;
46
47 // Add a cloud service backend
48 let cloud_backend = create_cloud_backend();
49 println!("Adding cloud backend: {}", cloud_backend.id);
50 executor.add_backend(cloud_backend)?;
51
52 // Add a hybrid backend
53 let hybrid_backend = create_hybrid_backend();
54 println!("Adding hybrid backend: {}", hybrid_backend.id);
55 executor.add_backend(hybrid_backend)?;
56
57 println!("Total backends added: {}", executor.backends.len());
58
59 // Example 3: System health status
60 println!("\n3. System Health Status");
61 println!("-----------------------");
62
63 let health = executor.get_health_status();
64 println!("System health:");
65 println!(" Total backends: {}", health.total_backends);
66 println!(" Available backends: {}", health.available_backends);
67 println!(" Total qubits: {}", health.total_qubits);
68 println!(
69 " Average queue time: {:.2} seconds",
70 health.average_queue_time
71 );
72 println!(" System load: {:.1}%", health.system_load * 100.0);
73
74 // Example 4: Creating and submitting jobs
75 println!("\n4. Creating and Submitting Jobs");
76 println!("-------------------------------");
77
78 // Create different types of circuits for testing
79 let jobs = create_test_jobs();
80
81 for (i, job) in jobs.iter().enumerate() {
82 println!(
83 "Job {}: {} ({} qubits, {} gates, priority: {:?})",
84 i + 1,
85 job.id,
86 job.circuit.num_qubits(),
87 job.circuit.num_gates(),
88 job.priority
89 );
90
91 match executor.submit_job(job.clone()) {
92 Ok(job_id) => println!(" ✅ Submitted successfully: {}", job_id),
93 Err(e) => println!(" ❌ Submission failed: {}", e),
94 }
95 }
96
97 // Example 5: Different load balancing strategies
98 println!("\n5. Load Balancing Strategies");
99 println!("----------------------------");
100
101 let strategies = vec![
102 ("Round Robin", LoadBalancingStrategy::RoundRobin),
103 ("Least Connections", LoadBalancingStrategy::LeastConnections),
104 ("Least Queue Time", LoadBalancingStrategy::LeastQueueTime),
105 ("Best Performance", LoadBalancingStrategy::BestPerformance),
106 ];
107
108 for (name, strategy) in strategies {
109 executor.load_balancer.strategy = strategy.clone();
110 println!(" {}: {:?}", name, strategy);
111 }
112
113 // Example 6: Backend types and capabilities
114 println!("\n6. Backend Types and Capabilities");
115 println!("---------------------------------");
116
117 for backend in &executor.backends {
118 println!("Backend: {} ({:?})", backend.id, backend.status);
119 match &backend.backend_type {
120 BackendType::Hardware {
121 vendor,
122 model,
123 location,
124 } => {
125 println!(" Type: Hardware ({} {} in {})", vendor, model, location);
126 }
127 BackendType::Simulator {
128 simulator_type,
129 host,
130 } => {
131 println!(" Type: Simulator ({:?} on {})", simulator_type, host);
132 }
133 BackendType::CloudService {
134 provider,
135 service_name,
136 region,
137 } => {
138 println!(
139 " Type: Cloud ({} {} in {})",
140 provider, service_name, region
141 );
142 }
143 BackendType::Hybrid {
144 quantum_backend: _,
145 classical_resources,
146 } => {
147 println!(
148 " Type: Hybrid ({} CPU cores, {:.1} GB memory)",
149 classical_resources.cpu_cores, classical_resources.memory_gb
150 );
151 }
152 }
153
154 println!(" Capabilities:");
155 println!(" Max qubits: {}", backend.performance.max_qubits);
156 println!(" Max depth: {}", backend.performance.max_depth);
157 println!(
158 " Supported gates: {:?}",
159 backend.capabilities.supported_gates
160 );
161 println!(
162 " Mid-circuit measurements: {}",
163 backend.capabilities.mid_circuit_measurements
164 );
165 println!(
166 " Queue length: {}/{}",
167 backend.queue_info.queue_length, backend.queue_info.max_queue_size
168 );
169 println!(
170 " Estimated wait time: {:.1} seconds",
171 backend.queue_info.estimated_wait_time
172 );
173 println!();
174 }
175
176 // Example 7: Execution parameters and error mitigation
177 println!("7. Execution Parameters and Error Mitigation");
178 println!("--------------------------------------------");
179
180 let error_mitigation_techniques = vec![
181 (
182 "Readout Error Mitigation",
183 ErrorMitigation::ReadoutErrorMitigation,
184 ),
185 (
186 "Zero Noise Extrapolation",
187 ErrorMitigation::ZeroNoiseExtrapolation,
188 ),
189 (
190 "Clifford Data Regression",
191 ErrorMitigation::CliffordDataRegression,
192 ),
193 (
194 "Symmetry Verification",
195 ErrorMitigation::SymmetryVerification,
196 ),
197 ];
198
199 for (name, technique) in error_mitigation_techniques {
200 println!(" {}: {:?}", name, technique);
201 }
202
203 let result_formats = vec![
204 ("Counts", ResultFormat::Counts),
205 ("Probabilities", ResultFormat::Probabilities),
206 ("Statevector", ResultFormat::Statevector),
207 ("Expectation Values", ResultFormat::ExpectationValues),
208 ];
209
210 println!("\nResult formats:");
211 for (name, format) in result_formats {
212 println!(" {}: {:?}", name, format);
213 }
214
215 // Example 8: Fault tolerance and redundancy
216 println!("\n8. Fault Tolerance and Redundancy");
217 println!("---------------------------------");
218
219 println!("Current fault tolerance configuration:");
220 println!(
221 " Failover enabled: {}",
222 executor.fault_tolerance.enable_failover
223 );
224 println!(
225 " Redundancy level: {}",
226 executor.fault_tolerance.redundancy_level
227 );
228 println!(
229 " Error correction: {:?}",
230 executor.fault_tolerance.error_correction
231 );
232
233 // Demonstrate different error correction strategies
234 let error_correction_strategies = vec![
235 ("None", ErrorCorrectionStrategy::None),
236 ("Majority Voting", ErrorCorrectionStrategy::MajorityVoting),
237 (
238 "Quantum Error Correction",
239 ErrorCorrectionStrategy::QuantumErrorCorrection,
240 ),
241 (
242 "Classical Post-processing",
243 ErrorCorrectionStrategy::ClassicalPostProcessing,
244 ),
245 ];
246
247 println!("\nAvailable error correction strategies:");
248 for (name, strategy) in error_correction_strategies {
249 println!(" {}: {:?}", name, strategy);
250 }
251
252 // Example 9: Resource management and allocation
253 println!("\n9. Resource Management and Allocation");
254 println!("------------------------------------");
255
256 println!("Resource pool:");
257 println!(
258 " Total qubits: {}",
259 executor.resource_manager.resource_pool.total_qubits
260 );
261 println!(
262 " Available slots: {}",
263 executor.resource_manager.resource_pool.available_slots
264 );
265 println!(
266 " Memory pool: {:.1} GB",
267 executor.resource_manager.resource_pool.memory_pool
268 );
269 println!(
270 " Compute pool: {:.1} CPU hours",
271 executor.resource_manager.resource_pool.compute_pool
272 );
273
274 println!("\nAllocation policies:");
275 if let Some(max_qubits) = executor
276 .resource_manager
277 .allocation_policies
278 .max_qubits_per_user
279 {
280 println!(" Max qubits per user: {}", max_qubits);
281 }
282 if let Some(max_time) = executor
283 .resource_manager
284 .allocation_policies
285 .max_execution_time
286 {
287 println!(" Max execution time: {:.1} seconds", max_time);
288 }
289 println!(
290 " Fair share: {}",
291 executor.resource_manager.allocation_policies.fair_share
292 );
293 println!(
294 " Reserved resources: {:.1}%",
295 executor
296 .resource_manager
297 .allocation_policies
298 .reserved_resources
299 * 100.0
300 );
301
302 // Example 10: Network configuration and authentication
303 println!("\n10. Network Configuration and Authentication");
304 println!("-------------------------------------------");
305
306 for backend in &executor.backends {
307 println!(
308 "Backend {}: {}",
309 backend.id, backend.network_config.endpoint
310 );
311 println!(
312 " Auth type: {:?}",
313 backend.network_config.credentials.auth_type
314 );
315 println!(
316 " Connection timeout: {:.1}s",
317 backend.network_config.timeouts.connection_timeout
318 );
319 println!(
320 " Request timeout: {:.1}s",
321 backend.network_config.timeouts.request_timeout
322 );
323 println!(
324 " Max retries: {}",
325 backend.network_config.retry_policy.max_retries
326 );
327 println!(
328 " Backoff strategy: {:?}",
329 backend.network_config.retry_policy.backoff_strategy
330 );
331 }
332
333 // Example 11: Job status and results (mock)
334 println!("\n11. Job Status and Results");
335 println!("--------------------------");
336
337 for job in jobs.iter().take(3) {
338 let status = executor.get_job_status(&job.id)?;
339 println!("Job {}: {:?}", job.id, status);
340
341 // Mock getting results for completed jobs
342 if status == ExecutionStatus::Queued {
343 let result = executor.get_results(&job.id)?;
344 println!(" Status: {:?}", result.status);
345 println!(" Backends used: {:?}", result.metadata.backends_used);
346 println!(" Total time: {:?}", result.metadata.total_time);
347 println!(" Queue time: {:?}", result.metadata.queue_time);
348 println!(" Resource usage:");
349 println!(
350 " CPU hours: {:.3}",
351 result.metadata.resource_usage.cpu_hours
352 );
353 println!(
354 " Memory hours: {:.3}",
355 result.metadata.resource_usage.memory_hours
356 );
357 println!(
358 " Qubit hours: {:.3}",
359 result.metadata.resource_usage.qubit_hours
360 );
361 println!(
362 " Network usage: {:.3} GB",
363 result.metadata.resource_usage.network_usage
364 );
365 }
366 }
367
368 // Example 12: Connectivity topologies
369 println!("\n12. Connectivity Topologies");
370 println!("---------------------------");
371
372 let topologies = vec![
373 ("Linear", distributed::TopologyType::Linear),
374 (
375 "2D Grid (3x3)",
376 distributed::TopologyType::Grid2D { rows: 3, cols: 3 },
377 ),
378 ("All-to-all", distributed::TopologyType::AllToAll),
379 (
380 "Random (70% density)",
381 distributed::TopologyType::Random { density: 0.7 },
382 ),
383 ];
384
385 for (name, topology) in topologies {
386 println!(" {}: {:?}", name, topology);
387 }
388
389 println!("\n✅ Distributed Circuit Execution Demo completed!");
390 println!("\nNote: This demo shows the distributed execution framework structure.");
391 println!("Real distributed execution requires actual quantum backends and networking.");
392
393 Ok(())
394}
Trait Implementations§
Source§impl Debug for DistributedExecutor
impl Debug for DistributedExecutor
Auto Trait Implementations§
impl Freeze for DistributedExecutor
impl RefUnwindSafe for DistributedExecutor
impl Send for DistributedExecutor
impl Sync for DistributedExecutor
impl Unpin for DistributedExecutor
impl UnwindSafe for DistributedExecutor
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self
from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self
is actually part of its subset T
(and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset
but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self
to the equivalent element of its superset.