CompositeCache#

class iqm.pulse.gate_implementation.CompositeCache#

Bases: object

Cache for CompositeGate TimeBoxes.

Result from CompositeGate.__call__`() (or other methods returning a TimeBox) cannot be stored in the normal cache GateImplementation._timebox_cache as composites can include any gates in their calls, and we cannot trust that the cache is flushed correctly just based on if the composite itself has its own calibration data changed (we would have to flush also when any of the composite’s members get new calibration, and this cannot consistently be deduced). For this reason, CompositeCache will be flushed whenever ANY gate implementation gets new calibration data.

Module: iqm.pulse.gate_implementation

Methods

flush

Flush the CompositeCache.

get

Get a TimeBox from the cache.

set

Set a TimeBox into the cache.

set(gate_implementation, cache_key, timebox, extra_id='')#

Set a TimeBox into the cache.

Parameters:
  • gate_implementation (GateImplementation) – gate implementation that created the TimeBox.

  • cache_key (tuple[Any, ...]) – hashable key identifying the TimeBox (usually the CompositeGate.__call__() arguments cast into a tuple).

  • timebox (TimeBox) – TimeBox that will be added to the cache.

  • extra_id (str) – extra string id for further identifying the result if needed (for example if the TimeBox did not come from the call method, but some other method, this could be the method’s name).

Return type:

None

get(gate_implementation, cache_key, extra_id='')#

Get a TimeBox from the cache.

Parameters:
  • gate_implementation (GateImplementation) – gate implementation that created the TimeBox.

  • cache_key (tuple[Any, ...]) – hashable key identifying the TimeBox (usually the CompositeGate.__call__() arguments cast into a tuple).

  • extra_id (str) – extra string id for further identifying the result (for example if the TimeBox did not come from the call method, but some other method, this could be the method’s name).

Returns:

The cached TimeBox or None if not fund for this gate_implementation, cache_key, and extra_id.

Return type:

TimeBox | None

flush()#

Flush the CompositeCache.

Return type:

None