def __init__( self, name: str, desc: str = " ", comment: str = " ", params: dict = {}, ): params_default = { 'freq': Qty( value=0.0, min_val=-1.0, max_val=+1.0, unit="V" ), 'framechange': Qty( value=0.0, min_val=-np.pi, max_val=np.pi, unit="rad" ) } params_default.update(params) super().__init__( name=name, desc=desc, comment=comment, params=params_default, )
def __init__( self, name: str, desc: str = " ", comment: str = " ", params: dict = {}, shape: types.FunctionType = None, ): super().__init__( name=name, desc=desc, comment=comment, params=params, ) self.shape = shape if 'amp' not in params: params['amp'] = Qty(value=0.0, min=-1.0, max=+1.0, unit="V") if 'delta' not in params: params['delta'] = Qty(value=0.0, min=-1.0, max=+1.0, unit="V") if 'freq_offset' not in params: params['freq_offset'] = Qty(value=0.0, min=-1.0, max=+1.0, unit='Hz 2pi') if 'xy_angle' not in params: params['xy_angle'] = Qty(value=0.0, min=-1.0, max=+1.0, unit='rad') if 't_final' not in params: params['t_final'] = Qty(value=0.0, min=-1.0, max=+1.0, unit="s")
def test_AWG_freq_offset() -> None: offset = 53e6 rect.params["freq_offset"] = Qty(offset, "Hz 2pi") rect.params["xy_angle"] = Qty(0, "pi") sigs = generator.generate_signals(rectangle) correct_signal = np.cos(2 * np.pi * (lo_freq_q1 + offset) * sigs["d1"]["ts"]) assert (sigs["d1"]["values"].numpy() - correct_signal < 1e-9).all()
def test_AWG_phase_shift() -> None: phase = 0.5 rect.params["freq_offset"] = Qty(0, "Hz 2pi") rect.params["xy_angle"] = Qty(phase, "pi") sigs = generator.generate_signals(rectangle) correct_signal = np.cos(2 * np.pi * lo_freq_q1 * sigs["d1"]["ts"] + phase * np.pi) print(sigs["d1"]["values"]) np.testing.assert_allclose( sigs["d1"]["values"].numpy(), correct_signal, atol=1e-9 * np.max(sigs["d1"]["values"]), )
def drag(t, params): """Second order gaussian with fixed time/sigma ratio.""" DeprecationWarning("Using standard width. Better use drag_sigma.") params['sigma'] = Qty(value=params['t_final'].get_value() / 4, min_val=params['t_final'].get_value() / 8, max_val=params['t_final'].get_value() / 2, unit=params['t_final'].unit) return drag_sigma(t, params)
def drag(t, params): """Second order gaussian with fixed time/sigma ratio.""" params["sigma"] = Qty( value=params["t_final"].get_value() / 4, min_val=params["t_final"].get_value() / 8, max_val=params["t_final"].get_value() / 2, unit=params["t_final"].unit, ) return drag_sigma(t, params)
def __init__( self, name: str, desc: str = " ", comment: str = " ", params: dict = {}, shape: types.FunctionType = None, ): if isinstance(shape, str): self.shape = envelopes[shape] else: self.shape = shape params_default = { 'amp': Qty(value=0.0, min_val=-1.0, max_val=+1.0, unit="V"), 'delta': Qty(value=0.0, min_val=-5.0, max_val=+5.0, unit="V"), 'freq_offset': Qty(value=0.0, min_val=-1.0, max_val=+1.0, unit='Hz 2pi'), 'xy_angle': Qty(value=0.0, min_val=-1.0, max_val=+1.0, unit='rad'), 'sigma': Qty(value=5e-9, min_val=-2.0, max_val=+2.0, unit="s"), 't_final': Qty(value=0.0, min_val=-1.0, max_val=+1.0, unit="s") } params_default.update(params) super().__init__( name=name, desc=desc, comment=comment, params=params_default, )
def __init__( self, name: str, desc: str = " ", comment: str = " ", params: dict = {}, shape: types.FunctionType = None, ): if isinstance(shape, str): self.shape = envelopes[shape] else: self.shape = shape default_params = { "amp": Qty(value=0.0, min_val=-1.0, max_val=+1.0, unit="V"), "delta": Qty(value=0.0, min_val=-5.0, max_val=+5.0, unit="V"), "freq_offset": Qty(value=0.0, min_val=-1.0, max_val=+1.0, unit="Hz 2pi"), "xy_angle": Qty(value=0.0, min_val=-1.0, max_val=+1.0, unit="rad"), "sigma": Qty(value=5e-9, min_val=-2.0, max_val=+2.0, unit="s"), "t_final": Qty(value=0.0, min_val=-1.0, max_val=+1.0, unit="s"), } default_params.update(params) super().__init__( name=name, desc=desc, comment=comment, params=default_params, )
def test_FluxTuning(): flux_tune = devices.FluxTuning( name="flux_tune", phi_0=Qty(phi_0_tc), phi=Qty(value=0, min_val=-phi_0_tc, max_val=phi_0_tc), omega_0=Qty(freq_tc), anhar=Qty(anhar_TC), d=Qty(d), ) transmon = chip.Transmon( name="transmon", hilbert_dim=3, freq=Qty(freq_tc), phi=Qty(value=0, min_val=-1.5 * phi_0_tc, max_val=1.5 * phi_0_tc), phi_0=Qty(phi_0_tc), d=Qty(d), anhar=Qty(anhar_TC), ) bias_phis = [0, 0.2] phis = np.linspace(-1, 1, 10) * phi_0_tc for bias_phi in bias_phis: flux_tune.params["phi"].set_value(bias_phi) signal = {"ts": np.linspace(0, 1, 10), "values": phis} signal_out = flux_tune.process(None, None, signal) flux_tune_frequencies = signal_out["values"].numpy() transmon_frequencies = [] transmon.params["phi"].set_value(bias_phi) bias_freq = transmon.get_freq() for phi in phis + bias_phi: transmon.params["phi"].set_value(phi) transmon_frequencies.append(transmon.get_freq()) transmon_diff_freq = np.array(transmon_frequencies) - bias_freq assert (np.max(np.abs(flux_tune_frequencies - transmon_diff_freq)) < 1e-15 * freq_tc)
def gaussian(t, params): """ Normalized gaussian with fixed time/sigma ratio. Parameters ---------- params : dict t_final : float Total length of the Gaussian. """ DeprecationWarning("Using standard width. Better use gaussian_sigma.") params['sigma'] = Qty(value=params['t_final'].get_value() / 6, min_val=params['t_final'].get_value() / 8, max_val=params['t_final'].get_value() / 4, unit=params['t_final'].unit) return gaussian_sigma(t, params)
def gaussian(t, params): """ Normalized gaussian with fixed time/sigma ratio. Parameters ---------- params : dict t_final : float Total length of the Gaussian. """ params["sigma"] = Qty( value=params["t_final"].get_value() / 6, min_val=params["t_final"].get_value() / 8, max_val=params["t_final"].get_value() / 4, unit=params["t_final"].unit, ) return gaussian_sigma(t, params)
def change_pi12_amp(self, amp): t_final = self.pmap.instructions['Id'].t_end sideband = 50e6 gauss_params_pi = { "amp": Qty(value=amp, min_val=amp * 0.9, max_val=amp * 1.1, unit="V"), "t_final": Qty(value=t_final, min_val=0.5 * t_final, max_val=1.5 * t_final, unit="s"), "sigma": Qty(value=t_final / 4, min_val=t_final / 8, max_val=t_final / 2, unit="s"), "xy_angle": Qty(value=0.0, min_val=-0.5 * np.pi, max_val=2.5 * np.pi, unit="rad"), "freq_offset": Qty( value=-sideband - 0.5e6, min_val=-60 * 1e6, max_val=-40 * 1e6, unit="Hz 2pi", ), "delta": Qty(value=-1, min_val=-5, max_val=3, unit=""), } gauss_env_pi = pulse.Envelope( name="gauss", desc="Gaussian comp for single-qubit gates", params=gauss_params_pi, shape=envelopes.gaussian_nonorm, ) RXp12 = gates.Instruction(name="RXp12", t_start=0.0, t_end=t_final, channels=["d1"]) RXp12.add_component(gauss_env_pi, "d1") RXp12.add_component( self.pmap.instructions['RXp12'].comps['d1']['carrier'], "d1") #reuse carrier self.pmap.instructions['RXp12'] = RXp12 return RXp12
def two_qubits() -> float: """script for setting up two qubits and optimising a simple gate Returns ------- float result of optimisation run """ qubit_lvls = 3 freq_q1 = 5e9 * 2 * np.pi anhar_q1 = -210e6 * 2 * np.pi t1_q1 = 27e-6 t2star_q1 = 39e-6 qubit_temp = 50e-3 q1 = chip.Qubit(name="Q1", desc="Qubit 1", freq=Qty(value=freq_q1, min=4.995e9 * 2 * np.pi, max=5.005e9 * 2 * np.pi, unit='Hz 2pi'), anhar=Qty(value=anhar_q1, min=-380e6 * 2 * np.pi, max=-120e6 * 2 * np.pi, unit='Hz 2pi'), hilbert_dim=qubit_lvls, t1=Qty(value=t1_q1, min=1e-6, max=90e-6, unit='s'), t2star=Qty(value=t2star_q1, min=10e-6, max=90e-3, unit='s'), temp=Qty(value=qubit_temp, min=0.0, max=0.12, unit='K')) freq_q2 = 5.6e9 * 2 * np.pi anhar_q2 = -240e6 * 2 * np.pi t1_q2 = 23e-6 t2star_q2 = 31e-6 q2 = chip.Qubit(name="Q2", desc="Qubit 2", freq=Qty(value=freq_q2, min=5.595e9 * 2 * np.pi, max=5.605e9 * 2 * np.pi, unit='Hz 2pi'), anhar=Qty(value=anhar_q2, min=-380e6 * 2 * np.pi, max=-120e6 * 2 * np.pi, unit='Hz 2pi'), hilbert_dim=qubit_lvls, t1=Qty(value=t1_q2, min=1e-6, max=90e-6, unit='s'), t2star=Qty(value=t2star_q2, min=10e-6, max=90e-6, unit='s'), temp=Qty(value=qubit_temp, min=0.0, max=0.12, unit='K')) coupling_strength = 20e6 * 2 * np.pi q1q2 = chip.Coupling(name="Q1-Q2", desc="coupling", comment="Coupling qubit 1 to qubit 2", connected=["Q1", "Q2"], strength=Qty(value=coupling_strength, min=-1 * 1e3 * 2 * np.pi, max=200e6 * 2 * np.pi, unit='Hz 2pi'), hamiltonian_func=hamiltonians.int_XX) drive = chip.Drive(name="d1", desc="Drive 1", comment="Drive line 1 on qubit 1", connected=["Q1"], hamiltonian_func=hamiltonians.x_drive) drive2 = chip.Drive(name="d2", desc="Drive 2", comment="Drive line 2 on qubit 2", connected=["Q2"], hamiltonian_func=hamiltonians.x_drive) m00_q1 = 0.97 # Prop to read qubit 1 state 0 as 0 m01_q1 = 0.04 # Prop to read qubit 1 state 0 as 1 m00_q2 = 0.96 # Prop to read qubit 2 state 0 as 0 m01_q2 = 0.05 # Prop to read qubit 2 state 0 as 1 one_zeros = np.array([0] * qubit_lvls) zero_ones = np.array([1] * qubit_lvls) one_zeros[0] = 1 zero_ones[0] = 0 val1 = one_zeros * m00_q1 + zero_ones * m01_q1 val2 = one_zeros * m00_q2 + zero_ones * m01_q2 min = one_zeros * 0.8 + zero_ones * 0.0 max = one_zeros * 1.0 + zero_ones * 0.2 confusion_row1 = Qty(value=val1, min=min, max=max, unit="") confusion_row2 = Qty(value=val2, min=min, max=max, unit="") conf_matrix = tasks.ConfusionMatrix(Q1=confusion_row1, Q2=confusion_row2) init_temp = 50e-3 init_ground = tasks.InitialiseGround( init_temp=Qty(value=init_temp, min=-0.001, max=0.22, unit='K')) model = Mdl( [q1, q2], # Individual, self-contained components [drive, drive2, q1q2], # Interactions between components [conf_matrix, init_ground] # SPAM processing ) model.set_lindbladian(False) model.set_dressed(True) sim_res = 100e9 # Resolution for numerical simulation awg_res = 2e9 # Realistic, limited resolution of an AWG lo = devices.LO(name='lo', resolution=sim_res) awg = devices.AWG(name='awg', resolution=awg_res) mixer = devices.Mixer(name='mixer') resp = devices.Response(name='resp', rise_time=Qty(value=0.3e-9, min=0.05e-9, max=0.6e-9, unit='s'), resolution=sim_res) dig_to_an = devices.Digital_to_Analog(name="dac", resolution=sim_res) v2hz = 1e9 v_to_hz = devices.Volts_to_Hertz(name='v_to_hz', V_to_Hz=Qty(value=v2hz, min=0.9e9, max=1.1e9, unit='Hz 2pi/V')) generator = Gnr([lo, awg, mixer, v_to_hz, dig_to_an, resp]) import c3.signal.gates as gates gateset = gates.GateSet() t_final = 7e-9 # Time for single qubit gates sideband = 50e6 * 2 * np.pi gauss_params_single = { 'amp': Qty(value=0.5, min=0.4, max=0.6, unit="V"), 't_final': Qty(value=t_final, min=0.5 * t_final, max=1.5 * t_final, unit="s"), 'sigma': Qty(value=t_final / 4, min=t_final / 8, max=t_final / 2, unit="s"), 'xy_angle': Qty(value=0.0, min=-0.5 * np.pi, max=2.5 * np.pi, unit='rad'), 'freq_offset': Qty(value=-sideband - 3e6 * 2 * np.pi, min=-56 * 1e6 * 2 * np.pi, max=-52 * 1e6 * 2 * np.pi, unit='Hz 2pi'), 'delta': Qty(value=-1, min=-5, max=3, unit="") } gauss_env_single = pulse.Envelope( name="gauss", desc="Gaussian comp for single-qubit gates", params=gauss_params_single, shape=envelopes.gaussian_nonorm) nodrive_env = pulse.Envelope(name="no_drive", params={ 't_final': Qty(value=t_final, min=0.5 * t_final, max=1.5 * t_final, unit="s") }, shape=envelopes.no_drive) lo_freq_q1 = 5e9 * 2 * np.pi + sideband carrier_parameters = { 'freq': Qty(value=lo_freq_q1, min=4.5e9 * 2 * np.pi, max=6e9 * 2 * np.pi, unit='Hz 2pi'), 'framechange': Qty(value=0.0, min=-np.pi, max=3 * np.pi, unit='rad') } carr = pulse.Carrier(name="carrier", desc="Frequency of the local oscillator", params=carrier_parameters) lo_freq_q2 = 5.6e9 * 2 * np.pi + sideband carr_2 = copy.deepcopy(carr) carr_2.params['freq'].set_value(lo_freq_q2) X90p_q1 = gates.Instruction(name="X90p", t_start=0.0, t_end=t_final, channels=["d1"]) X90p_q2 = gates.Instruction(name="X90p", t_start=0.0, t_end=t_final, channels=["d2"]) QId_q1 = gates.Instruction(name="Id", t_start=0.0, t_end=t_final, channels=["d1"]) QId_q2 = gates.Instruction(name="Id", t_start=0.0, t_end=t_final, channels=["d2"]) X90p_q1.add_component(gauss_env_single, "d1") X90p_q1.add_component(carr, "d1") QId_q1.add_component(nodrive_env, "d1") QId_q1.add_component(copy.deepcopy(carr), "d1") X90p_q2.add_component(copy.deepcopy(gauss_env_single), "d2") X90p_q2.add_component(carr_2, "d2") QId_q2.add_component(copy.deepcopy(nodrive_env), "d2") QId_q2.add_component(copy.deepcopy(carr_2), "d2") QId_q1.comps['d1']['carrier'].params['framechange'].set_value( (-sideband * t_final) % (2 * np.pi)) QId_q2.comps['d2']['carrier'].params['framechange'].set_value( (-sideband * t_final) % (2 * np.pi)) Y90p_q1 = copy.deepcopy(X90p_q1) Y90p_q1.name = "Y90p" X90m_q1 = copy.deepcopy(X90p_q1) X90m_q1.name = "X90m" Y90m_q1 = copy.deepcopy(X90p_q1) Y90m_q1.name = "Y90m" Y90p_q1.comps['d1']['gauss'].params['xy_angle'].set_value(0.5 * np.pi) X90m_q1.comps['d1']['gauss'].params['xy_angle'].set_value(np.pi) Y90m_q1.comps['d1']['gauss'].params['xy_angle'].set_value(1.5 * np.pi) Q1_gates = [QId_q1, X90p_q1, Y90p_q1, X90m_q1, Y90m_q1] Y90p_q2 = copy.deepcopy(X90p_q2) Y90p_q2.name = "Y90p" X90m_q2 = copy.deepcopy(X90p_q2) X90m_q2.name = "X90m" Y90m_q2 = copy.deepcopy(X90p_q2) Y90m_q2.name = "Y90m" Y90p_q2.comps['d2']['gauss'].params['xy_angle'].set_value(0.5 * np.pi) X90m_q2.comps['d2']['gauss'].params['xy_angle'].set_value(np.pi) Y90m_q2.comps['d2']['gauss'].params['xy_angle'].set_value(1.5 * np.pi) Q2_gates = [QId_q2, X90p_q2, Y90p_q2, X90m_q2, Y90m_q2] all_1q_gates_comb = [] for g1 in Q1_gates: for g2 in Q2_gates: g = gates.Instruction(name="NONE", t_start=0.0, t_end=t_final, channels=[]) g.name = g1.name + ":" + g2.name channels = [] channels.extend(g1.comps.keys()) channels.extend(g2.comps.keys()) for chan in channels: g.comps[chan] = {} if chan in g1.comps: g.comps[chan].update(g1.comps[chan]) if chan in g2.comps: g.comps[chan].update(g2.comps[chan]) all_1q_gates_comb.append(g) for gate in all_1q_gates_comb: gateset.add_instruction(gate) exp = Exp(model=model, generator=generator, gateset=gateset) exp.opt_gates = ['X90p:Id', 'Id:Id'] gates = exp.get_gates() psi_init = [[0] * 9] psi_init[0][0] = 1 init_state = tf.transpose(tf.constant(psi_init, tf.complex128)) barely_a_seq = ['X90p:Id'] barely_a_seq * 10 generator.devices['awg'].enable_drag_2() opt_gates = ["X90p:Id"] gateset_opt_map = [[ ("X90p:Id", "d1", "gauss", "amp"), ], [ ("X90p:Id", "d1", "gauss", "freq_offset"), ], [ ("X90p:Id", "d1", "gauss", "xy_angle"), ], [ ("X90p:Id", "d1", "gauss", "delta"), ]] opt = C1(dir_path="/tmp/c3log/", fid_func=fidelities.average_infid_set, fid_subspace=["Q1", "Q2"], gateset_opt_map=gateset_opt_map, opt_gates=opt_gates, algorithm=algorithms.lbfgs, options={"maxfun": 10}, run_name="better_X90") opt.set_exp(exp) opt.optimize_controls() return (opt.current_best_goal)
def create_experiment(): lindblad = False dressed = True qubit_lvls = 3 freq_q1 = 5e9 * 2 * np.pi freq_q2 = 5.6e9 * 2 * np.pi anhar_q1 = -210e6 * 2 * np.pi anhar_q2 = -240e6 * 2 * np.pi coupling_strength = 20e6 * 2 * np.pi t1_q1 = 27e-6 t1_q2 = 23e-6 t2star_q1 = 39e-6 t2star_q2 = 31e-6 init_temp = 0 qubit_temp = 0 t_final = 7e-9 # Time for single qubit gates sim_res = 100e9 awg_res = 2e9 sideband = 50e6 * 2 * np.pi lo_freq_q1 = 5e9 * 2 * np.pi + sideband lo_freq_q2 = 5.6e9 * 2 * np.pi + sideband # ### MAKE MODEL q1 = chip.Qubit( name="Q1", desc="Qubit 1", freq=Qty( value=freq_q1, min_val=4.995e9 * 2 * np.pi, max_val=5.005e9 * 2 * np.pi, unit="Hz 2pi", ), anhar=Qty( value=anhar_q1, min_val=-380e6 * 2 * np.pi, max_val=-120e6 * 2 * np.pi, unit="Hz 2pi", ), hilbert_dim=qubit_lvls, t1=Qty(value=t1_q1, min_val=1e-6, max_val=90e-6, unit="s"), t2star=Qty(value=t2star_q1, min_val=10e-6, max_val=90e-6, unit="s"), temp=Qty(value=qubit_temp, min_val=0.0, max_val=0.12, unit="K"), ) q2 = chip.Qubit( name="Q2", desc="Qubit 2", freq=Qty( value=freq_q2, min_val=5.595e9 * 2 * np.pi, max_val=5.605e9 * 2 * np.pi, unit="Hz 2pi", ), anhar=Qty( value=anhar_q2, min_val=-380e6 * 2 * np.pi, max_val=-120e6 * 2 * np.pi, unit="Hz 2pi", ), hilbert_dim=qubit_lvls, t1=Qty(value=t1_q2, min_val=1e-6, max_val=90e-6, unit="s"), t2star=Qty(value=t2star_q2, min_val=10e-6, max_val=90e-6, unit="s"), temp=Qty(value=qubit_temp, min_val=0.0, max_val=0.12, unit="K"), ) q1q2 = chip.Coupling( name="Q1-Q2", desc="coupling", comment="Coupling qubit 1 to qubit 2", connected=["Q1", "Q2"], strength=Qty( value=coupling_strength, min_val=-1 * 1e3 * 2 * np.pi, max_val=200e6 * 2 * np.pi, unit="Hz 2pi", ), hamiltonian_func=hamiltonians.int_XX, ) drive = chip.Drive( name="d1", desc="Drive 1", comment="Drive line 1 on qubit 1", connected=["Q1"], hamiltonian_func=hamiltonians.x_drive, ) drive2 = chip.Drive( name="d2", desc="Drive 2", comment="Drive line 2 on qubit 2", connected=["Q2"], hamiltonian_func=hamiltonians.x_drive, ) phys_components = [q1, q2] line_components = [drive, drive2, q1q2] init_ground = tasks.InitialiseGround( init_temp=Qty(value=init_temp, min_val=-0.001, max_val=0.22, unit="K")) task_list = [init_ground] model = Mdl(phys_components, line_components, task_list) model.set_lindbladian(lindblad) model.set_dressed(dressed) # ### MAKE GENERATOR generator = Gnr( devices={ "LO": devices.LO(name="lo", resolution=sim_res, outputs=1), "AWG": devices.AWG(name="awg", resolution=awg_res, outputs=1), "DigitalToAnalog": devices.DigitalToAnalog(name="dac", resolution=sim_res, inputs=1, outputs=1), "Response": devices.Response( name="resp", rise_time=Qty(value=0.3e-9, min_val=0.05e-9, max_val=0.6e-9, unit="s"), resolution=sim_res, inputs=1, outputs=1, ), "Mixer": devices.Mixer(name="mixer", inputs=2, outputs=1), "VoltsToHertz": devices.VoltsToHertz( name="v_to_hz", V_to_Hz=Qty(value=1e9, min_val=0.9e9, max_val=1.1e9, unit="Hz/V"), inputs=1, outputs=1, ), }, chains={ "d1": [ "LO", "AWG", "DigitalToAnalog", "Response", "Mixer", "VoltsToHertz" ], "d2": [ "LO", "AWG", "DigitalToAnalog", "Response", "Mixer", "VoltsToHertz" ], }, ) generator.devices["awg"].enable_drag_2() # ### MAKE GATESET gateset = gates.GateSet() gauss_params_single = { "amp": Qty(value=0.45, min_val=0.4, max_val=0.6, unit="V"), "t_final": Qty(value=t_final, min_val=0.5 * t_final, max_val=1.5 * t_final, unit="s"), "sigma": Qty(value=t_final / 4, min_val=t_final / 8, max_val=t_final / 2, unit="s"), "xy_angle": Qty(value=0.0, min_val=-0.5 * np.pi, max_val=2.5 * np.pi, unit="rad"), "freq_offset": Qty( value=-sideband - 0.5e6 * 2 * np.pi, min_val=-53 * 1e6 * 2 * np.pi, max_val=-47 * 1e6 * 2 * np.pi, unit="Hz 2pi", ), "delta": Qty(value=-1, min_val=-5, max_val=3, unit=""), } gauss_env_single = pulse.Envelope( name="gauss", desc="Gaussian comp for single-qubit gates", params=gauss_params_single, shape=envelopes.gaussian_nonorm, ) nodrive_env = pulse.Envelope( name="no_drive", params={ "t_final": Qty(value=t_final, min_val=0.5 * t_final, max_val=1.5 * t_final, unit="s") }, shape=envelopes.no_drive, ) carrier_parameters = { "freq": Qty( value=lo_freq_q1, min_val=4.5e9 * 2 * np.pi, max_val=6e9 * 2 * np.pi, unit="Hz 2pi", ), "framechange": Qty(value=0.0, min_val=-np.pi, max_val=3 * np.pi, unit="rad"), } carr = pulse.Carrier( name="carrier", desc="Frequency of the local oscillator", params=carrier_parameters, ) carr_2 = copy.deepcopy(carr) carr_2.params["freq"].set_value(lo_freq_q2) RX90p_q1 = gates.Instruction(name="RX90p", t_start=0.0, t_end=t_final, channels=["d1"]) RX90p_q2 = gates.Instruction(name="RX90p", t_start=0.0, t_end=t_final, channels=["d2"]) QId_q1 = gates.Instruction(name="Id", t_start=0.0, t_end=t_final, channels=["d1"]) QId_q2 = gates.Instruction(name="Id", t_start=0.0, t_end=t_final, channels=["d2"]) RX90p_q1.add_component(gauss_env_single, "d1") RX90p_q1.add_component(carr, "d1") QId_q1.add_component(nodrive_env, "d1") QId_q1.add_component(copy.deepcopy(carr), "d1") QId_q1.comps["d1"]["carrier"].params["framechange"].set_value( (-sideband * t_final) % (2 * np.pi)) Y90p_q1 = copy.deepcopy(RX90p_q1) Y90p_q1.name = "RY90p" X90m_q1 = copy.deepcopy(RX90p_q1) X90m_q1.name = "RX90m" Y90m_q1 = copy.deepcopy(RX90p_q1) Y90m_q1.name = "RY90m" Y90p_q1.comps["d1"]["gauss"].params["xy_angle"].set_value(0.5 * np.pi) X90m_q1.comps["d1"]["gauss"].params["xy_angle"].set_value(np.pi) Y90m_q1.comps["d1"]["gauss"].params["xy_angle"].set_value(1.5 * np.pi) Q1_gates = [QId_q1, RX90p_q1, Y90p_q1, X90m_q1, Y90m_q1] RX90p_q2.add_component(copy.deepcopy(gauss_env_single), "d2") RX90p_q2.add_component(carr_2, "d2") QId_q2.add_component(copy.deepcopy(nodrive_env), "d2") QId_q2.add_component(copy.deepcopy(carr_2), "d2") QId_q2.comps["d2"]["carrier"].params["framechange"].set_value( (-sideband * t_final) % (2 * np.pi)) Y90p_q2 = copy.deepcopy(RX90p_q2) Y90p_q2.name = "RY90p" X90m_q2 = copy.deepcopy(RX90p_q2) X90m_q2.name = "RX90m" Y90m_q2 = copy.deepcopy(RX90p_q2) Y90m_q2.name = "RY90m" Y90p_q2.comps["d2"]["gauss"].params["xy_angle"].set_value(0.5 * np.pi) X90m_q2.comps["d2"]["gauss"].params["xy_angle"].set_value(np.pi) Y90m_q2.comps["d2"]["gauss"].params["xy_angle"].set_value(1.5 * np.pi) Q2_gates = [QId_q2, RX90p_q2, Y90p_q2, X90m_q2, Y90m_q2] all_1q_gates_comb = [] for g1 in Q1_gates: for g2 in Q2_gates: g = gates.Instruction(name="NONE", t_start=0.0, t_end=t_final, channels=[]) g.name = g1.name + ":" + g2.name channels = [] channels.extend(g1.comps.keys()) channels.extend(g2.comps.keys()) for chan in channels: g.comps[chan] = {} if chan in g1.comps: g.comps[chan].update(g1.comps[chan]) if chan in g2.comps: g.comps[chan].update(g2.comps[chan]) all_1q_gates_comb.append(g) for gate in all_1q_gates_comb: gateset.add_instruction(gate) # ### MAKE EXPERIMENT exp = Exp(model=model, generator=generator, gateset=gateset) return exp
awg_res = 2.4e9 cphase_time = 100e-9 # Two qubit gate flux_freq = 829 * 1e6 offset = 0 * 1e6 fluxamp = 0.1 * phi_0_tc t_down = cphase_time - 5e-9 xy_angle = 0.3590456701578104 framechange_q1 = 0.725 * np.pi framechange_q2 = 1.221 * np.pi # ### MAKE MODEL q1 = chip.Qubit(name="Q1", desc="Qubit 1", freq=Qty(value=freq_q1, min_val=5.0e9, max_val=8.0e9, unit='Hz 2pi'), anhar=Qty(value=anhar_q1, min_val=-380e6, max_val=-120e6, unit='Hz 2pi'), hilbert_dim=q1_lvls, t1=Qty(value=t1_q1, min_val=5e-6, max_val=90e-6, unit='s'), t2star=Qty(value=t2star_q1, min_val=10e-6, max_val=90e-6, unit='s'), temp=Qty(value=init_temp, min_val=0.0, max_val=0.12, unit='K')) q2 = chip.Qubit(name="Q2", desc="Qubit 2", freq=Qty(value=freq_q2,
import c3.libraries.fidelities as fidelities import c3.libraries.envelopes as envelopes from c3.optimizers.c1_robust import C1_robust qubit_lvls = 3 freq_q1 = 5e9 anhar_q1 = -210e6 t1_q1 = 27e-6 t2star_q1 = 39e-6 qubit_temp = 50e-3 q1 = chip.Qubit( name="Q1", desc="Qubit 1", freq=Qty(value=freq_q1, min_val=4.995e9, max_val=5.005e9, unit="Hz 2pi"), anhar=Qty(value=anhar_q1, min_val=-380e6, max_val=-120e6, unit="Hz 2pi"), hilbert_dim=qubit_lvls, t1=Qty(value=t1_q1, min_val=1e-6, max_val=90e-6, unit="s"), t2star=Qty(value=t2star_q1, min_val=10e-6, max_val=90e-3, unit="s"), temp=Qty(value=qubit_temp, min_val=0.0, max_val=0.12, unit="K"), ) drive = chip.Drive( name="d1", desc="Drive 1", comment="Drive line 1 on qubit 1", connected=["Q1"], hamiltonian_func=hamiltonians.x_drive, )
lvls1 = 6 lvls2 = 4 anhar1 = -200e6 anhar2 = -300e6 cut_excitations = 4 coupling_strength = 100e6 sim_res = 20e9 awg_res = 5e9 fluxamp = 0.3 cphase_time = 1e-9 q1 = TransmonExpanded( name="Qubit1", freq=Qty(value=freq_q1, min_val=0.0e9, max_val=10.0e9, unit="Hz 2pi"), phi=Qty(value=fluxpoint1, min_val=-5.0 * phi_0, max_val=5.0 * phi_0, unit="Phi0"), phi_0=Qty(value=phi_0, min_val=phi_0 * 0.9, max_val=phi_0 * 1.1, unit="Phi0"), d=Qty(value=d1, min_val=d1 * 0.9, max_val=d1 * 1.1, unit=""), hilbert_dim=lvls1, anhar=Qty(value=anhar1, min_val=-380e6, max_val=-120e6, unit="Hz 2pi"), # t1=Qty(value=t1_tc, min_val=1e-6, max_val=90e-6, unit="s"), # t2star=Qty(value=t2star_tc, min_val=1e-6, max_val=90e-6, unit="s"), # temp=Qty(value=init_temp, min_val=0.0, max_val=0.12, unit="K"), )
"d1": { "LO": [], "AWG": [], "DigitalToAnalog": ["AWG"], "Mixer": ["LO", "DigitalToAnalog"], }, }, ) lo_freq_q1 = 2e9 t_final = 1 / lo_freq_q1 rect = Envelope( name="Rectangle", desc="", params={"t_final": Qty(t_final, "s")}, shape=envelopes.rect, ) carrier_parameters = { "freq": Qty(value=lo_freq_q1, min_val=1.5e9, max_val=6e9, unit="Hz 2pi"), "framechange": Qty(value=0.0, min_val=-np.pi, max_val=3 * np.pi, unit="rad"), } carr = Carrier(name="carrier", desc="Frequency of the local oscillator", params=carrier_parameters) rectangle = Instruction(name="Rectangle", t_start=0.0,
from c3.signal.pulse import Envelope, EnvelopeNetZero from c3.c3objs import Quantity as Qty from c3.libraries import envelopes import numpy as np import pytest flux_env = Envelope( name="flux", desc="Flux bias for tunable coupler", shape=envelopes.rect, params={ "amp": Qty(value=0.1, unit="V"), "t_final": Qty(value=10e-9, unit="s"), "freq_offset": Qty(value=0, min_val=0, max_val=1, unit="Hz 2pi"), "xy_angle": Qty(value=0, min_val=0, max_val=np.pi, unit="rad"), }, ) flux_env_netzero = EnvelopeNetZero( name="flux", desc="Flux bias for tunable coupler", shape=envelopes.rect, params={ "amp": Qty(value=0.1, unit="V"), "t_final": Qty(value=5e-9, unit="s"), "freq_offset": Qty(value=0, min_val=0, max_val=1, unit="Hz 2pi"), "xy_angle": Qty(value=0, min_val=0, max_val=np.pi, unit="rad"), }, )
def create_experiment(): lindblad = False dressed = True qubit_lvls = 3 freq_q1 = 5e9 * 2 * np.pi freq_q2 = 5.6e9 * 2 * np.pi anhar_q1 = -210e6 * 2 * np.pi anhar_q2 = -240e6 * 2 * np.pi coupling_strength = 20e6 * 2 * np.pi t1_q1 = 27e-6 t1_q2 = 23e-6 t2star_q1 = 39e-6 t2star_q2 = 31e-6 init_temp = 0 qubit_temp = 0 v2hz = 1e9 t_final = 7e-9 # Time for single qubit gates sim_res = 100e9 awg_res = 2e9 meas_offset = 0.0 meas_scale = 1.0 sideband = 50e6 * 2 * np.pi lo_freq_q1 = 5e9 * 2 * np.pi + sideband lo_freq_q2 = 5.6e9 * 2 * np.pi + sideband # ### MAKE MODEL q1 = chip.Qubit(name="Q1", desc="Qubit 1", freq=Qty(value=freq_q1, min=4.995e9 * 2 * np.pi, max=5.005e9 * 2 * np.pi, unit='Hz 2pi'), anhar=Qty(value=anhar_q1, min=-380e6 * 2 * np.pi, max=-120e6 * 2 * np.pi, unit='Hz 2pi'), hilbert_dim=qubit_lvls, t1=Qty(value=t1_q1, min=1e-6, max=90e-6, unit='s'), t2star=Qty(value=t2star_q1, min=10e-6, max=90e-6, unit='s'), temp=Qty(value=qubit_temp, min=0.0, max=0.12, unit='K')) q2 = chip.Qubit(name="Q2", desc="Qubit 2", freq=Qty(value=freq_q2, min=5.595e9 * 2 * np.pi, max=5.605e9 * 2 * np.pi, unit='Hz 2pi'), anhar=Qty(value=anhar_q2, min=-380e6 * 2 * np.pi, max=-120e6 * 2 * np.pi, unit='Hz 2pi'), hilbert_dim=qubit_lvls, t1=Qty(value=t1_q2, min=1e-6, max=90e-6, unit='s'), t2star=Qty(value=t2star_q2, min=10e-6, max=90e-6, unit='s'), temp=Qty(value=qubit_temp, min=0.0, max=0.12, unit='K')) q1q2 = chip.Coupling(name="Q1-Q2", desc="coupling", comment="Coupling qubit 1 to qubit 2", connected=["Q1", "Q2"], strength=Qty(value=coupling_strength, min=-1 * 1e3 * 2 * np.pi, max=200e6 * 2 * np.pi, unit='Hz 2pi'), hamiltonian_func=hamiltonians.int_XX) drive = chip.Drive(name="d1", desc="Drive 1", comment="Drive line 1 on qubit 1", connected=["Q1"], hamiltonian_func=hamiltonians.x_drive) drive2 = chip.Drive(name="d2", desc="Drive 2", comment="Drive line 2 on qubit 2", connected=["Q2"], hamiltonian_func=hamiltonians.x_drive) phys_components = [q1, q2] line_components = [drive, drive2, q1q2] init_ground = tasks.InitialiseGround( init_temp=Qty(value=init_temp, min=-0.001, max=0.22, unit='K')) task_list = [init_ground] model = Mdl(phys_components, line_components, task_list) model.set_lindbladian(lindblad) model.set_dressed(dressed) # ### MAKE GENERATOR lo = devices.LO(name='lo', resolution=sim_res) awg = devices.AWG(name='awg', resolution=awg_res) mixer = devices.Mixer(name='mixer') v_to_hz = devices.Volts_to_Hertz(name='v_to_hz', V_to_Hz=Qty(value=v2hz, min=0.9e9, max=1.1e9, unit='Hz 2pi/V')) dig_to_an = devices.Digital_to_Analog(name="dac", resolution=sim_res) resp = devices.Response(name='resp', rise_time=Qty(value=0.3e-9, min=0.05e-9, max=0.6e-9, unit='s'), resolution=sim_res) device_list = [lo, awg, mixer, v_to_hz, dig_to_an, resp] generator = Gnr(device_list) generator.devices['awg'].enable_drag_2() # ### MAKE GATESET gateset = gates.GateSet() gauss_params_single = { 'amp': Qty(value=0.45, min=0.4, max=0.6, unit="V"), 't_final': Qty(value=t_final, min=0.5 * t_final, max=1.5 * t_final, unit="s"), 'sigma': Qty(value=t_final / 4, min=t_final / 8, max=t_final / 2, unit="s"), 'xy_angle': Qty(value=0.0, min=-0.5 * np.pi, max=2.5 * np.pi, unit='rad'), 'freq_offset': Qty(value=-sideband - 0.5e6 * 2 * np.pi, min=-53 * 1e6 * 2 * np.pi, max=-47 * 1e6 * 2 * np.pi, unit='Hz 2pi'), 'delta': Qty(value=-1, min=-5, max=3, unit="") } gauss_env_single = pulse.Envelope( name="gauss", desc="Gaussian comp for single-qubit gates", params=gauss_params_single, shape=envelopes.gaussian_nonorm) nodrive_env = pulse.Envelope(name="no_drive", params={ 't_final': Qty(value=t_final, min=0.5 * t_final, max=1.5 * t_final, unit="s") }, shape=envelopes.no_drive) carrier_parameters = { 'freq': Qty(value=lo_freq_q1, min=4.5e9 * 2 * np.pi, max=6e9 * 2 * np.pi, unit='Hz 2pi'), 'framechange': Qty(value=0.0, min=-np.pi, max=3 * np.pi, unit='rad') } carr = pulse.Carrier(name="carrier", desc="Frequency of the local oscillator", params=carrier_parameters) carr_2 = copy.deepcopy(carr) carr_2.params['freq'].set_value(lo_freq_q2) X90p_q1 = gates.Instruction(name="X90p", t_start=0.0, t_end=t_final, channels=["d1"]) X90p_q2 = gates.Instruction(name="X90p", t_start=0.0, t_end=t_final, channels=["d2"]) QId_q1 = gates.Instruction(name="Id", t_start=0.0, t_end=t_final, channels=["d1"]) QId_q2 = gates.Instruction(name="Id", t_start=0.0, t_end=t_final, channels=["d2"]) X90p_q1.add_component(gauss_env_single, "d1") X90p_q1.add_component(carr, "d1") QId_q1.add_component(nodrive_env, "d1") QId_q1.add_component(copy.deepcopy(carr), "d1") QId_q1.comps['d1']['carrier'].params['framechange'].set_value( (-sideband * t_final) % (2 * np.pi)) Y90p_q1 = copy.deepcopy(X90p_q1) Y90p_q1.name = "Y90p" X90m_q1 = copy.deepcopy(X90p_q1) X90m_q1.name = "X90m" Y90m_q1 = copy.deepcopy(X90p_q1) Y90m_q1.name = "Y90m" Y90p_q1.comps['d1']['gauss'].params['xy_angle'].set_value(0.5 * np.pi) X90m_q1.comps['d1']['gauss'].params['xy_angle'].set_value(np.pi) Y90m_q1.comps['d1']['gauss'].params['xy_angle'].set_value(1.5 * np.pi) Q1_gates = [QId_q1, X90p_q1, Y90p_q1, X90m_q1, Y90m_q1] X90p_q2.add_component(copy.deepcopy(gauss_env_single), "d2") X90p_q2.add_component(carr_2, "d2") QId_q2.add_component(copy.deepcopy(nodrive_env), "d2") QId_q2.add_component(copy.deepcopy(carr_2), "d2") QId_q2.comps['d2']['carrier'].params['framechange'].set_value( (-sideband * t_final) % (2 * np.pi)) Y90p_q2 = copy.deepcopy(X90p_q2) Y90p_q2.name = "Y90p" X90m_q2 = copy.deepcopy(X90p_q2) X90m_q2.name = "X90m" Y90m_q2 = copy.deepcopy(X90p_q2) Y90m_q2.name = "Y90m" Y90p_q2.comps['d2']['gauss'].params['xy_angle'].set_value(0.5 * np.pi) X90m_q2.comps['d2']['gauss'].params['xy_angle'].set_value(np.pi) Y90m_q2.comps['d2']['gauss'].params['xy_angle'].set_value(1.5 * np.pi) Q2_gates = [QId_q2, X90p_q2, Y90p_q2, X90m_q2, Y90m_q2] all_1q_gates_comb = [] for g1 in Q1_gates: for g2 in Q2_gates: g = gates.Instruction(name="NONE", t_start=0.0, t_end=t_final, channels=[]) g.name = g1.name + ":" + g2.name channels = [] channels.extend(g1.comps.keys()) channels.extend(g2.comps.keys()) for chan in channels: g.comps[chan] = {} if chan in g1.comps: g.comps[chan].update(g1.comps[chan]) if chan in g2.comps: g.comps[chan].update(g2.comps[chan]) all_1q_gates_comb.append(g) for gate in all_1q_gates_comb: gateset.add_instruction(gate) # ### MAKE EXPERIMENT exp = Exp(model=model, generator=generator, gateset=gateset) return exp
from c3.signal.pulse import Envelope, EnvelopeNetZero from c3.c3objs import Quantity as Qty from c3.libraries import envelopes import numpy as np import pytest flux_env = Envelope(name="flux", desc="Flux bias for tunable coupler", shape=envelopes.rect, params={ 'amp': Qty(value=0.1, unit="V"), 't_final': Qty(value=10e-9, unit="s"), 'freq_offset': Qty(value=0, min_val=0, max_val=1, unit='Hz 2pi'), 'xy_angle': Qty(value=0, min_val=0, max_val=np.pi, unit='rad') }) flux_env_netzero = EnvelopeNetZero(name="flux", desc="Flux bias for tunable coupler", shape=envelopes.rect, params={ 'amp': Qty(value=0.1, unit="V"), 't_final': Qty(value=5e-9, unit="s"), 'freq_offset': Qty(value=0, min_val=0,
def create_experiment(gatetime: np.float64 = 7e-9, anhar=-210e6) -> Exp: """ Parameters ---------- gatetime : longer gatetimes needed for a better FFT of the microwave signal """ lindblad = False dressed = True qubit_lvls = 3 freq = 5e9 anhar = anhar init_temp = 0 qubit_temp = 0 t_final = gatetime # Time for single qubit gates sim_res = 100e9 awg_res = 2e9 sideband = 50e6 lo_freq = 5e9 + sideband lo2_freq = lo_freq + anhar # for 1<->2 # ### MAKE MODEL q1 = chip.Qubit( name="Q1", desc="Qubit 1", freq=Qty( value=freq, min_val=4.995e9, max_val=5.005e9, unit="Hz 2pi", ), anhar=Qty( value=anhar, # min_val=-380e9, # max_val=-120e6, unit="Hz 2pi", ), hilbert_dim=qubit_lvls, temp=Qty(value=qubit_temp, min_val=0.0, max_val=0.12, unit="K"), ) drive = chip.Drive( name="d1", desc="Drive 1", comment="Drive line 1 on qubit 1", connected=["Q1"], hamiltonian_func=hamiltonians.x_drive, ) phys_components = [q1] line_components = [drive] init_ground = tasks.InitialiseGround( init_temp=Qty(value=init_temp, min_val=-0.001, max_val=0.22, unit="K")) task_list = [init_ground] model = Mdl(phys_components, line_components, task_list) model.set_lindbladian(lindblad) model.set_dressed(dressed) # ### MAKE GENERATOR generator = Gnr( devices={ "LO": devices.LO(name="lo", resolution=sim_res, outputs=1), "AWG": devices.AWG(name="awg", resolution=awg_res, outputs=1), "DigitalToAnalog": devices.DigitalToAnalog(name="dac", resolution=sim_res, inputs=1, outputs=1), "Response": devices.Response( name="resp", rise_time=Qty(value=0.3e-9, min_val=0.05e-9, max_val=0.6e-9, unit="s"), resolution=sim_res, inputs=1, outputs=1, ), "Mixer": devices.Mixer(name="mixer", inputs=2, outputs=1), "VoltsToHertz": devices.VoltsToHertz( name="v_to_hz", V_to_Hz=Qty(value=1e9, min_val=0.9e9, max_val=1.1e9, unit="Hz/V"), inputs=1, outputs=1, ), }, chains={ "d1": [ "LO", "AWG", "DigitalToAnalog", "Response", "Mixer", "VoltsToHertz" ] }, ) generator.devices["AWG"].enable_drag_2() # ### MAKE GATESET gauss_params_single = { "amp": Qty(value=0.45, min_val=0.4, max_val=0.6, unit="V"), "t_final": Qty(value=t_final, min_val=0.5 * t_final, max_val=1.5 * t_final, unit="s"), "sigma": Qty(value=t_final / 4, min_val=t_final / 8, max_val=t_final / 2, unit="s"), "xy_angle": Qty(value=0.0, min_val=-0.5 * np.pi, max_val=2.5 * np.pi, unit="rad"), "freq_offset": Qty( value=-sideband - 0.5e6, min_val=-60 * 1e6, max_val=-40 * 1e6, unit="Hz 2pi", ), "delta": Qty(value=-1, min_val=-5, max_val=3, unit=""), } gauss_params_pi = { "amp": Qty(value=0.8, min_val=0.4, max_val=0.9, unit="V"), "t_final": Qty(value=t_final, min_val=0.5 * t_final, max_val=1.5 * t_final, unit="s"), "sigma": Qty(value=t_final / 4, min_val=t_final / 8, max_val=t_final / 2, unit="s"), "xy_angle": Qty(value=0.0, min_val=-0.5 * np.pi, max_val=2.5 * np.pi, unit="rad"), "freq_offset": Qty( value=-sideband - 0.5e6, min_val=-60 * 1e6, max_val=-40 * 1e6, unit="Hz 2pi", ), "delta": Qty(value=-1, min_val=-5, max_val=3, unit=""), } gauss_env_pi = pulse.Envelope( name="gauss", desc="Gaussian comp for single-qubit gates", params=gauss_params_pi, shape=envelopes.gaussian_nonorm, ) gauss_env_single = pulse.Envelope( name="gauss", desc="Gaussian comp for single-qubit gates", params=gauss_params_single, shape=envelopes.gaussian_nonorm, ) nodrive_env = pulse.Envelope( name="no_drive", params={ "t_final": Qty(value=t_final, min_val=0.5 * t_final, max_val=1.5 * t_final, unit="s") }, shape=envelopes.no_drive, ) carrier_parameters = { "freq": Qty( value=lo_freq, min_val=4.5e9, max_val=6e9, unit="Hz 2pi", ), "framechange": Qty(value=0.0, min_val=-np.pi, max_val=3 * np.pi, unit="rad"), } carr = pulse.Carrier( name="carrier", desc="Frequency of the local oscillator", params=carrier_parameters, ) # for 1<->2 carrier2_parameters = { "freq": Qty( value=lo2_freq, min_val=4.5e9, max_val=6e9, unit="Hz 2pi", ), "framechange": Qty(value=0.0, min_val=-np.pi, max_val=3 * np.pi, unit="rad"), } carr2 = pulse.Carrier( name="carrier", desc="Frequency of the local oscillator 2", params=carrier2_parameters, ) PI01p = gates.Instruction(name="PI01p", t_start=0.0, t_end=t_final, channels=["d1"]) RX90p = gates.Instruction(name="RX90p", t_start=0.0, t_end=t_final, channels=["d1"]) RXp12 = gates.Instruction(name="RXp12", t_start=0.0, t_end=t_final, channels=["d1"]) RXp = gates.Instruction(name="RXp", t_start=0.0, t_end=t_final, channels=["d1"]) QId = gates.Instruction(name="Id", t_start=0.0, t_end=t_final, channels=["d1"]) PI01p.add_component(gauss_env_pi, "d1") PI01p.add_component(carr, "d1") RX90p.add_component(gauss_env_single, "d1") RX90p.add_component(carr, "d1") RXp12.add_component(gauss_env_pi, "d1") RXp12.add_component(carr2, "d1") RXp.add_component(gauss_env_pi, "d1") RXp.add_component(carr, "d1") QId.add_component(nodrive_env, "d1") QId.add_component(copy.deepcopy(carr), "d1") QId.comps["d1"]["carrier"].params["framechange"].set_value( (-sideband * t_final) % (2 * np.pi)) RY90p = copy.deepcopy(RX90p) RY90p.name = "RY90p" RX90m = copy.deepcopy(RX90p) RX90m.name = "RX90m" RY90m = copy.deepcopy(RX90p) RY90m.name = "RY90m" RY90p.comps["d1"]["gauss"].params["xy_angle"].set_value(0.5 * np.pi) RX90m.comps["d1"]["gauss"].params["xy_angle"].set_value(np.pi) RY90m.comps["d1"]["gauss"].params["xy_angle"].set_value(1.5 * np.pi) parameter_map = PMap( instructions=[QId, RX90p, RY90p, RX90m, RY90m, RXp12, PI01p, RXp], model=model, generator=generator) # ### MAKE EXPERIMENT exp = Exp(pmap=parameter_map) return exp
def create_experiment(): lindblad = False dressed = True qubit_lvls = 3 freq = 5e9 * 2 * np.pi anhar = -210e6 * 2 * np.pi init_temp = 0 qubit_temp = 0 v2hz = 1e9 t_final = 7e-9 # Time for single qubit gates sim_res = 100e9 awg_res = 2e9 meas_offset = 0.0 meas_scale = 1.0 sideband = 50e6 * 2 * np.pi lo_freq = 5e9 * 2 * np.pi + sideband # ### MAKE MODEL q1 = chip.Qubit(name="Q1", desc="Qubit 1", freq=Qty(value=freq, min=4.995e9 * 2 * np.pi, max=5.005e9 * 2 * np.pi, unit='Hz 2pi'), anhar=Qty(value=anhar, min=-380e6 * 2 * np.pi, max=-120e6 * 2 * np.pi, unit='Hz 2pi'), hilbert_dim=qubit_lvls, temp=Qty(value=qubit_temp, min=0.0, max=0.12, unit='K')) drive = chip.Drive(name="d1", desc="Drive 1", comment="Drive line 1 on qubit 1", connected=["Q1"], hamiltonian_func=hamiltonians.x_drive) phys_components = [q1] line_components = [drive] init_ground = tasks.InitialiseGround( init_temp=Qty(value=init_temp, min=-0.001, max=0.22, unit='K')) task_list = [init_ground] model = Mdl(phys_components, line_components, task_list) model.set_lindbladian(lindblad) model.set_dressed(dressed) # ### MAKE GENERATOR lo = devices.LO(name='lo', resolution=sim_res) awg = devices.AWG(name='awg', resolution=awg_res) mixer = devices.Mixer(name='mixer') v_to_hz = devices.Volts_to_Hertz(name='v_to_hz', V_to_Hz=Qty(value=v2hz, min=0.9e9, max=1.1e9, unit='Hz 2pi/V')) dig_to_an = devices.Digital_to_Analog(name="dac", resolution=sim_res) resp = devices.Response(name='resp', rise_time=Qty(value=0.3e-9, min=0.05e-9, max=0.6e-9, unit='s'), resolution=sim_res) device_list = [lo, awg, mixer, v_to_hz, dig_to_an, resp] generator = Gnr(device_list) generator.devices['awg'].enable_drag_2() # ### MAKE GATESET gateset = gates.GateSet() gauss_params_single = { 'amp': Qty(value=0.45, min=0.4, max=0.6, unit="V"), 't_final': Qty(value=t_final, min=0.5 * t_final, max=1.5 * t_final, unit="s"), 'sigma': Qty(value=t_final / 4, min=t_final / 8, max=t_final / 2, unit="s"), 'xy_angle': Qty(value=0.0, min=-0.5 * np.pi, max=2.5 * np.pi, unit='rad'), 'freq_offset': Qty(value=-sideband - 0.5e6 * 2 * np.pi, min=-60 * 1e6 * 2 * np.pi, max=-40 * 1e6 * 2 * np.pi, unit='Hz 2pi'), 'delta': Qty(value=-1, min=-5, max=3, unit="") } gauss_env_single = pulse.Envelope( name="gauss", desc="Gaussian comp for single-qubit gates", params=gauss_params_single, shape=envelopes.gaussian_nonorm) nodrive_env = pulse.Envelope(name="no_drive", params={ 't_final': Qty(value=t_final, min=0.5 * t_final, max=1.5 * t_final, unit="s") }, shape=envelopes.no_drive) carrier_parameters = { 'freq': Qty(value=lo_freq, min=4.5e9 * 2 * np.pi, max=6e9 * 2 * np.pi, unit='Hz 2pi'), 'framechange': Qty(value=0.0, min=-np.pi, max=3 * np.pi, unit='rad') } carr = pulse.Carrier(name="carrier", desc="Frequency of the local oscillator", params=carrier_parameters) X90p = gates.Instruction(name="X90p", t_start=0.0, t_end=t_final, channels=["d1"]) QId = gates.Instruction(name="Id", t_start=0.0, t_end=t_final, channels=["d1"]) X90p.add_component(gauss_env_single, "d1") X90p.add_component(carr, "d1") QId.add_component(nodrive_env, "d1") QId.add_component(copy.deepcopy(carr), "d1") QId.comps['d1']['carrier'].params['framechange'].set_value( (-sideband * t_final) % (2 * np.pi)) Y90p = copy.deepcopy(X90p) Y90p.name = "Y90p" X90m = copy.deepcopy(X90p) X90m.name = "X90m" Y90m = copy.deepcopy(X90p) Y90m.name = "Y90m" Y90p.comps['d1']['gauss'].params['xy_angle'].set_value(0.5 * np.pi) X90m.comps['d1']['gauss'].params['xy_angle'].set_value(np.pi) Y90m.comps['d1']['gauss'].params['xy_angle'].set_value(1.5 * np.pi) for gate in [QId, X90p, Y90p, X90m, Y90m]: gateset.add_instruction(gate) # ### MAKE EXPERIMENT exp = Exp(model=model, generator=generator, gateset=gateset) return exp
def make_exp(simtime: np.float64 = 7e-9) -> Exp: """ Parameters ---------- simtime : np.float64 """ qubit_lvls = 3 freq_q1 = 5e9 anhar_q1 = -210e6 t1_q1 = 27e-6 t2star_q1 = 39e-6 qubit_temp = 50e-3 q1 = chip.Qubit( name="Q1", desc="Qubit 1", freq=Qty(value=freq_q1, min_val=4.995e9, max_val=5.005e9, unit="Hz 2pi"), anhar=Qty(value=anhar_q1, min_val=-380e6, max_val=-120e6, unit="Hz 2pi"), hilbert_dim=qubit_lvls, t1=Qty(value=t1_q1, min_val=1e-6, max_val=90e-6, unit="s"), t2star=Qty(value=t2star_q1, min_val=10e-6, max_val=90e-3, unit="s"), temp=Qty(value=qubit_temp, min_val=0.0, max_val=0.12, unit="K"), ) freq_q2 = 5.6e9 anhar_q2 = -240e6 t1_q2 = 23e-6 t2star_q2 = 31e-6 q2 = chip.Qubit( name="Q2", desc="Qubit 2", freq=Qty(value=freq_q2, min_val=5.595e9, max_val=5.605e9, unit="Hz 2pi"), anhar=Qty(value=anhar_q2, min_val=-380e6, max_val=-120e6, unit="Hz 2pi"), hilbert_dim=qubit_lvls, t1=Qty(value=t1_q2, min_val=1e-6, max_val=90e-6, unit="s"), t2star=Qty(value=t2star_q2, min_val=10e-6, max_val=90e-6, unit="s"), temp=Qty(value=qubit_temp, min_val=0.0, max_val=0.12, unit="K"), ) coupling_strength = 20e6 q1q2 = chip.Coupling( name="Q1-Q2", desc="coupling", comment="Coupling qubit 1 to qubit 2", connected=["Q1", "Q2"], strength=Qty(value=coupling_strength, min_val=-1 * 1e3, max_val=200e6, unit="Hz 2pi"), hamiltonian_func=hamiltonians.int_XX, ) drive = chip.Drive( name="d1", desc="Drive 1", comment="Drive line 1 on qubit 1", connected=["Q1"], hamiltonian_func=hamiltonians.x_drive, ) drive2 = chip.Drive( name="d2", desc="Drive 2", comment="Drive line 2 on qubit 2", connected=["Q2"], hamiltonian_func=hamiltonians.x_drive, ) m00_q1 = 0.97 # Prop to read qubit 1 state 0 as 0 m01_q1 = 0.04 # Prop to read qubit 1 state 0 as 1 m00_q2 = 0.96 # Prop to read qubit 2 state 0 as 0 m01_q2 = 0.05 # Prop to read qubit 2 state 0 as 1 one_zeros = np.array([0] * qubit_lvls) zero_ones = np.array([1] * qubit_lvls) one_zeros[0] = 1 zero_ones[0] = 0 val1 = one_zeros * m00_q1 + zero_ones * m01_q1 val2 = one_zeros * m00_q2 + zero_ones * m01_q2 min_val = one_zeros * 0.8 + zero_ones * 0.0 max_val = one_zeros * 1.0 + zero_ones * 0.2 confusion_row1 = Qty(value=val1, min_val=min_val, max_val=max_val, unit="") confusion_row2 = Qty(value=val2, min_val=min_val, max_val=max_val, unit="") conf_matrix = tasks.ConfusionMatrix(Q1=confusion_row1, Q2=confusion_row2) init_temp = 50e-3 init_ground = tasks.InitialiseGround( init_temp=Qty(value=init_temp, min_val=-0.001, max_val=0.22, unit="K")) model = Mdl( [q1, q2], # Individual, self-contained components [drive, drive2, q1q2], # Interactions between components [conf_matrix, init_ground], # SPAM processing ) model.set_lindbladian(False) model.set_dressed(True) sim_res = 100e9 # Resolution for numerical simulation awg_res = 2e9 # Realistic, limited resolution of an AWG generator = Gnr( devices={ "LO": devices.LO(name="lo", resolution=sim_res, outputs=1), "AWG": devices.AWG(name="awg", resolution=awg_res, outputs=1), "DigitalToAnalog": devices.DigitalToAnalog(name="dac", resolution=sim_res, inputs=1, outputs=1), "Response": devices.Response( name="resp", rise_time=Qty(value=0.3e-9, min_val=0.05e-9, max_val=0.6e-9, unit="s"), resolution=sim_res, inputs=1, outputs=1, ), "Mixer": devices.Mixer(name="mixer", inputs=2, outputs=1), "VoltsToHertz": devices.VoltsToHertz( name="v_to_hz", V_to_Hz=Qty(value=1e9, min_val=0.9e9, max_val=1.1e9, unit="Hz/V"), inputs=1, outputs=1, ), }, chains={ "d1": [ "LO", "AWG", "DigitalToAnalog", "Response", "Mixer", "VoltsToHertz" ], "d2": [ "LO", "AWG", "DigitalToAnalog", "Response", "Mixer", "VoltsToHertz" ], }, ) t_final = simtime # Time for single qubit gates sideband = 50e6 gauss_params_single = { "amp": Qty(value=0.5, min_val=0.4, max_val=0.6, unit="V"), "t_final": Qty(value=t_final, min_val=0.5 * t_final, max_val=1.5 * t_final, unit="s"), "sigma": Qty(value=t_final / 4, min_val=t_final / 8, max_val=t_final / 2, unit="s"), "xy_angle": Qty(value=0.0, min_val=-0.5 * np.pi, max_val=2.5 * np.pi, unit="rad"), "freq_offset": Qty(value=-sideband - 3e6, min_val=-56 * 1e6, max_val=-52 * 1e6, unit="Hz 2pi"), "delta": Qty(value=-1, min_val=-5, max_val=3, unit=""), } gauss_env_single = pulse.Envelope( name="gauss", desc="Gaussian comp for single-qubit gates", params=gauss_params_single, shape=envelopes.gaussian_nonorm, ) lo_freq_q1 = 5e9 + sideband carrier_parameters = { "freq": Qty(value=lo_freq_q1, min_val=4.5e9, max_val=6e9, unit="Hz 2pi"), "framechange": Qty(value=0.0, min_val=-np.pi, max_val=3 * np.pi, unit="rad"), } nodrive_env = pulse.Envelope( name="no_drive", params={ "t_final": Qty(value=t_final, min_val=0.5 * t_final, max_val=1.5 * t_final, unit="s") }, shape=envelopes.no_drive, ) lo_freq_q1 = 5e9 + sideband carrier_parameters = { "freq": Qty(value=lo_freq_q1, min_val=4.5e9, max_val=6e9, unit="Hz 2pi"), "framechange": Qty(value=0.0, min_val=-np.pi, max_val=3 * np.pi, unit="rad"), } carr = pulse.Carrier(name="carrier", desc="Frequency of the local oscillator", params=carrier_parameters) lo_freq_q2 = 5.6e9 + sideband carr_2 = copy.deepcopy(carr) carr_2.params["freq"].set_value(lo_freq_q2) X90p_q1 = gates.Instruction(name="X90p", channels=["d1"], t_start=0.0, t_end=t_final) X90p_q2 = gates.Instruction(name="X90p", channels=["d2"], t_start=0.0, t_end=t_final) QId_q1 = gates.Instruction(name="Id", channels=["d1"], t_start=0.0, t_end=t_final) QId_q2 = gates.Instruction(name="Id", channels=["d2"], t_start=0.0, t_end=t_final) X90p_q1.add_component(gauss_env_single, "d1") X90p_q1.add_component(carr, "d1") QId_q1.add_component(nodrive_env, "d1") QId_q1.add_component(copy.deepcopy(carr), "d1") X90p_q2.add_component(copy.deepcopy(gauss_env_single), "d2") X90p_q2.add_component(carr_2, "d2") QId_q2.add_component(copy.deepcopy(nodrive_env), "d2") QId_q2.add_component(copy.deepcopy(carr_2), "d2") QId_q1.comps["d1"]["carrier"].params["framechange"].set_value( (-sideband * t_final) * 2 * np.pi % (2 * np.pi)) QId_q2.comps["d2"]["carrier"].params["framechange"].set_value( (-sideband * t_final) * 2 * np.pi % (2 * np.pi)) Y90p_q1 = copy.deepcopy(X90p_q1) Y90p_q1.name = "Y90p" X90m_q1 = copy.deepcopy(X90p_q1) X90m_q1.name = "X90m" Y90m_q1 = copy.deepcopy(X90p_q1) Y90m_q1.name = "Y90m" Y90p_q1.comps["d1"]["gauss"].params["xy_angle"].set_value(0.5 * np.pi) X90m_q1.comps["d1"]["gauss"].params["xy_angle"].set_value(np.pi) Y90m_q1.comps["d1"]["gauss"].params["xy_angle"].set_value(1.5 * np.pi) Q1_gates = [QId_q1, X90p_q1, Y90p_q1, X90m_q1, Y90m_q1] Y90p_q2 = copy.deepcopy(X90p_q2) Y90p_q2.name = "Y90p" X90m_q2 = copy.deepcopy(X90p_q2) X90m_q2.name = "X90m" Y90m_q2 = copy.deepcopy(X90p_q2) Y90m_q2.name = "Y90m" Y90p_q2.comps["d2"]["gauss"].params["xy_angle"].set_value(0.5 * np.pi) X90m_q2.comps["d2"]["gauss"].params["xy_angle"].set_value(np.pi) Y90m_q2.comps["d2"]["gauss"].params["xy_angle"].set_value(1.5 * np.pi) Q2_gates = [QId_q2, X90p_q2, Y90p_q2, X90m_q2, Y90m_q2] all_1q_gates_comb = [] for g1 in Q1_gates: for g2 in Q2_gates: g = gates.Instruction(name="NONE", channels=[], t_start=0.0, t_end=t_final) g.name = g1.name + ":" + g2.name channels: List[str] = [] channels.extend(g1.comps.keys()) channels.extend(g2.comps.keys()) for chan in channels: g.comps[chan] = {} if chan in g1.comps: g.comps[chan].update(g1.comps[chan]) if chan in g2.comps: g.comps[chan].update(g2.comps[chan]) all_1q_gates_comb.append(g) pmap = PMap(all_1q_gates_comb, generator, model) return Exp(pmap)
import c3.libraries.envelopes as envelopes from c3.optimizers.c1 import C1 qubit_lvls = 3 freq_q1 = 5e9 anhar_q1 = -210e6 t1_q1 = 27e-6 t2star_q1 = 39e-6 qubit_temp = 50e-3 q1 = chip.Qubit( name="Q1", desc="Qubit 1", freq=Qty(value=freq_q1, min_val=4.995e9, max_val=5.005e9, unit="Hz 2pi"), anhar=Qty(value=anhar_q1, min_val=-380e6, max_val=-120e6, unit="Hz 2pi"), hilbert_dim=qubit_lvls, t1=Qty(value=t1_q1, min_val=1e-6, max_val=90e-6, unit="s"), t2star=Qty(value=t2star_q1, min_val=10e-6, max_val=90e-3, unit="s"), temp=Qty(value=qubit_temp, min_val=0.0, max_val=0.12, unit="K"), ) freq_q2 = 5.6e9 anhar_q2 = -240e6 t1_q2 = 23e-6 t2star_q2 = 31e-6 q2 = chip.Qubit( name="Q2", desc="Qubit 2", freq=Qty(value=freq_q2, min_val=5.595e9, max_val=5.605e9, unit="Hz 2pi"),
def flattop_risefall_1ns(t, params): """Flattop gaussian with fixed width of 1ns.""" params["risefall"] = Qty(1e-9, unit="s") return flattop_risefall(t, params)