Hardware Impairments API Reference

A HardwareProfile describes the control chain (AWG, mixer, cable) that drives the qubits. It is separate from Qiskit’s Target, which holds qubit-side data. Pass it as TargetWaveformSimulator(target, hardware_profile=profile) and the samples returned by get_snippet() carry the impairments; get_snippet(..., ideal=True) returns the ideal waveform, bit-identical to a simulator without a profile.

Warning

These are waveform impairments, not a fidelity prediction. The package does not evolve a Hamiltonian, so it reports no gate fidelities. Preset values are generic and illustrative, not datasheet numbers of any product. Hardware export should always use ideal=True.

Signal chain

The stages run in this fixed order on every sample. A stage whose parameters are neutral is skipped, so the ideal preset equals a simulator with no profile.

  1. Delay. The whole ideal channel signal (envelope, IF carrier and frame phase) is evaluated at t - delay. A whole-sample part is an exact index shift; a fractional part is evaluated analytically, so a pulse then spans duration + 1 samples and its envelope is zero outside [0, duration). Frame changes and the phase trace shift with the channel.

  2. Digital gain amp_scale.

  3. DAC quantization and clipping (dac_bits), two’s complement: codes -2**(b-1) ... 2**(b-1) - 1 with LSB = 2**-(b-1), so full scale +1 clips to 1 - LSB. This is the only clipping stage.

  4. Bandwidth: a 1-pole low-pass on I and Q. It has infinite memory, so windows that overlap agree to 1e-12 * max|x|, not bit-exactly.

  5. Mixer: I' = (1 + e/2) I and Q' = (1 - e/2)(Q cos(p) - I sin(p)). The image sideband only exists when if_freq_hz is not zero; at baseband the imbalance is a static complex error.

  6. DC offset (LO leakage) dc_i + 1j * dc_q.

Channel lookup

Profile keys are exact channel names (d0, m1, u(0,1)) or globs (d*, u(*)), matched case-sensitively. Precedence: exact name, then the first matching glob in insertion order, then default. The chosen entry is used whole. When loading a JSON or TOML file, keys left out of a channel entry are filled from the file’s default entry, and unknown keys raise ValueError.

delay_ns must be >= 0; express skew relative to the earliest channel.

from qiskit_waveform_sim import (
    ChannelImpairments, HardwareProfile, TargetWaveformSimulator, show_iq_oscilloscope,
)

profile = HardwareProfile.from_preset("iq_mixer_uncalibrated")
# or HardwareProfile.from_file("my_lab.toml")
# or HardwareProfile(default=ChannelImpairments(dac_bits=14),
#                    channels={"u(*)": ChannelImpairments(delay_ns=12.0, dac_bits=14)})

sim = TargetWaveformSimulator(backend.target, hardware_profile=profile).compile(qc)
sim.get_snippet("d0", 0, 1000)              # impaired
sim.get_snippet("d0", 0, 1000, ideal=True)  # ideal
show_iq_oscilloscope(sim, "d0", compare_ideal=True)

ChannelImpairments

class qiskit_waveform_sim.hardware.ChannelImpairments(delay_ns: float = 0.0, amp_scale: float = 1.0, gain_imbalance: float = 0.0, phase_error_deg: float = 0.0, dc_i: float = 0.0, dc_q: float = 0.0, dac_bits: int | None = None, bandwidth_mhz: float | None = None)[source]

Bases: object

Deterministic impairments of one control channel.

Parameters:
  • delay_ns (float) – Channel latency in ns, >= 0. Express skew relative to the earliest channel; a negative delay would move pulses before t = 0.

  • amp_scale (float) – Digital gain error applied before the DAC, > 0.

  • gain_imbalance (float) – Mixer I/Q gain imbalance epsilon with |epsilon| < 1: I' = (1 + e/2) I and Q' = (1 - e/2) (Q cos(phi) - I sin(phi)).

  • phase_error_deg (float) – Mixer I/Q phase error phi in degrees, |phi| < 90.

  • dc_i (float) – DC offset (LO leakage) added after the mixer, in units of full scale.

  • dc_q (float) – DC offset (LO leakage) added after the mixer, in units of full scale.

  • dac_bits (int or None) – DAC resolution (two’s complement, 2..32). None disables quantization and clipping.

  • bandwidth_mhz (float or None) – -3 dB bandwidth of a 1-pole low-pass in MHz. None disables it.

