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: Sampler

Circuit 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 IQMClient as 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”). None means connect to the default one.

  • use_timeslot (bool) – Submits the job to the timeslot queue if set to True. If set to False, 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 from IQMClient.

  • 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

device

Returns the device used by the sampler.

Methods

create_run_request

Create a run request without submitting it for execution.

run_iqm_batch

Sends a batch of circuits to be executed.

run_sweep

Execute the given quantum circuit for various values of the given parameters.

run_sweep_async

Asynchronously samples from the given Circuit.

property device: IQMDevice#

Returns the device used by the sampler.

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.

Parameters:
  • program (Circuit)

  • params (ParamResolver | Mapping[str | Expr, complex | number | Expr] | None | Sweep | _Sweepable)

  • repetitions (int)

Return type:

list[IQMResult]

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:
  • programs (list[Circuit]) – quantum circuits to execute

  • repetitions (int) – number of times the circuits are sampled

Returns:

results of the execution

Raises:
Return type:

list[IQMResult]

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() and run_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 params for run(), used only if programs is not a list

  • repetitions (int) – number of times the circuits are sampled

Returns:

the created run request

Return type:

PostJobsRequest

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

Inheritance diagram of iqm.cirq_iqm.iqm_sampler.IQMSampler