Ejemplo n.º 1
0
    def _add_parameters(self, num_ccio: int) -> None:
        """
        add CC native parameters
        """

        for vsm_ch in range(0, self._NUM_VSM_CH
                            ):  # NB: VSM channel starts from 0 on CC-light/QCC
            self.add_parameter(
                'vsm_rise_delay{}'.format(vsm_ch),
                label='VSM rise {} delay'.format(vsm_ch),
                docstring='Sets/gets the rise delay for VSM channel {}'.format(
                    vsm_ch),
                unit='833 ps',
                vals=vals.PermissiveInts(0, self._CCIO_MAX_VSM_DELAY),
                set_cmd=_gen_set_func_1par(self._set_vsm_rise_delay, vsm_ch),
                get_cmd=_gen_get_func_1par(self._get_vsm_rise_delay, vsm_ch))
            self.add_parameter(
                'vsm_fall_delay{}'.format(vsm_ch),
                label='VSM fall {} delay'.format(vsm_ch),
                docstring='Sets/gets the fall delay for VSM channel {}'.format(
                    vsm_ch),
                unit='833 ps',
                vals=vals.PermissiveInts(0, self._CCIO_MAX_VSM_DELAY),
                set_cmd=_gen_set_func_1par(self._set_vsm_fall_delay, vsm_ch),
                get_cmd=_gen_get_func_1par(self._get_vsm_fall_delay, vsm_ch))
Ejemplo n.º 2
0
    def _add_compatibility_parameters(self, num_ccio: int) -> None:
        """
        parameters for the end user, CC-light 'emulation'
        FIXME:  these are compatibility hacks to ease integration in the existing CC-light toolchain,
                richer functionality may be available via the native interface
        """

        # support for openql_helpers.py::compile()
        self.add_parameter(
            'eqasm_program',
            label='eQASM program (compatibility function)',
            docstring=
            'Uploads the program to the CC. Valid input is a string representing the filename.',
            set_cmd=self._eqasm_program,
            vals=vals.Strings())

        # support 'dio{}_out_delay' for device_object_CCL.py::prepare_timing()
        # NB: DIO starts from 1 on CC-light/QCC, but we use CCIO number starting from 0
        for ccio in range(0, num_ccio):
            if 1:
                # skip DIO delay setting for slots driving VSM. Note that vsm_channel_delay also sets DIO delay
                if ccio in self._ccio_slots_driving_vsm:  # skip VSM
                    continue
            self.add_parameter(
                'dio{}_out_delay'.format(ccio),
                label='Output Delay of DIO{}'.format(ccio),
                docstring=
                'This parameter determines the extra output delay introduced for the DIO{} channel (i.e. CCIO slot number)'
                .format(ccio),
                unit='20 ns',
                vals=vals.PermissiveInts(0, 31),  # FIXME: CC limit is 2^32-1
                set_cmd=_gen_set_func_1par(self._set_dio_delay, ccio)
                #                get_cmd=cmd + '?',
            )

        # support for 'vsm_channel_delay{}' for CCL_Transmon.py::_set_mw_vsm_delay(), also see calibrate_mw_vsm_delay()
        # NB: CC supports 1/1200 MHz ~= 833 ps resolution
        # NB: CC supports setting trailing edge delay separately
        # NB: on CCL, index is qubit, not channel
        # NB: supports single VSM only, use native parameter for >1 VSM
        for vsm_ch in range(0, self._NUM_VSM_CH
                            ):  # NB: VSM channel starts from 0 on CC-light/QCC
            self.add_parameter(
                'vsm_channel_delay{}'.format(vsm_ch),
                label='VSM Channel {} delay'.format(vsm_ch),
                docstring='Sets/gets the delay for VSM channel {}'.format(
                    vsm_ch),
                unit='2.5 ns',
                vals=vals.PermissiveInts(0, 127),
                set_cmd=_gen_set_func_1par(self._set_vsm_channel_delay, vsm_ch)
                #                get_cmd=_gen_get_func_1par(self._get_vsm_channel_delay, vsm_ch),
            )
def test_setting_int_with_float_not_close():
    parameter = Parameter(name='foobar',
                          set_cmd=None,
                          get_cmd=None,
                          set_parser=lambda x: int(round(x)),
                          vals=vals.PermissiveInts(0))

    a = 0
    b = 10
    values = np.linspace(a, b, b - a + 2)
    for i in values[1:-2]:
        with pytest.raises(TypeError):
            parameter(i)
def test_setting_int_with_float():
    parameter = Parameter(name='foobar',
                          set_cmd=None,
                          get_cmd=None,
                          set_parser=lambda x: int(round(x)),
                          vals=vals.PermissiveInts(0))

    a = 0
    b = 10
    values = np.linspace(a, b, b - a + 1)
    for i in values:
        parameter(i)
        a = parameter()
        assert isinstance(a, int)
Ejemplo n.º 5
0
 def setUp(self):
     self.parameter = Parameter(name='foobar',
                                set_cmd=None,
                                get_cmd=None,
                                set_parser=lambda x: int(round(x)),
                                vals=vals.PermissiveInts(0))