amp_scale: float = 1.0
bandwidth_mhz: float | None = None
dac_bits: int | None = None
dc_i: float = 0.0
dc_q: float = 0.0
delay_ns: float = 0.0
delay_split(dt: float) → tuple[int, float][source]

Split the delay into whole samples k and a fraction f in [0, 1).

Values within 1e-9 samples of an integer snap to it, so whole-sample delays are exact despite floating-point rounding (a plain floor of delay_ns * 1e-9 / dt is off by one for some whole-sample delays).

gain_imbalance: float = 0.0
property is_ideal: bool

True when every field is at its neutral default.

phase_error_deg: float = 0.0

HardwareProfile

class qiskit_waveform_sim.hardware.HardwareProfile(default: ChannelImpairments = <factory>, channels: dict[str, ~qiskit_waveform_sim.hardware.ChannelImpairments]=<factory>, seed: int | None = None)[source]

Bases: object

Control-hardware profile with per-channel overrides.

Channel keys are exact channel names (d0, m1, u(0,1)) or globs (d*, u(*)), matched case-sensitively. Precedence: exact name, then the first matching glob in insertion order, then default. The chosen entry is used whole; entries are not merged at lookup time.

Parameters:
  • default (ChannelImpairments) – Used for channels no key matches.

  • channels (dict[str, ChannelImpairments]) – Per-channel overrides.

  • seed (int, optional) – Seed for the stochastic impairments (Phase 2). Drawn once from system entropy when omitted, and stored so a saved file reproduces the run.

channels: dict[str, ChannelImpairments]
default: ChannelImpairments
for_channel(channel: str) → ChannelImpairments[source]

Impairments for channel: exact name > first matching glob > default.

classmethod from_dict(data: Mapping[str, Any]) → HardwareProfile[source]

Build a profile from a dict (the JSON/TOML layout).

Keys left out of a channel entry are filled from the default entry. Unknown keys raise ValueError so typos do not pass silently.

classmethod from_file(path: str | Path) → HardwareProfile[source]

Load a profile from a .json or .toml file.

classmethod from_preset(name: str, seed: int | None = None) → HardwareProfile[source]

Build one of the generic, illustrative presets (see PRESET_NAMES).

seed: int | None = None
to_dict() → dict[str, Any][source]

Plain-dict form with every field written out.

to_file(path: str | Path) → None[source]

Save the profile as JSON (TOML is read-only: the stdlib cannot write it).

validate_for_dt(dt: float) → None[source]

Check the parameters that depend on the sample period (Nyquist).

qiskit_waveform_sim.hardware.PRESET_NAMES: tuple[str, ...] = ('ideal', 'iq_mixer_uncalibrated', 'iq_mixer_calibrated', 'direct_rf', 'noisy_lab')

Built-in immutable sequence.

If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable’s items.

If the argument is a tuple, the return value is the same object.

Signal helpers

qiskit_waveform_sim.hardware.quantize_dac(wave: ndarray, bits: int) → ndarray[source]

Quantize I and Q separately to a bits-bit two’s-complement DAC.

Codes run from -2**(bits-1) to 2**(bits-1) - 1 with LSB = 2**-(bits-1), so the top code is 1 - LSB and full scale +1 clips there. This is the only clipping stage of the impairment chain.

qiskit_waveform_sim.hardware.lowpass(wave: ndarray, bandwidth_hz: float, dt: float) → ndarray[source]

1-pole low-pass y[n] = (1 - a) x[n] + a y[n-1] from zero initial state.

a = exp(-2 pi f_3dB dt); the DC gain is 1. Evaluated with a doubling scan (log2(N) vectorized passes), so no SciPy is needed.

qiskit_waveform_sim.hardware.lowpass_lookback(bandwidth_hz: float, dt: float) → int[source]

Samples of history after which the 1-pole filter’s initial state is below 1e-12.

A 1-pole IIR has infinite memory, so starting a window this many samples early agrees with the full-history response to 1e-12 * max|x|, not bit-exactly.

qiskit_waveform_sim.hardware.apply_iq_imbalance(wave: ndarray, gain_imbalance: float, phase_error_deg: float) → ndarray[source]

Apply mixer gain/phase imbalance: I' = (1+e/2) I, Q' = (1-e/2)(Q cos(p) - I sin(p)).