iqm.cpc.compiler.dd.apply_dd_strategy

iqm.cpc.compiler.dd.apply_dd_strategy#

iqm.cpc.compiler.dd.apply_dd_strategy(schedules, builder, context, dd_is_disabled=True, qubit_specific_dd=None, idling_specific_dd=None, DDStrategy_merge_contiguous_waits=True, DDStrategy_target_qubits=None, DDStrategy_skip_leading_wait=True, DDStrategy_skip_trailing_wait=True, DDStrategy_gate_sequences_ratio=[9, 5, 2], DDStrategy_gate_sequences_gate_pattern_xy=['XYXYYXYX', 'YXYX', 'XX'], DDStrategy_gate_sequences_align=['asap', 'asap', 'center'])#

Insert dynamical decoupling sequences into the schedules iff dd_is_disabled is False.

By default DD is controlled by a DDStrategy, which can be provided in context["DDStrategy"], or as individual fields in the settings tree (the DDStrategy_* parameters). Alternatively you can override this with qubit-specific DD strategies, or idling window -specific DD strategies. The precedence of the parameters to this function (highest first) is

  1. idling_specific_dd — per-idle-window DD. May be either

    • an IdleDDMap mapping IdleWindowKey keys to DDGateSequence lists (the longest sequence that fits in the idle window is applied) or to None (no DD for this window).

    • a callable IdleDDMapBuilder. Invoked inside the pass after waits are merged and idle windows enumerated, but before any DD pulse is applied.

    Idle windows not in the map use the default DD sequence defined in DDStrategy, if any.

    To inspect the idle windows before choosing an idling_specific_dd map, see the workflow in iqm.cpc.compiler.dd.

  2. qubit_specific_dd — per-qubit DD. Maps qubit name to the DD sequence applied on that qubit, or None (no DD for this qubit). Qubits not in the map use the default DD strategy, if any.

  3. context["DDStrategy"], describing the global default DD strategy.

  4. DDStrategy built from the individual DDStrategy_* parameters. These are initialized to STANDARD_DD_STRATEGY in the settings tree, so the standard strategy is the default unless you change them.

Note

qubit_specific_dd and idling_specific_dd are compile-only settings: their values cannot be serialized (e.g. callables and dicts), so this pass removes them from context["settings"] when it finishes.

Parameters:
  • schedules (list[Schedule]) – Schedules representing the compiled circuits.

  • builder (ScheduleBuilder) – The ScheduleBuilder.

  • context (dict[str, Any]) – Compiler context.

  • dd_is_disabled (bool) – Set to False to enable dynamical decoupling.

  • qubit_specific_dd (dict[str, list[DDGateSequence] | None] | None) – Per-qubit DD map. Maps physical qubit name to the DD sequences applied to idle windows on that qubit, or None to mean no DD sequence is applied on that qubit. Qubits not in the map use the default DD strategy.

  • idling_specific_dd (dict[IdleWindowKey, list[DDGateSequence] | None] | IdleDDMapBuilder | None) – Per-idle-window DD. Either an IdleDDMap (dict from IdleWindowKey to a gate_sequences list or None), or an IdleDDMapBuilder callable fn(idle_windows, schedules, builder) -> IdleDDMap | None (useful for automated decisions — see the module docstring of iqm.cpc.compiler.dd).

  • DDStrategy_merge_contiguous_waits (bool) – Whether to merge contiguous waits (see DDStrategy).

  • DDStrategy_target_qubits (list[str] | None) – The qubits to which DD is applied (None means apply to every applicable qubit).

  • DDStrategy_skip_leading_wait (bool) – Whether to skip leading waits (see DDStrategy).

  • DDStrategy_skip_trailing_wait (bool) – Whether to skip trailing waits (see DDStrategy).

  • DDStrategy_gate_sequences_ratio (list[int]) – Minimal durations for the Wait to be replaced with the DD sequence (in PRX gate durations) in the DD sequence. Defaults to the ratios of STANDARD_DD_STRATEGY.

  • DDStrategy_gate_sequences_gate_pattern_xy (list[str]) – XY Gate patterns in the DD sequence. If you want to provide custom PRX angles instead of XY patterns, you must provide the DDStrategy in the Compiler context. Defaults to the gate patterns of STANDARD_DD_STRATEGY.

  • DDStrategy_gate_sequences_align (list[str]) –

    Alignments in the DD sequence (“asap”, “alap” or “center”). Defaults to the alignments of STANDARD_DD_STRATEGY.

    These three parameters are parallel lists defining the default DD strategy, and must have the same length. Setting any of them to an empty list means there is no default DD strategy.

Returns:

The schedules where applicable Waits are replaced with DD sequences.

Return type:

list[Schedule]