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.
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 spansduration + 1samples and its envelope is zero outside[0, duration). Frame changes and the phase trace shift with the channel.Digital gain
amp_scale.DAC quantization and clipping (
dac_bits), two’s complement: codes-2**(b-1) ... 2**(b-1) - 1withLSB = 2**-(b-1), so full scale+1clips to1 - LSB. This is the only clipping stage.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.Mixer:
I' = (1 + e/2) IandQ' = (1 - e/2)(Q cos(p) - I sin(p)). The image sideband only exists whenif_freq_hzis not zero; at baseband the imbalance is a static complex error.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:
objectDeterministic 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
epsilonwith|epsilon| < 1:I' = (1 + e/2) IandQ' = (1 - e/2) (Q cos(phi) - I sin(phi)).phase_error_deg (float) – Mixer I/Q phase error
phiin 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).Nonedisables quantization and clipping.bandwidth_mhz (float or None) – -3 dB bandwidth of a 1-pole low-pass in MHz.
Nonedisables it.
- delay_split(dt: float) tuple[int, float][source]¶
Split the delay into whole samples
kand a fractionfin[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 / dtis off by one for some whole-sample delays).
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:
objectControl-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, thendefault. 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
defaultentry. Unknown keys raiseValueErrorso typos do not pass silently.
- classmethod from_file(path: str | Path) HardwareProfile[source]¶
Load a profile from a
.jsonor.tomlfile.
- classmethod from_preset(name: str, seed: int | None = None) HardwareProfile[source]¶
Build one of the generic, illustrative presets (see
PRESET_NAMES).
- 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)to2**(bits-1) - 1withLSB = 2**-(bits-1), so the top code is1 - LSBand full scale+1clips 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.