iqm.cirq_iqm.iqm_sampler.IQMSampler#
- class iqm.cirq_iqm.iqm_sampler.IQMSampler(url: str, *, device: IQMDevice | None = None, calibration_set_id: UUID | None = None, run_sweep_timeout: int | None = None, compiler_options: CircuitCompilationOptions | None = 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 calibration-specific dynamic quantum architecture obtained fromIQMClient
.calibration_set_id (Optional[UUID]) – ID of the calibration set to use. If
None
, use the default one.run_sweep_timeout (Optional[int]) – Timeout for polling sweep results, in seconds. If
None
, use the client default value.compiler_options (Optional[CircuitCompilationOptions]) – The compilation options to use for the circuits, as defined by IQM Client.
- 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
_resolve_parameters
(program, params)_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.
create_run_request
(programs, *[, params, ...])Creates a run request without submitting it for execution.
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: Circuit, params: ParamResolver | Mapping[str | Expr, complex | float | Complex | Expr] | None | Sweep | _Sweepable, repetitions: int = 1) list[IQMResult] #
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: list[Circuit], repetitions: int = 1) list[IQMResult] #
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:
- create_run_request(programs: cirq.Circuit | list[cirq.Circuit], *, params: cirq.Sweepable = None, repetitions: int = 1) RunRequest #
Creates a run request without submitting it for execution.
This takes the same parameters as
run()
andrun_iqm_batch()
, and can be used to check the run request that would be sent when calling those functions.- Parameters:
- Returns:
the created run request
- Return type:
RunRequest
- run_sweep_async(program: cirq.AbstractCircuit, params: cirq.Sweepable, repetitions: int = 1) Sequence[cirq.Result] #
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.