Generator package

Submodules

Devices module

class c3.generator.devices.AWG(**props)[source]

Bases: c3.generator.devices.Device

AWG device, transforms digital input to analog signal.

Parameters

logdir (str) – Filepath to store generated waveforms.

asdict() dict[source]
create_IQ(instr: c3.signal.gates.Instruction, chan: str) dict[source]

Construct the in-phase (I) and quadrature (Q) components of the signal. These are universal to either experiment or simulation. In the xperiment these will be routed to AWG and mixer electronics, while in the simulation they provide the shapes of the instruction fields to be added to the Hamiltonian.

Parameters
  • channel (str) – Identifier for the selected drive line.

  • components (dict) – Separate signals to be combined onto this drive line.

  • t_start (float) – Beginning of the signal.

  • t_end (float) – End of the signal.

Returns

Waveforms as I and Q components.

Return type

dict

create_IQ_pwc(instr: c3.signal.gates.Instruction, chan: str) dict[source]

Construct the in-phase (I) and quadrature (Q) components of the signal. These are universal to either experiment or simulation. In the xperiment these will be routed to AWG and mixer electronics, while in the simulation they provide the shapes of the instruction fields to be added to the Hamiltonian.

Parameters
  • channel (str) – Identifier for the selected drive line.

  • components (dict) – Separate signals to be combined onto this drive line.

  • t_start (float) – Beginning of the signal.

  • t_end (float) – End of the signal.

Returns

Waveforms as I and Q components.

Return type

dict

enable_drag()[source]
enable_drag_2()[source]
enable_pwc()[source]
get_I(line)[source]
get_Q(line)[source]
get_average_amp(line)[source]

Compute average and sum of the amplitudes. Used to estimate effective drive power for non-trivial shapes.

Returns

Average and sum.

Return type

tuple

log_shapes()[source]
class c3.generator.devices.Additive_Noise(**props)[source]

Bases: c3.generator.devices.Device

Noise applied to a signal

get_noise(sig)[source]
process(instr, chan, signal)[source]

Distort signal by adding noise.

class c3.generator.devices.Crosstalk(**props)[source]

Bases: c3.generator.devices.Device

Device to phenomenologically include crosstalk in the model by explicitly mixing drive lines.

Parameters

crosstalk_matrix (tf.constant) – Matrix description of how to mix drive channels.

Examples

xtalk = Crosstalk(
    name="crosstalk",
    channels=["TC1", "TC2"],
    crosstalk_matrix=Quantity(
        value=[[1, 0], [0, 1]],
        min_val=[[0, 0], [0, 0]],
        max_val=[[1, 1], [1, 1]],
        unit="",
    ),
)
process(signal: Dict[str, Any]) Dict[str, Any][source]

Mix channels in the input signal according to a crosstalk matrix.

Parameters

signal (Dict[str, Any]) –

Dictionary of several signals identified by their channel as dict keys, e.g.

