iqm.cirq_iqm.iqm_sampler.IQMSampler#
- class iqm.cirq_iqm.iqm_sampler.IQMSampler(url, device=None, *, calibration_set_id=None, run_sweep_timeout=None, max_circuit_duration_over_t2=None, heralding_mode=HeraldingMode.NONE, **user_auth_args)#
Bases:
Sampler
Circuit sampler for executing quantum circuits on IQM quantum computers.
- Parameters:
url (str) – Endpoint for accessing the server interface. Has to start with http or https.
device (Optional[IQMDevice]) – Device to execute the circuits on. If
None
, the device will be created based on the quantum architecture obtained fromIQMClient
.calibration_set_id (Optional[UUID]) – ID of the calibration set to use. If
None
, use the latest one.run_sweep_timeout (Optional[int]) – timeout to poll sweep results in seconds.
max_circuit_duration_over_t2 (Optional[float]) – Circuits are disqualified on the server if they are longer than this ratio of the T2 time of the qubits. If set to 0.0, no circuits are disqualified. If set to None the server default value is used.
heralding_mode (HeraldingMode) – Heralding mode to use during execution.
- Keyword Arguments:
auth_server_url (str) – URL of user authentication server, if required by the IQM Cortex server. This can also be set in the IQM_AUTH_SERVER environment variable.
username (str) – Username, if required by the IQM Cortex server. This can also be set in the IQM_AUTH_USERNAME environment variable.
password (str) – Password, if required by the IQM Cortex server. This can also be set in the IQM_AUTH_PASSWORD environment variable.
Attributes
Returns the device used by the sampler.
Methods
_send_circuits
(circuits[, repetitions])Sends a batch of circuits to be executed and retrieves the results.
Close IQMClient's session with the user authentication server.
run_iqm_batch
(programs[, repetitions])Sends a batch of circuits to be executed.
run_sweep
(program, params[, repetitions])Samples from the given Circuit.
run_sweep_async
(program, params[, repetitions])Asynchronously samples from the given Circuit.
- close_client()#
Close IQMClient’s session with the user authentication server. Discard the client.
- run_sweep(program, params, repetitions=1)#
Samples from the given Circuit.
This allows for sweeping over different parameter values, unlike the run method. The params argument will provide a mapping from sympy.Symbol`s used within the circuit to a set of values. Unlike the `run method, which specifies a single mapping from symbol to value, this method allows a “sweep” of values. This allows a user to specify execution of a family of related circuits efficiently.
- Parameters:
- Returns:
Result list for this run; one for each possible parameter resolver.
- Return type:
- run_iqm_batch(programs, repetitions=1)#
Sends a batch of circuits to be executed.
Running circuits in a batch is more efficient and hence completes quicker than running the circuits individually. Circuits run in a batch must all measure the same qubits.
- Parameters:
- Returns:
results of the execution
- Raises:
ValueError – circuits are not valid for execution
CircuitExecutionError – something went wrong on the server
APITimeoutError – server did not return the results in the allocated time
RuntimeError – IQM client session has been closed
- Return type:
- run_sweep_async(program, params, repetitions=1)#
Asynchronously samples from the given Circuit.
By default, this method invokes run_sweep synchronously and simply exposes its result is an awaitable. Child classes that are capable of true asynchronous sampling should override it to use other strategies.