Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/refactor videomode folder #237

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)

## [Unreleased]
### Changed
- **Breaking change!** - `video_mode` became `live_mode` to avoid confusion with the video mode tool used to tune up quantum dots devices.

## [0.18.0] - 2024-10-23
### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from qualang_tools.addons.variables import assign_variables_to_element
from qualang_tools.results import fetching_tool
from configuration import *
from qualang_tools.video_mode.videomode import VideoMode
from qualang_tools.live_mode import LiveMode


####################
Expand Down Expand Up @@ -47,7 +47,7 @@ def PID_derivation(input_signal, bitshift_scale_factor, gain_P, gain_I, gain_D,
###################
# The QUA program #
###################
def PID_prog(vm: VideoMode, PDH_angle: float = 0.0):
def PID_prog(lm: LiveMode, PDH_angle: float = 0.0):
with program() as prog:
# Results variables
I = declare(fixed)
Expand All @@ -56,7 +56,7 @@ def PID_prog(vm: VideoMode, PDH_angle: float = 0.0):
single_shot_AC = declare(fixed)
dc_offset_1 = declare(fixed)
# PID variables
vm.declare_variables()
lm.declare_variables()
# Streams
single_shot_st = declare_stream()
error_st = declare_stream()
Expand All @@ -71,7 +71,7 @@ def PID_prog(vm: VideoMode, PDH_angle: float = 0.0):
with infinite_loop_():
# with for_(n, 0, n < N_shots, n + 1):
# Update the PID parameters based on the user input.
vm.load_parameters()
lm.load_parameters()
# Ensure that the two digital oscillators will start with the same phase
reset_phase("phase_modulator")
reset_phase("detector_AC")
Expand All @@ -98,7 +98,7 @@ def PID_prog(vm: VideoMode, PDH_angle: float = 0.0):
)
assign(single_shot_AC, I)
# PID correction signal
correction, error, int_error, der_error = PID_derivation(single_shot_DC, *vm.variables)
correction, error, int_error, der_error = PID_derivation(single_shot_DC, *lm.variables)
# Update the DC offset
assign(dc_offset_1, dc_offset_1 + correction)
# Handle saturation - Make sure that the DAC won't be asked to output more than 0.5V
Expand Down Expand Up @@ -133,7 +133,7 @@ def PID_prog(vm: VideoMode, PDH_angle: float = 0.0):
qmm = QuantumMachinesManager(qop_ip, cluster_name=cluster_name)
# Open the Quantum Machine
qm = qmm.open_qm(config)
# Define the parameters to be updated in video mode with their initial value and QUA type
# Define the parameters to be updated in live mode with their initial value and QUA type
param_dict = {
"bitshift_scale_factor": (3, int),
"gain_P": (-1e-4, fixed), # The proportional gain
Expand All @@ -142,11 +142,11 @@ def PID_prog(vm: VideoMode, PDH_angle: float = 0.0):
"alpha": (0.0, fixed), # The ratio between integration and proportional error
"target": (0.0, fixed), # The target value
}
# Initialize the video mode
video_mode = VideoMode(qm, param_dict)
# Initialize the live mode
live_mode = LiveMode(qm, param_dict)
# Get the QUA program
qua_prog = PID_prog(video_mode)
job = video_mode.execute(qua_prog)
qua_prog = PID_prog(live_mode)
job = live_mode.execute(qua_prog)
# Get the results from the OPX in live mode
data_list = ["error", "int_err", "der_err", "single_shot", "offset"]
results = fetching_tool(job, data_list, mode="live")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Video Mode usage examples
# Live Mode usage examples

__Package__: https://github.com/qua-platform/py-qua-tools/tree/main/qualang_tools/video_mode
__Package__: https://github.com/qua-platform/py-qua-tools/tree/main/qualang_tools/live_mode

This package contains modules to set the OPX in a video-mode, where pre-defined parameters of the QUA program can be
This package contains modules to set the OPX in a live-mode, where pre-defined parameters of the QUA program can be
updated while looking at data extracted and plotted in real-time.

In this example folder, you will find two files:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@
from qm import QuantumMachinesManager
from qualang_tools.results import fetching_tool
from configuration import *
from qualang_tools.video_mode.videomode import VideoMode
from qualang_tools.live_mode import LiveMode


def qua_prog(vm: VideoMode):
def qua_prog(lm: LiveMode):
with program() as prog:
# Results variables
single_shot_1 = declare(fixed)
single_shot_2 = declare(fixed)
# Get the parameters from the video mode
dc_offset_1, dc_offset_2 = vm.declare_variables()
# Get the parameters from the live mode
dc_offset_1, dc_offset_2 = lm.declare_variables()
# Streams
signal1_st = declare_stream()
signal2_st = declare_stream()

