SamplerBackend

SamplerBackend#

Module: iqm.qaoa.backends

class iqm.qaoa.backends.SamplerBackend[source]#

Bases: object

The template for sampler backends, i.e., those returning samples from the QAOA.

Methods

sample

Sample bitstrings from the QAOA circuit.

sample(qaoa_object, shots)[source]#
sample(qaoa_object, shots)
sample(qaoa_object, shots)

Sample bitstrings from the QAOA circuit.

This method uses singledispatchmethod() to dispatch to a type-specific implementation based on the runtime type of qaoa_object. If no registered implementation matches, it falls back to _sample_unsupported(). Subclasses should override the type-specific private methods rather than this one.

Parameters:
  • qaoa_object (QAOA) – A QAOA object to be sampled from.

  • shots (int) – The number of individual samples to take.

Returns:

A dictionary of samples. The keys are bitstrings and the values are their counts (which should add up to shots)

Raises:

TypeError – If no registered implementation exists for the type of qaoa_object.

Return type:

dict[str, int]

Inheritance

Inheritance diagram of iqm.qaoa.backends.SamplerBackend