IQMSampler#
Module: iqm.cirq_iqm.iqm_sampler
- class iqm.cirq_iqm.iqm_sampler.IQMSampler(url: str, *, quantum_computer: str | None = None, device: IQMDevice | None = None, calibration_set_id: UUID | None = None, run_sweep_timeout: float | None = None, compiler_options: CircuitCompilationOptions | None = None, use_timeslot: bool = False, **user_auth_args)#
Bases:
SamplerCircuit sampler for executing quantum circuits on IQM quantum computers.
IQMSampler connects to a quantum computer through an IQM Server. If the server requires user authentication, you can provide it either using environment variables, or as keyword arguments to IQMSampler. The user authentication kwargs are passed through to
IQMClientas is, and are documented there.- Parameters:
url (str) – URL of the IQM Server (e.g. “https://resonance.iqm.tech/”).
quantum_computer (str | None) – ID or alias of the quantum computer to connect to, if the IQM Server instance controls more than one (e.g. “garnet”).
Nonemeans connect to the default one.use_timeslot (bool) – Submits the job to the timeslot queue if set to
True. If set toFalse, the job is submitted to the normal on-demand queue.device (IQMDevice | None) – 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 (UUID | None) – ID of the calibration set to use. If
None, use the default one.run_sweep_timeout (float | None) – Timeout for polling sweep results, in seconds. If
None, use the client default value.compiler_options (CircuitCompilationOptions | None) – The compilation options to use for the circuits, as defined by IQM Client.
Attributes
Returns the device used by the sampler.
Methods
Create a run request without submitting it for execution.
Sends a batch of circuits to be executed.
Execute the given quantum circuit for various values of the given parameters.
Asynchronously samples from the given Circuit.
- run_sweep(program: Circuit, params: ParamResolver | Mapping[str | Expr, complex | number | Expr] | None | Sweep | _Sweepable, repetitions: int = 1) list[IQMResult]#
Execute the given quantum circuit for various values of the given parameters.
- 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
- Return type:
- create_run_request(programs: Circuit | list[Circuit], *, params: ParamResolver | Mapping[str | Expr, complex | number | Expr] | None | Sweep | _Sweepable = None, repetitions: int = 1) PostJobsRequest#
Create 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:
programs (Circuit | list[Circuit]) – quantum circuit(s) that would be executed when submitting the run request
params (ParamResolver | Mapping[str | Expr, complex | number | Expr] | None | Sweep | _Sweepable) – same as
paramsforrun(), used only ifprogramsis not a listrepetitions (int) – number of times the circuits are sampled
- Returns:
the created run request
- Return type:
- 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.
- Parameters:
program (cirq.AbstractCircuit) – The circuit to sample from.
params (cirq.Sweepable) – Parameters to run with the program.
repetitions (int) – The number of times to sample.
- Returns:
Result list for this run; one for each possible parameter resolver.
- Return type:
Sequence[cirq.Result]
Inheritance