signal = {
    "TC1": {"values": [0, 0.5, 1, 1, ...]},
    "TC2": {"values": [1, 1, 1, 1, ...],
}

Returns

signal

Return type

Dict[str, Any]

class c3.generator.devices.DC_Noise(**props)[source]

Bases: c3.generator.devices.Additive_Noise

Add a random constant offset to the signals

get_noise(sig)[source]
class c3.generator.devices.DC_Offset(**props)[source]

Bases: c3.generator.devices.Device

Noise applied to a signal

process(instr, chan, signal)[source]

Distort signal by adding noise.

class c3.generator.devices.Device(**props)[source]

Bases: c3.c3objs.C3obj

A Device that is part of the stack generating the instruction signals.

Parameters

resolution (np.float64) – Number of samples per second this device operates at.

asdict() Dict[str, Any][source]
calc_slice_num(t_start: numpy.float64, t_end: numpy.float64) None[source]

Effective number of time slices given start, end and resolution.

Parameters
  • t_start (np.float64) – Starting time for this device.

  • t_end (np.float64) – End time for this device.

create_ts(t_start: numpy.float64, t_end: numpy.float64, centered: bool = True) tensorflow.python.framework.constant_op.constant[source]

Compute time samples.

Parameters
  • t_start (np.float64) – Starting time for this device.

  • t_end (np.float64) – End time for this device.

  • centered (boolean) – Sample in the middle of an interval, otherwise at the beginning.

write_config(filepath: str) None[source]

Write dictionary to a HJSON file.

class c3.generator.devices.DigitalToAnalog(**props)[source]

Bases: c3.generator.devices.Device

Take the values at the awg resolution to the simulation resolution.

process(instr: c3.signal.gates.Instruction, chan: str, awg_signal: Dict[str, Any]) Dict[str, Any][source]

Resample the awg values to higher resolution.

Parameters
  • instr (Instruction) – The logical instruction or qubit operation for which the signal is generated.

  • chan (str) – Specifies which channel is being processed if needed.

  • awg_signal (dict) – Dictionary of several signals identified by their channel as dict keys.

Returns

Inphase and Quadrature compontent of the upsampled signal.

Return type

dict

class c3.generator.devices.ExponentialIIR(**props)[source]

Bases: c3.generator.devices.StepFuncFilter

Implement IIR filter with step response of the form s(t) = (1 + A * exp(-t / t_iir) )

Parameters
step_response_function(ts)[source]
class c3.generator.devices.Filter(**props)[source]

Bases: c3.generator.devices.Device

Apply a filter function to the signal.

process(instr: c3.signal.gates.Instruction, chan: str, Hz_signal: Dict[str, Any]) Dict[str, Any][source]

Apply a filter function to the signal.

class c3.generator.devices.FluxTuning(**props)[source]

Bases: c3.generator.devices.Device

Flux tunable qubit frequency.

Parameters
get_factor(phi)[source]
get_freq(phi)[source]
process(instr: c3.signal.gates.Instruction, chan: str, signal_in)[source]

Compute the qubit frequency resulting from an applied flux.

Parameters

signal (tf.float64) –

Returns

Qubit frequency.

Return type

tf.float64

class c3.generator.devices.FluxTuningLinear(**props)[source]

Bases: c3.generator.devices.Device

Flux tunable qubit frequency linear adjustment.

Parameters
frequency(signal: tf.float64) tensorflow.python.framework.constant_op.constant[source]

Compute the qubit frequency resulting from an applied flux.

Parameters

signal (tf.float64) –

Returns

Qubit frequency.

Return type

tf.float64

class c3.generator.devices.HighpassExponential(**props)[source]

Bases: c3.generator.devices.StepFuncFilter

Implement Highpass filter based on exponential with step response of the form s(t) = exp(-t / t_hp)

Parameters
step_response_function(ts)[source]
class c3.generator.devices.HighpassFilter(**props)[source]

Bases: c3.generator.devices.Device

Introduce a highpass filter

Parameters
  • cutoff (Quantity) – cutoff frequency of highpass filter

  • keep_mean (bool) – should the mean of the signal be restored

convolve(signal: list, resp_shape: list)[source]

Compute the convolution with a function.

Parameters
  • signal (list) – Potentially unlimited signal samples.

  • resp_shape (list) – Samples of the function to model limited bandwidth.

Returns

Processed signal.

Return type

tf.Tensor

process(instr, chan, iq_signal)[source]

Apply a highpass cutoff to an IQ signal.

Parameters

iq_signal (dict) – I and Q components of an AWG signal.

Returns

Filtered IQ signal.

Return type

dict

class c3.generator.devices.LO(**props)[source]

Bases: c3.generator.devices.Device

Local oscillator device, generates a constant oscillating signal.

process(instr: c3.signal.gates.Instruction, chan: str) dict[source]
class c3.generator.devices.LONoise(**props)[source]

Bases: c3.generator.devices.Device

Noise applied to the local oscillator

process(instr, chan, lo_signal)[source]

Distort signal by adding noise.

class c3.generator.devices.Mixer(**props)[source]

Bases: c3.generator.devices.Device

Mixer device, combines inputs from the local oscillator and the AWG.

process(instr: c3.signal.gates.Instruction, chan: str, in1: dict, in2: dict)[source]

Combine signal from AWG and LO.

Parameters
  • lo_signal (dict) – Local oscillator signal.

  • awg_signal (dict) – Waveform generator signal.

Returns

Mixed signal.

Return type

dict

class c3.generator.devices.Pink_Noise(**props)[source]

Bases: c3.generator.devices.Additive_Noise

Device creating pink noise, i.e. 1/f noise.

get_noise(sig)[source]
class c3.generator.devices.Readout(**props)[source]

Bases: c3.generator.devices.Device

Mimic the readout process by multiplying a state phase with a factor and offset.

Parameters
readout(phase)[source]

Apply the readout rescaling

Parameters

phase (tf.float64) – Raw phase of a quantum state

Returns

Rescaled readout value

Return type

tf.float64

class c3.generator.devices.Response(**props)[source]

Bases: c3.generator.devices.Device

Make the AWG signal physical by convolution with a Gaussian to limit bandwith.

Parameters

rise_time (Quantity) – Time constant for the gaussian convolution.

convolve(signal: list, resp_shape: list)[source]

Compute the convolution with a function.

Parameters
  • signal (list) – Potentially unlimited signal samples.

  • resp_shape (list) – Samples of the function to model limited bandwidth.

Returns

Processed signal.

Return type

tf.Tensor

process(instr, chan, iq_signal)[source]

Apply a Gaussian shaped limiting function to an IQ signal.

Parameters

iq_signal (dict) – I and Q components of an AWG signal.

Returns

Bandwidth limited IQ signal.

Return type

dict

class c3.generator.devices.ResponseFFT(**props)[source]

Bases: c3.generator.devices.Device

Make the AWG signal physical by convolution with a Gaussian to limit bandwith.

Parameters

rise_time (Quantity) – Time constant for the gaussian convolution.

process(instr, chan, iq_signal)[source]

Apply a Gaussian shaped limiting function to an IQ signal.

Parameters

iq_signal (dict) – I and Q components of an AWG signal.

Returns

Bandwidth limited IQ signal.

Return type

dict

class c3.generator.devices.SkinEffectResponse(**props)[source]

Bases: c3.generator.devices.StepFuncFilter

Implement Highpass filter based on exponential with step response of the form s(t) = exp(-t / t_hp)

Parameters
step_response_function(ts)[source]
class c3.generator.devices.StepFuncFilter(**props)[source]

Bases: c3.generator.devices.Device

Base class for filters that are based on the step response function Step function has to be defined explicetly

process(instr, chan, signal_in)[source]
step_response_function(ts)[source]
class c3.generator.devices.VoltsToHertz(**props)[source]

Bases: c3.generator.devices.Device

Convert the voltage signal to an amplitude to plug into the model Hamiltonian.

Parameters
  • V_to_Hz (Quantity) – Conversion factor.

  • offset (tf.float64) – Drive frequency offset.

process(instr: c3.signal.gates.Instruction, chan: str, mixed_signal: Dict[str, Any]) Dict[str, Any][source]

Transform signal from value of V to Hz.

Parameters

mixed_signal (tf.Tensor) – Waveform as line voltages after IQ mixing

Returns

Waveform as control amplitudes

Return type

tf.Tensor

c3.generator.devices.dev_reg_deco(func: Callable) Callable[source]

Decorator for making registry of functions

Generator module

Signal generation stack.

Contrary to most quanutm simulators, C^3 includes a detailed simulation of the control stack. Each component in the stack and its functions are simulated individually and combined here.

Example: A local oscillator and arbitrary waveform generator signal are put through via a mixer device to produce an effective modulated signal.

class c3.generator.generator.Generator(devices: Optional[dict] = None, chains: Optional[dict] = None, resolution: numpy.float64 = 0.0, callback: Optional[Callable] = None)[source]

Bases: object

Generator, creates signal from digital to what arrives to the chip.

Parameters
  • devices (list) – Physical or abstract devices in the signal processing chain.

  • resolution (np.float64) – Resolution at which continuous functions are sampled.

  • callback (Callable) – Function that is called after each device in the signal line.

asdict() dict[source]

Return a dictionary compatible with config files.

fromdict(cfg: dict) None[source]
generate_signals(instr: c3.signal.gates.Instruction) dict[source]

Perform the signal chain for a specified instruction, including local oscillator, AWG generation and IQ mixing.

Parameters

instr (Instruction) – Operation to be performed, e.g. logical gate.

Returns

Signal to be applied to the physical device.

Return type

dict

read_config(filepath: str) None[source]

Load a file and parse it to create a Generator object.

Parameters

filepath (str) – Location of the configuration file

write_config(filepath: str) None[source]

Write dictionary to a HJSON file.

Module contents