def run_on_q_single(wave, params): qctrl = Qctrl(email=config['EMAIL'], password=config['PW']) # Extract parameters duration = params["duration"] shot_count = params["shot_count"] #build controls repetitions = [1, 4, 16, 32, 64] controls = [] max_amp = max(wave[:, 0]) wave[:, 0] = wave[:, 0] / max_amp values = wave[:, 0] * np.exp(1j * wave[:, 1]) # Iterate through possible repetitions for rep in repetitions: controls.append({ "duration": duration, "values": values, "repetition_count": rep }) #run experiment experiment_results = qctrl.functions.calculate_qchack_measurements( controls=controls, shot_count=shot_count, ) return repetitions * 1, experiment_results
def run_on_q(waves_list, params): qctrl = Qctrl(email=config['EMAIL'], password=config['PW']) # Extract parameters duration = params["duration"] shot_count = params["shot_count"] repetitions = [1, 4, 16, 32, 64] #build controls controls = [] for wave in waves_list: # Create a random string of complex numbers for each controls. max_amp = max(wave[:, 0]) wave[:, 0] = wave[:, 0] / max_amp values = wave[:, 0] * np.exp(1j * wave[:, 1]) # Iterate through possible repetitions for rep in repetitions: controls.append({ "duration": duration, "values": values, "repetition_count": rep }) #conduct experiment experiment_results = qctrl.functions.calculate_qchack_measurements( controls=controls, shot_count=shot_count, ) return repetitions * len(waves_list), experiment_results
# # Boulder Opal from qctrlvisualizer import QCTRL_STYLE_COLORS, plot_controls, get_qctrl_style from qctrlopencontrols import new_primitive_control import numpy as np import matplotlib.pyplot as plt import matplotlib.gridspec as gridspec import jsonpickle import time from qctrl import Qctrl qctrl = Qctrl()
import jsonpickle import matplotlib.gridspec as gridspec import matplotlib.pyplot as plt import numpy as np from qctrlvisualizer import get_qctrl_style, plot_controls from scipy import interpolate from scipy.optimize import curve_fit import os # Q-CTRL imports from qctrl import Qctrl # Starting a session with the API qctrl = Qctrl(email=os.getenv('EMAIL'), password=os.getenv('PASSWORD')) # Choose to run experiments or to use saved data use_saved_data = False # Plotting parameters plt.style.use(get_qctrl_style()) prop_cycle = plt.rcParams["axes.prop_cycle"] colors = prop_cycle.by_key()["color"] markers = {"x": "x", "y": "s", "z": "o"} lines = {"x": "--", "y": "-.", "z": "-"} # Definition of operators and functions sigma_z = np.array([[1.0, 0.0], [0.0, -1.0]], dtype=np.complex) sigma_x = np.array([[0.0, 1.0], [1.0, 0.0]], dtype=np.complex) sigma_y = np.array([[0.0, -1.0j], [1.0j, 0.0]], dtype=np.complex) X90_gate = np.array([[1.0, -1j], [-1j, 1.0]], dtype=np.complex) / np.sqrt(2)
y = np.zeros((m, nn)) for (pi, p) in enumerate (xp): si = np.tile(np.sinc (xt - p), (m, 1)) y[:, pi] = np.sum(si * x) return y.squeeze () # In[1]: from qctrlvisualizer import get_qctrl_style, plot_controls from qctrl import Qctrl from dotenv import dotenv_values config = dotenv_values(".env") qctrl = Qctrl(email=config['EMAIL'], password=config['PW']) # In[2]: error_norm = lambda A, B : 1 - np.abs(np.trace((A.conj().T @ B)) / 2) ** 2 def estimate_probability_of_one(measurements): size = len(measurements) probability = np.mean(measurements) standart_error = np.std(measurements) / np.sqrt(size) return (probability, standart_error) def simulate_more_realistic_qubit( duration=1, values=np.array([np.pi]), shots=1024, repetitions=1 ):
import matplotlib.pyplot as plt import numpy as np from qctrlvisualizer import get_qctrl_style from scipy.linalg import expm from qctrl import Qctrl plt.style.use(get_qctrl_style()) # Define standard matrices sigma_x = np.array([[0, 1], [1, 0]], dtype=np.complex) sigma_y = np.array([[0, -1j], [1j, 0]], dtype=np.complex) sigma_z = np.array([[1, 0], [0, -1]], dtype=np.complex) # Start a session with the API qctrl = Qctrl() # ## Characterizing the control lines # # In this first section, we will consider the identification of a linear filter that alters the shape of the pulses in the control line. By feeding different control pulses and then measuring the qubit, we are able to extract information about the parameters that characterize the filter. This setup is illustrated in the figure below. # # ![Illustration_1.png](attachment:Illustration_1.png) # # To exemplify this procedure, we will consider a one-qubit system obeying the following Hamiltonian: # # $$ H(t) = \frac{1}{2} \mathcal{L} \left[ \alpha(t) \right] \sigma_x, $$ # # where $\alpha(t)$ is a real time-dependent control pulse and $\mathcal{L}$ is a filter applied to the pulse. # This linear filter acts on the control pulse $\alpha(t)$ according to the convolution product with some kernel $K(t)$: #
def step_impl(context): context.target = Qctrl(KEY, api_root=TEST_API_HOST)
import matplotlib.pyplot as plt import numpy as np from qctrlvisualizer import get_qctrl_style, plot_controls from qctrl import Qctrl import os from dotenv import load_dotenv load_dotenv() email = os.getenv('EMAIL') password = os.getenv('PASS') qctrl = Qctrl(email=email, password=password) def get_filtered_results(duration=1, values=np.array([np.pi]), shots=1024, repetitions=1): # 1. Limits for drive amplitudes assert np.max(values) <= 1.0 assert np.min(values) >= -1.0 max_drive_amplitude = 2 * np.pi * 20 # MHz # 2. Dephasing error dephasing_error = -2 * 2 * np.pi # MHz # 3. Amplitude error amplitude_i_error = 0.98 amplitude_q_error = 1.03