with infinite_loop_():
# Update the parameters
vm.load_parameters()
lm.load_parameters()
# Update the dc_offset of the channel connected to the OPX analog input 1
set_dc_offset("filter_cavity_1", "single", dc_offset_1)
set_dc_offset("filter_cavity_2", "single", dc_offset_2)
Expand Down Expand Up @@ -48,17 +48,17 @@ def qua_prog(vm: VideoMode):
qmm = QuantumMachinesManager(qop_ip, cluster_name=cluster_name)
# Open the Quantum Machine
qm = qmm.open_qm(config)
# Define the parameters to be updated in video mode with their initial value and QUA type
# Define the parameters to be updated in live mode with their initial value and QUA type
param_dict = {
"dc_offset_1": (0.0, fixed),
"dc_offset_2": (0.0, fixed),
}
# Initialize the video mode
video_mode = VideoMode(qm, param_dict)
# Initialize the live mode
live_mode = LiveMode(qm, param_dict)
# Get the QUA program
qua_prog = qua_prog(video_mode)
# Execute the QUA program in video mode
job = video_mode.execute(qua_prog)
qua_prog = qua_prog(live_mode)
# Execute the QUA program in live mode
job = live_mode.execute(qua_prog)
# Get the results from the OPX in live mode
results = fetching_tool(job, ["signal1", "signal2"], mode="live")
# Live plotting
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"from qm import QuantumMachinesManager\n",
"from qualang_tools.results import fetching_tool\n",
"from configuration import *\n",
"from qualang_tools.video_mode import VideoMode"
"from qualang_tools.live_mode import LiveMode"
]
},
{
Expand Down Expand Up @@ -56,7 +56,7 @@
"start\n",
"List of implemented commands: \n",
" get: returns the current value of the parameters. \n",
" stop: quit VideoMode. \n",
" stop: quit LiveMode. \n",
" done: resume program (if pause_program==True). \n",
" help: displays the list of available commands. \n",
" 'param_name'='param_value': sets the parameter to the specified value (ex: V1=0.152).\n",
Expand Down Expand Up @@ -99,20 +99,20 @@
],
"source": [
"\n",
"def qua_prog(video_mode: VideoMode):\n",
"def qua_prog(live_mode: LiveMode):\n",
" with program() as prog:\n",
" # Results variables\n",
" single_shot_1 = declare(fixed)\n",
" single_shot_2 = declare(fixed)\n",
" # Get the parameters from the video mode\n",
" dc_offset_1, dc_offset_2 = video_mode.declare_variables()\n",
" # Get the parameters from the live mode\n",
" dc_offset_1, dc_offset_2 = live_mode.declare_variables()\n",
" # Streams\n",
" signal1_st = declare_stream()\n",
" signal2_st = declare_stream()\n",
"\n",
" with infinite_loop_():\n",
" # Update the parameters\n",
" video_mode.load_parameters()\n",
" live_mode.load_parameters()\n",
" # Update the dc_offset of the channel connected to the OPX analog input 1\n",
" set_dc_offset(\"filter_cavity_1\", \"single\", dc_offset_1)\n",
" set_dc_offset(\"filter_cavity_2\", \"single\", dc_offset_2)\n",
Expand Down Expand Up @@ -141,17 +141,17 @@
" qmm = QuantumMachinesManager(qop_ip, cluster_name=cluster_name)\n",
" # Open the Quantum Machine\n",
" qm = qmm.open_qm(config)\n",
" # Define the parameters to be updated in video mode with their initial value\n",
" # Define the parameters to be updated in live mode with their initial value\n",
" param_dict = {\n",
" \"dc_offset_1\": (0.0, fixed),\n",
" \"dc_offset_2\": (0.0, fixed)\n",
" }\n",
" # Initialize the video mode\n",
" video_mode = VideoMode(qm, param_dict)\n",
" # Initialize the live mode\n",
" live_mode = LiveMode(qm, param_dict)\n",
" # Get the QUA program\n",
" prog = qua_prog(video_mode)\n",
" # Execute the QUA program in video mode\n",
" job = video_mode.execute(prog)\n",
" prog = qua_prog(live_mode)\n",
" # Execute the QUA program in live mode\n",
" job = live_mode.execute(prog)\n",
" # Get the results from the OPX in live mode\n",
" results = fetching_tool(job, [\"signal1\", \"signal2\"], mode=\"live\")\n",
" # Live plotting\n",
Expand Down
1 change: 1 addition & 0 deletions qualang_tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"bakery",
"config",
"control_panel",
"live_mode",
"loops",
"results",
"plot",
Expand Down
Loading
Loading