Ejemplo n.º 6
0
    def _add_waveform_parameters(self):
        """
        Adds the parameters required to generate the standard waveforms

        The following prefixes are used for waveform parameters
            sq
            cz
            czd
            mcz
            custom

        """
        self.add_parameter('sq_amp', initial_value=.5,
                           # units is part of the total range of AWG8
                           label='Square pulse amplitude',
                           unit='dac value', vals=vals.Numbers(),
                           parameter_class=ManualParameter)
        self.add_parameter('sq_length', unit='s',
                           label='Square pulse length',
                           initial_value=40e-9,
                           vals=vals.Numbers(0, 100e-6),
                           parameter_class=ManualParameter)

        self.add_parameter('cz_length', vals=vals.Numbers(),
                           unit='s', initial_value=35e-9,
                           parameter_class=ManualParameter)
        self.add_parameter('cz_lambda_2', vals=vals.Numbers(),
                           initial_value=0,
                           parameter_class=ManualParameter)
        self.add_parameter('cz_lambda_3', vals=vals.Numbers(),
                           initial_value=0,
                           parameter_class=ManualParameter)
        self.add_parameter('cz_theta_f', vals=vals.Numbers(),
                           unit='deg',
                           initial_value=80,
                           parameter_class=ManualParameter)

        self.add_parameter('czd_length_ratio', vals=vals.Numbers(0, 1),
                           initial_value=0.5,
                           parameter_class=ManualParameter)
        self.add_parameter(
            'czd_lambda_2',
            docstring='lambda_2 parameter of the negative part of the cz pulse'
            ' if set to np.nan will default to the value of the main parameter',
            vals=vals.MultiType(vals.Numbers(), NP_NANs()),
            initial_value=np.nan,
            parameter_class=ManualParameter)

        self.add_parameter(
            'czd_lambda_3',
            docstring='lambda_3 parameter of the negative part of the cz pulse'
            ' if set to np.nan will default to the value of the main parameter',
            vals=vals.MultiType(vals.Numbers(), NP_NANs()),
            initial_value=np.nan,
            parameter_class=ManualParameter)
        self.add_parameter(
            'czd_theta_f',
            docstring='theta_f parameter of the negative part of the cz pulse'
            ' if set to np.nan will default to the value of the main parameter',
            vals=vals.MultiType(vals.Numbers(), NP_NANs()),
            unit='deg',
            initial_value=np.nan,
            parameter_class=ManualParameter)

        self.add_parameter('cz_freq_01_max', vals=vals.Numbers(),
                           # initial value is chosen to not raise errors
                           initial_value=6e9,
                           unit='Hz', parameter_class=ManualParameter)
        self.add_parameter('cz_J2', vals=vals.Numbers(), unit='Hz',
                            # initial value is chosen to not raise errors
                           initial_value=15e6,
                           parameter_class=ManualParameter)
        self.add_parameter('cz_freq_interaction', vals=vals.Numbers(),
                           # initial value is chosen to not raise errors
                           initial_value=5e9,
                           unit='Hz',
                           parameter_class=ManualParameter)

        self.add_parameter('cz_phase_corr_length', unit='s',
                           initial_value=5e-9, vals=vals.Numbers(),
                           parameter_class=ManualParameter)
        self.add_parameter('cz_phase_corr_amp',
                           unit='dac value',
                           initial_value=0, vals=vals.Numbers(),
                           parameter_class=ManualParameter)

        self.add_parameter('czd_amp_ratio',
                           docstring='Amplitude ratio for double sided CZ gate',
                           initial_value=1,
                           vals=vals.Numbers(),
                           parameter_class=ManualParameter)

        self.add_parameter('czd_amp_offset',
                           docstring='used to add an offset to the negative '
                           ' pulse that is used in the net-zero cz gate',
                           initial_value=0,
                           unit='dac value',
                           vals=vals.Numbers(),
                           parameter_class=ManualParameter)

        self.add_parameter('czd_double_sided',
                           initial_value=False,
                           vals=vals.Bool(),
                           parameter_class=ManualParameter)

        self.add_parameter('mcz_nr_of_repeated_gates',
                           initial_value=1, vals=vals.PermissiveInts(1, 40),
                           parameter_class=ManualParameter)
        self.add_parameter('mcz_gate_separation', unit='s',
                           label='Gate separation',  initial_value=0,
                           docstring=('Separtion between the start of CZ gates'
                                      'in the "multi_cz" gate'),
                           parameter_class=ManualParameter,
                           vals=vals.Numbers(min_value=0))

        self.add_parameter(
            'custom_wf',
            initial_value=np.array([]),
            label='Custom waveform',
            docstring=('Specifies a custom waveform, note that '
                       '`custom_wf_length` is used to cut of the waveform if'
                       'it is set.'),
            parameter_class=ManualParameter,
            vals=vals.Arrays())
        self.add_parameter(
            'custom_wf_length',
            unit='s',
            label='Custom waveform length',
            initial_value=np.inf,
            docstring=('Used to determine at what sample the custom waveform '
                       'is forced to zero. This is used to facilitate easy '
                       'cryoscope measurements of custom waveforms.'),
            parameter_class=ManualParameter,
            vals=vals.Numbers(min_value=0))