### Hello QUA Script (Python) Source: https://github.com/qua-platform/qua-libs/blob/main/Quantum-Control-Applications/Optically addressable spin qubits/Cryogenic nanophotonic cavity/README.md A basic script to get started with QUA programming. It serves as an introductory example for interacting with quantum hardware via the QUA framework. ```Python print("This is a placeholder for the 00_hello_qua.py script. Actual code content is not provided in the input text.") ``` -------------------------------- ### Basic Octave Commands and Setup Source: https://github.com/qua-platform/qua-libs/blob/main/Tutorials/intro-to-octave/README.md Demonstrates fundamental Octave commands for configuration, clock setting, RF output testing, and mixer calibration. This script serves as an introduction to interacting with the Octave hardware. ```python # This file contains the basic octave commands. # It shows the configuration the octave, sets the octave's clock, test the RF outputs and calibrate the mixers. # Example sections: # 1. Configuring the clock # 2. Looking at the octave RF outputs # 3. Configuring the digital switches # 4. Configuring the down converter modules # 5. Calibration # Note: Actual code for these operations would be within the script. # For example, setting clock might involve: # qm.octave_manager.set_octave_clock(octave_name, clock_freq) # Testing RF outputs might involve: # qm.octave_manager.test_octave_rf_outputs(octave_name) pass # Placeholder for actual implementation ``` -------------------------------- ### Configuration with Octave Setup Source: https://github.com/qua-platform/qua-libs/blob/main/Quantum-Control-Applications/Superconducting/3D-storage-cavity/README.md Provides an example configuration file for integrating an Octave device into the experimental setup. This file can replace the default 'configuration.py' to enable Octave functionality across scripts. ```python import qm # Example configuration for a setup with Octave # Replace this content with your actual configuration # Define quantum elements and their properties # For example: # config = { # "elements": { # "qb": { # "mixers": { # "f1_mixer": { # "intermediate_frequency": 10e6, # "lo_frequency": 4.8e9, # "correction": 0.0 # } # }, # "digitalInputs": ["d_in_1"], # "outputs": ["out1", "out2"], # "pulses": { # "drive_pulse": { # "operation": "control", # "type": "drag", # "length": 100, # in ns # "amplitude": 0.5, # "wf_filename": "drive_pulse.txt" # } # } # } # }, # "controllers": { # "con1": { # "analog_outputs": { # "out1": {"port": "PA_1"}, # "out2": {"port": "PA_2"} # }, # "digital_outputs": { # "d_in_1": {"port": "PDI_1"} # } # } # } # } # Placeholder for actual configuration content # This file is intended to be a template for users to adapt. print("Configuration file for Octave setup loaded.") ``` -------------------------------- ### Octave Configuration Example Source: https://github.com/qua-platform/qua-libs/blob/main/Quantum-Control-Applications/Superconducting/Two-Flux-Tunable-Coupled-Transmons/Standard Configuration/README.md Provides an example configuration file for integrating the Octave module with the OPX system. This file can be used to replace the default configuration. ```python # configuration_with_octave.py # This file is an example of a configuration including the Octave. # You can replace the content of the file called `configuration.py` # by this one so that it will be imported in all the scripts above. # Placeholder for actual configuration code: # from qua.settings import Settings # from qua.devices import Device # # def get_settings(): # settings = Settings() # # ... Octave specific settings ... # return settings # # def get_device(): # device = Device() # # ... Octave specific device setup ... # return device # print("This is a placeholder for configuration_with_octave.py.") ``` -------------------------------- ### Hello QUA Script Source: https://github.com/qua-platform/qua-libs/blob/main/Quantum-Control-Applications/Superconducting/Single-Flux-Tunable-Transmon/README.md A basic Python script for interacting with the QUA framework. It serves as an introductory example for users new to QUA programming. ```Python ./Single-Flux-Tunable-Transmon/00_hello_qua.py ``` -------------------------------- ### Hello QUA Python Script Source: https://github.com/qua-platform/qua-libs/blob/main/Quantum-Control-Applications/Superconducting/Single-Fixed-Transmon/README.md A basic script for playing with QUA. Demonstrates fundamental QUA operations and setup. ```python ./Single-Fixed-Transmon/00_hello_qua.py ``` -------------------------------- ### Start QUAlibrate Frontend Source: https://github.com/qua-platform/qua-libs/blob/main/qualibration_graphs/superconducting/calibrations/README.md Launches the QUAlibrate web application by starting a local web server. This command discovers and makes calibration nodes and graphs available through the UI for execution and parameter adjustment. ```Shell qualibrate start ``` -------------------------------- ### Hello QUA Source: https://github.com/qua-platform/qua-libs/blob/main/Quantum-Control-Applications/Optically addressable spin qubits/NV center in a confocal setup/README.md A basic script for interacting with and playing with the QUA (Quantum Универсальный Аппарат) framework. It serves as an introductory example for users new to the QUA environment. ```python import time from qua.openqasm.qua_parser import qua_parser from qua.qcc import QCC # Example of a simple QUA program program = "" program += "play('X90', IQ_channel_1, 100)" program += "wait(100)" program += "align(IQ_channel_1, trigger_channel)" # Parse and compile the QUA program compiled_program = qua_parser.parse(program) # Assuming QCC is configured and connected to a quantum computer # qcc = QCC(host='localhost', port=8000) # qcc.connect() # job = qcc.run(compiled_program) print("QUA program executed (simulated).") # print(f"Job ID: {job.id}") ``` -------------------------------- ### Run QUA Program with Octave Setup Source: https://github.com/qua-platform/qua-libs/blob/main/Tutorials/intro-to-octave/qm-qua 1.1.4 and below/README.md Demonstrates how to execute a QUA program in an environment configured with OPX and Octave units. It highlights the importance of passing the Octave configuration defined in `configuration.py` to the Quantum Machine Manager. ```python import qm # Assuming configuration.py sets up Octave units and octave_configuration is available # from configuration import octave_configuration # Initialize Quantum Machine Manager with Octave configuration # qm_manager = qm.QuantumMachineManager(octave=octave_configuration) # Example of running a QUA program (placeholder) # program = my_qua_program() # job = qm_manager.run(program) print("Example of running a QUA program with Octave setup.") print("Ensure octave_configuration is properly defined and passed to QuantumMachineManager.") ``` -------------------------------- ### 1D Voltage Sweep Setup (QDAC Only) Source: https://github.com/qua-platform/qua-libs/blob/main/Tutorials/intro-to-qdac2/Integration_with_the_OPX_and_pyvisa.ipynb Sets up parameters for a 1D voltage sweep experiment where the QDAC controls the voltage sequence. This example defines the number of averaging loops and generates a list of voltage values for the sweep using NumPy's linspace function. ```python import numpy as np n_avg = 100 # Number of averaging loops # Voltage values in Volt voltage_values1 = list(np.linspace(-1.5, 1.5, 101)) ``` -------------------------------- ### Install and Run Black Formatter Source: https://github.com/qua-platform/qua-libs/blob/main/CONTRIBUTING.md Installs the Black code formatter using pip and then applies it to format all Python code in the current directory. This ensures code adheres to project-specific style guidelines. ```shell pip install black black . ``` -------------------------------- ### Octave Clock and Calibration Setup Source: https://github.com/qua-platform/qua-libs/blob/main/Tutorials/intro-to-octave/README.md This script is essential for preparing the Octave module for QUA experiments. It handles the parametrization of the Octave's clock and performs necessary calibrations, and must be run once before executing QUA programs. ```python # This file is used to parametrize the Octave's clock and to calibrate the octave. # This file must be run once prior to executing any QUA program in order to configure the Octave's clock and calibrate if needed. # Example operations: # qm.octave_manager.set_octave_clock(octave_name, clock_freq) # qm.octave_manager.calibrate_octave(octave_name) pass # Placeholder for actual implementation ``` -------------------------------- ### Running QUA Programs with Octave (Python) Source: https://github.com/qua-platform/qua-libs/blob/main/Tutorials/intro-to-octave/qm-qua 1.1.4 and below/README.md This Python script demonstrates an example of running a program with the Octave module. It showcases how to integrate Octave functionality within a Quantum Unity Architecture (QUA) program for quantum experiments. ```python # hello_octave.py # Shows an example of running a program with the octave. # Example structure (actual code not provided in source text): # from qm import QuantumMachine # from configuration import config # from octave_configuration import octave_settings # def build_qop_config(octave_config): # # ... build QOP config ... # return qop_config # def main(): # # Load configuration # octave_config = ... # Load from configuration.py # qop_config = build_qop_config(octave_config) # # Initialize Quantum Machine # qm = QuantumMachine(qop_config) # qm.open() # # Define QUA program # prog = qm.program() # # ... add QUA operations ... # # Execute program # job = qm.execute(prog) # job.wait_for_all_results() # qm.close() # if __name__ == "__main__": # main() ``` -------------------------------- ### Call QUA Play Statements Source: https://github.com/qua-platform/qua-libs/blob/main/Tutorials/intro-to-macros/readme.md A Python macro that demonstrates calling QUA play statements. This macro is parameterized to allow for the setup of reusable components within QUA programs. ```Python def qua_function_calls(el): """ A macro that calls QUA play statements :param el: The quantum element used by the QUA statements :return: """ play('const', el, duration=300) play('const'*amp(b), el, duration=300) ``` -------------------------------- ### QUA Program State Preparation Example Source: https://github.com/qua-platform/qua-libs/blob/main/Quantum-Control-Applications/Superconducting/Two-Flux-Tunable-Coupled-Transmons/Use Case 4 - Single- and Two-Qubit State and Process Tomography/README.md Demonstrates how to prepare a specific quantum state using QUA play statements within a Python function. This function is crucial for setting up experiments like state tomography. ```python def prepare_state(qubit1, qubit2): # write whatever QUA code you need in order to create the # state to perform tomography on, from an initial # ground state. For example, to create the |1> 1/sqrt(2)(|0>+i|1>) # state play("y180", f"q{qubit1}_xy") play("-x90", f"q{qubit2}_xy") ``` -------------------------------- ### Configure Quantum Elements with Digital Inputs Source: https://github.com/qua-platform/qua-libs/blob/main/Tutorials/basic-digital-output/readme.md Configures quantum elements, specifying their input ports and digital input configurations, including delay and buffer settings. This setup is crucial for synchronizing digital signals with quantum operations. ```python "qe1": { "singleInput": {"port": ("con1", 1)}, "digitalInputs": { "digital_input1": { "port": ("con1", 1), "delay": 0, "buffer": 0 } }, "intermediate_frequency": 5e6, "operations": { "const": "constPulse" } }, "qe2": { "singleInput": {"port": ("con1", 1)}, "digitalInputs": { "digital_input1": { "port": ("con1", 1), "delay": 200, "buffer": 0 } } ``` -------------------------------- ### Python Virtual Environment Setup Source: https://github.com/qua-platform/qua-libs/blob/main/qualibration_graphs/superconducting/README.md Instructions for creating and activating a Python virtual environment using either venv or conda. This is crucial for managing dependencies and ensuring project isolation. ```bash python -m venv .venv source .venv/bin/activate # or for Windows: # .venv\Scripts\activate ``` ```bash conda create -n qualibrate_env python=3.10 conda activate qualibrate_env ``` -------------------------------- ### Populate QUAM State (populate_quam_*.py) Source: https://github.com/qua-platform/qua-libs/blob/main/qualibration_graphs/superconducting/quam_config/README.md Explains the purpose of `populate_quam_*.py` scripts, which load a base QUAM state and populate it with initial operational parameters and connectivity details for specific hardware setups. ```python # Example: populate_quam_opxp_octave.py # Loads a base QUAM state (generated by generate_quam.py) # Populates it with initial operational parameters and connectivity details # for specific hardware setups (e.g., OPX+ & Octave). ``` -------------------------------- ### Running a QUA Program with Octave Source: https://github.com/qua-platform/qua-libs/blob/main/Tutorials/intro-to-octave/README.md Provides an example of executing a QUA program that utilizes an Octave module. It assumes the Octave's clock has been set and calibration performed, passing the Octave configuration to the Quantum Machine Manager. ```python # This file shows an example of how to run a program with a setup containing a set of OPX + Octave. # The Octave config defined in configuration.py is passed to the Quantum Machine Manager # to enable the communication with the previously declared Octave unit. # from qm import QuantumMachine # from configuration import config # Assuming config is defined here # def qua_program(): # # Your QUA program logic here # pass # def run_octave_program(config): # qm = QuantumMachine(config=config) # job = qm.execute(qua_program()) # job.result() # # Ensure octave_clock_and_calibration.py has been run first # # run_octave_program(config) pass # Placeholder for actual implementation ``` -------------------------------- ### QUAlibrate Frontend and CLI Source: https://github.com/qua-platform/qua-libs/blob/main/Tutorials/intro-to-QUAlibrate/calibrations/readme.md Instructions for running calibration nodes using the QUAlibrate web frontend. This includes starting the web application via the command line and accessing the UI to select and run nodes with specified parameters. ```APIDOC QUAlibrate CLI and Frontend: Command to start the QUAlibrate web application: qualibrate start Access the web UI: Open http://localhost:8001/ in your browser. Workflow: 1. Select the desired calibration node from the list. 2. Modify input parameters through the UI form. 3. Click "Run" to execute the node. 4. View progress, results, and plots in the UI. Note: Calibration node scripts must be placed in the 'calibrations' folder and follow the standard structure for automatic discovery. ``` -------------------------------- ### Node Initialization and Debugging Setup Source: https://github.com/qua-platform/qua-libs/blob/main/Tutorials/intro-to-QUAlibrate/calibrations/node_anatomy.ipynb Initializes the QualibrationNode for Time of Flight calibration, defining its name, description, and parameters. Includes a custom run action decorated with `@node.run_action` that is executed only in standalone/IDE debugging modes, allowing local parameter overrides. ```python description = """ TIME OF FLIGHT This sequence involves sending a readout pulse and capturing the raw ADC traces. The data undergoes post-processing to calibrate three distinct parameters: - Time of Flight: This represents the internal processing time and the propagation delay of the readout pulse. Its value can be adjusted in the configuration under "time_of_flight". This value is utilized to offset the acquisition window relative to when the readout pulse is dispatched. - Analog Inputs Offset: Due to minor impedance mismatches, the signals captured by the OPX might exhibit slight offsets. These can be rectified in the configuration at: config/controllers/\"con1\"/analog_inputs, enhancing the demodulation process. - Analog Inputs Gain: If a signal is constrained by digitization or if it saturates the ADC, the variable gain of the OPX analog input can be modified to fit the signal within the ADC range of +/-0.5V. This gain, ranging from -12 dB to 20 dB, can also be adjusted in the configuration at: config/controllers/\"con1\"/analog_inputs. """ node = QualibrationNode[Parameters, None]( name="time_of_flight", # Name should be unique description=description, # Describe what the node is doing, which is also reflected in the QUAlibrate GUI parameters=Parameters(), # Node parameters defined under calibration_utils/node_name/parameters ) # Any parameters that should change for debugging purposes only should go in here # These parameters are ignored when run through the GUI @node.run_action(skip_if=node.modes.external) def custom_param(node: QualibrationNode[Parameters, None]): """Allow the user to locally set the node parameters for debugging purposes, or execution in the Python IDE.""" # You can get type hinting in your IDE by typing node.parameters. node.parameters.simulate = False node.parameters.resonators = ["q1_resonator", "q2_resonator"] node.parameters.multiplexed = True node.parameters.num_shots = 10 node.parameters.depletion_time = 10 * u.us pass ``` -------------------------------- ### Connect to QDACII Instrument Source: https://github.com/qua-platform/qua-libs/blob/main/Tutorials/intro-to-qdac2/Integration_with_the_OPX_and_pyvisa.ipynb Establishes a connection to the QDACII instrument. This example shows how to instantiate the QDACII object using either an Ethernet connection with a specified IP address and port, or via a USB connection by specifying the USB device number. ```python # Create the qdac instrument qdac = QDACII("Ethernet", IP_address="127.0.0.1", port=5025) # Using Ethernet protocol # qdac = QDACII("USB", USB_device=4) # Using USB protocol ``` -------------------------------- ### Hello QUA Introduction Source: https://github.com/qua-platform/qua-libs/blob/main/Quantum-Control-Applications/Superconducting/Two-Fixed-Coupled-Transmons/README.md A script used for introductory experiments with QUA. -------------------------------- ### Basic Octave Commands and Configuration (Python) Source: https://github.com/qua-platform/qua-libs/blob/main/Tutorials/intro-to-octave/qm-qua 1.1.4 and below/README.md This Python file provides a step-by-step guide to basic Octave commands, including configuration, testing RF outputs, and calibrating mixers. It covers sections on clock configuration, LO source, RF output gain, digital switches, down converter modules, and calibration procedures. ```python # octave_introduction.py # Contains basic octave commands. # Step-by-step guide on how to configure the Octave, test the RF outputs and calibrate the mixers. # Example structure (actual code not provided in source text): # def configure_clock(octave_config): # pass # def configure_lo_source(octave_config): # pass # def look_at_octave_rf_outputs(octave_config): # pass # def configure_digital_switches(octave_config): # pass # def configure_down_converter_modules(octave_config): # pass # def calibration(octave_config): # pass ``` -------------------------------- ### Hello QUA Script Source: https://github.com/qua-platform/qua-libs/blob/main/Quantum-Control-Applications/Superconducting/Two-Flux-Tunable-Coupled-Transmons/Standard Configuration/README.md A basic script demonstrating how to interact with the QUA framework. It serves as an entry point for learning and playing with QUA functionalities. ```python import time from qm.qua import * from qm.QuantumMachinesManager import QuantumMachinesManager def qua_script(): # Example QUA program with program() as prog: with infinite_loop_(): play("drive", "qubit1") wait(1000, "qubit1") return prog if __name__ == "__main__": qmm = QuantumMachinesManager() qm = qmm.open_qm(host='localhost', port=80) # Compile and run the QUA program job = qm.execute(qua_script()) # Wait for the job to complete (optional) job.wait_for_all_attributes(completed=True) print("QUA script executed successfully.") ``` -------------------------------- ### Installing qua-libs in Editable Mode Source: https://github.com/qua-platform/qua-libs/blob/main/qualibration_graphs/superconducting/README.md Installs the qua-libs package in editable mode using pip or uv. This allows changes made to the source code to be reflected immediately without needing to reinstall the package. ```bash pip install -e . # or for uv users: # uv pip install -e . --prerelease=allow ``` -------------------------------- ### Octave Configuration API Source: https://github.com/qua-platform/qua-libs/blob/main/Tutorials/intro-to-octave/qm-qua 1.1.4 and below/README.md Provides API documentation for the `set_octave.py` module, detailing classes and functions for declaring and configuring Octave devices and their associated elements for QUA experiments. ```APIDOC OctaveUnit Class: Description: Defines the properties of an Octave unit within a cluster. Attributes: name (str): The unique identifier for the Octave unit. ip_address (str): The IP address of the Octave unit. port (int): The network port for communication with the Octave unit. clock_setting (dict): Configuration for the Octave's clock input. Example: {'input': 'external', 'freq': 1e9} port_mapping (list[tuple[str, int, int]]): Maps OPX ports to Octave ports. Format: [(opx_port_name, octave_port_index, octave_channel_index), ...] ElementsSettings Class: Description: Configures settings for elements connected to Octave units. Attributes: lo_source (str): The local oscillator source for the element (e.g., 'internal', 'external'). gain (float): The gain applied to the element's signal. rf_switch_mode (str): The mode for the RF switch (e.g., 'on', 'off', 'auto'). down_conversion (dict): Configuration for down-conversion modules. Example: {'module_index': 1, 'freq': 5e9, 'lo_freq': 5.1e9} octave_declaration Function: Description: Orchestrates the declaration of Octave devices and their calibration parameters. Steps: 1. Creates a `calibration_db.json` file to store calibration parameters. 2. Adds declared Octave devices to an `octave_config` object. 3. Sets the port mapping for each OPX-Octave pair. Parameters: octave_config (dict): The configuration object to which Octave devices are added. octave_units (list[OctaveUnit]): A list of OctaveUnit objects to declare. element_settings (dict[str, ElementsSettings]): A dictionary mapping element names to their settings. octave_settings Function: Description: Configures various operational settings for Octave units. Settings: 1. Clock Input: - Sets the Octave's clock input frequency. - Note: The Octave's clock output is fixed at 1GHz. - Example: octave_settings(octave_config, clock_in_freq=1e9) 2. Up-converters: - Configures up-converter modules, including trigger options. - Trigger options: "on", "off", "trig_normal", "trig_inverse". - Example: octave_settings(octave_config, upconverter_trigger='on') 3. Down-converters: - Configures down-converter modules. - Note: If using down-converter module 2, ensure LO is connected to Dmd2LO on the back panel. - Example: octave_settings(octave_config, downconverter_module=2) 4. Calibration: - Sets the calibration status for Octave units. - Default: True. - Example: octave_settings(octave_config, calibration=True) Parameters: octave_config (dict): The configuration object to update. clock_in_freq (float, optional): The frequency for the Octave's clock input. upconverter_trigger (str, optional): The trigger mode for up-converters. downconverter_module (int, optional): The index of the down-converter module to configure. calibration (bool, optional): Whether to enable calibration. ``` -------------------------------- ### Stream Processing with Buffer Operator Source: https://github.com/qua-platform/qua-libs/blob/main/Tutorials/intro-to-saving/readme.md Utilizes the buffer operator to reshape stream data into fixed-size buffers and applies averaging. This example demonstrates averaging buffers and saving all results. ```python with program() as streamProg_buffer: out_str = declare_stream() a = declare(int) with for_(a, 0, a <= 100, a + 1): save(a, out_str) with stream_processing(): # Group output into vectors of length 3. Since only full buffers are used, # the last 2 data points [99 100] are discarded. # Perform a running average over the data, in group of 3: # The first vector is [0 1 2] and it averages only with itself. # The second vector is [3 4 5] and it averages with the 1st vector, giving [1.5 2.5 3.5]. # etc... # This time 'save_all' is used, so all of the data is saved ('save' would have only saved [48 49 50]) out_str.buffer(3).average().save_all("out") ``` -------------------------------- ### Python Define QualibrationGraph Parameters Source: https://github.com/qua-platform/qua-libs/blob/main/qualibration_graphs/superconducting/calibrations/graph_anatomy.ipynb Defines a class that inherits from `GraphParameters` to specify parameters applicable to the entire graph execution. This example sets default target qubits for the calibration sequence. ```python # Define parameters specific to this graph execution class Parameters(GraphParameters): qubits: List[str] = ["q1"] # Default target qubit(s) ``` -------------------------------- ### Define QUAM Class Structure (my_quam.py) Source: https://github.com/qua-platform/qua-libs/blob/main/qualibration_graphs/superconducting/quam_config/README.md Explains the role of `my_quam.py` in defining the root-level QUAM class, which represents the physical setup and typically inherits from base classes like `FluxTunableQuam` or `FixedFrequencyQuam`. ```python # In my_quam.py: # Defines the root-level QUAM class (inheriting from base QuamRoot) # Example: # class Quam(FluxTunableQuam): # ... # Or # class Quam(FixedFrequencyQuam): # ... # This class represents your physical setup (qubits, instruments). ``` -------------------------------- ### Initialize QCoDeS Database and Station Source: https://github.com/qua-platform/qua-libs/blob/main/Tutorials/intro-to-qdac2/Integration_with_the_OPX_and_qcodes.ipynb Configures the QCoDeS database location and initializes a new QCoDeS station. This prepares the framework for instrument registration and experiment management, essential for data logging and instrument control. ```python db_name = "QM_demo.db" # Database name sample_name = "demo" # Sample name exp_name = "OPX_QDAC2_integration" # Experiment name # Initialize qcodes database db_file_path = os.path.join(os.getcwd(), db_name) qc.config.core.db_location = db_file_path initialise_or_create_database_at(db_file_path) # Initialize the qcodes station to which instruments will be added station = qc.Station() ``` -------------------------------- ### Initialize Dynamic Parameters Source: https://github.com/qua-platform/qua-libs/blob/main/qualibration_graphs/superconducting/quam_config/README.md Command to run Python scripts for populating the QUAM state file with initial operational parameters. The specific script depends on the hardware setup (e.g., OPX+/Octave or OPX1000). ```bash python populate_quam_{hw_type}.py ``` -------------------------------- ### Octave Unit Configuration and Port Mapping (Python) Source: https://github.com/qua-platform/qua-libs/blob/main/Tutorials/intro-to-octave/qm-qua 1.1.4 and below/README.md This Python file contains the configuration dictionary used by hello_octave.py and defines the Octave units using the OctaveUnit class. It allows specifying parameters like name, IP address, port, clock source, and custom port mappings between Octave and OPX controllers. ```python # configuration.py # Contains the config dictionary and OctaveUnit class. # Example structure (actual code not provided in source text): # class OctaveUnit: # def __init__(self, name, ip, port=50, clock="Internal", con="con1", port_mapping="default"): # self.name = name # self.ip = ip # self.port = port # self.clock = clock # self.con = con # self.port_mapping = port_mapping # # Example port mapping structure: # port_mapping_example = [ # { # ("con1", 1): ("octave1", "I1"), # ("con1", 2): ("octave1", "Q1"), # # ... other mappings ... # } # ] # # Example config dictionary: # config = { # "version": 1, # "controllers": { # "con1": { # "type": "octave", # "host": "192.168.1.100", # "port": 50, # "octaves": [ # OctaveUnit("octave1", "192.168.1.100", port_mapping=port_mapping_example) # ] # } # }, # "elements": { # "qb1": { # "mixInputs": [ # { # "intermediate_frequency": 100e6, # "lo_frequency": 4.5e9, # "mixer": "octave1_mixer", # "correction": "qb1_corr" # } # ], # "singleInput": { # "port": ["octave1", 1], # "delay": 0, # "buffer": 0 # } # } # }, # "mixers": { # "octave1_mixer": { # "real": 0.0, # "imag": 0.0, # "phase_error": 0.0 # } # } # } ``` -------------------------------- ### Start QUAlibrate Web Interface Source: https://github.com/qua-platform/qua-libs/blob/main/qualibration_graphs/superconducting/README.md This bash command launches the QUAlibrate web interface. After execution, the interface can be accessed via a web browser at http://127.0.0.1:8001. It displays discovered calibration nodes. ```bash qualibrate start ``` -------------------------------- ### Python File Iteration and Conversion Source: https://github.com/qua-platform/qua-libs/blob/main/Quantum-Control-Applications/README.md Iterates through files in the current directory, checks if they are Python files starting with '0', '1', or '2', and converts them to .ipynb format using ipynb_py_convert.convert. Requires the 'os' module and the 'ipynb_py_convert' library. ```python import os # iterate over files in current directory for filename in os.listdir(): f = os.path.join(filename) # checking if it is a file if os.path.isfile(f): # checking if it is a python file that we want to convert if f[-3:] == ".py" and (f[0] in ["0", "1", "2"]): print(f[:-2]+"ipynb") # Assuming ipynb_py_convert is available and imported elsewhere # ipynb_py_convert.convert(f, f[:-2]+"ipynb") ``` -------------------------------- ### Octave Configuration Parameters Source: https://github.com/qua-platform/qua-libs/blob/main/Tutorials/intro-to-octave/README.md Details the parameters for initializing an Octave unit within a QUA configuration. This includes specifying the unit's name, IP address, port, and associated OPX controller. ```python class OctaveUnit: # Defines the name, IP address and port. def __init__(self, name: str, ip: str, port: int = 50, con: str = "con1"): self.name = name self.ip = ip self.port = port self.con = con # Example usage: # octave_unit = OctaveUnit(name="octave1", ip="192.168.1.2") ``` -------------------------------- ### Generate Static Configuration & Wiring (generate_quam.py) Source: https://github.com/qua-platform/qua-libs/blob/main/qualibration_graphs/superconducting/quam_config/README.md Describes the `generate_quam.py` script's function: to create the static QUAM configuration, including hardware layout and connectivity. It involves copying and modifying an example from `wiring_examples/`. ```python # In generate_quam.py: # 1. Copy content from a relevant script in wiring_examples/ (e.g., wiring_opxp_octave.py) # 2. Modify script to adjust static parameters (IPs, cluster names), define instruments, qubit IDs, channel addresses. # 3. Run: python generate_quam.py # This generates state files (e.g., wiring.json, state.json) in the QUAM state folder. ``` -------------------------------- ### Stream Processing Manipulations Source: https://github.com/qua-platform/qua-libs/blob/main/Tutorials/intro-to-streams/readme.md Demonstrates various stream processing operations including saving all samples, buffering, averaging, and zipping streams. Each operation is applied within a `stream_processing` context and saved to different tags. ```python with stream_processing(): stream1.save_all('stream1') #saving all samples to a single vector stream1.buffer(10).save_all('stream2') #each elements has size 10 stream1.buffer(10,10).save_all('2d_buffer') #each elements has size 10X10 stream1.buffer(10).average().save_all('stream2avg') #each elements has size 10 and is averaged column wise. cumulative average returned stream1.buffer(10).average().save('stream2avg_single') #each elements has size 10 and is averaged column wise. only final average returned stream1.buffer(3).map(FUNCTIONS.average()).save_all('buffer_average') #Data is first collected to bunches of size 3 and then each bunch is averaged stream2.zip(stream1).save_all('zipped_streams') #two streams are combined into a vector of tuples. like the python zip function. ``` -------------------------------- ### QUAM Configuration Folder Structure Source: https://github.com/qua-platform/qua-libs/blob/main/qualibration_graphs/superconducting/quam_config/README.md Details the organization of the `quam_config` library, listing key files and directories such as `__init__.py`, `my_quam.py`, `generate_quam.py`, `populate_quam_*.py`, `instrument_limits.py`, and `wiring_examples/`. ```text quam_config/ ├── __init__.py # Makes quam_config a Python package. ├── my_quam.py # Defines the core QUAM Python class structure. ├── generate_quam.py # Script to generate the QUAM state file (e.g., JSON), based on wiring examples. ├── populate_quam_*.py # Scripts to populate QUAM with initial parameters for specific hardware. ├── instrument_limits.py # Defines operational limits for instruments. ├── wiring_examples/ # Example wiring/connectivity configurations. │ ├── wiring_opxp_octave.py │ ├── wiring_lffem_mwfem.py │ └── ... # Other specific hardware wiring examples. └── README.md # Documentation for QUAM configuration (this file). ``` -------------------------------- ### Enable Qt Backend for Matplotlib Source: https://github.com/qua-platform/qua-libs/blob/main/Quantum-Control-Applications/README.md Enables the interactive Qt backend for Matplotlib plots within a notebook environment. This line should replace the standard 'import matplotlib.pyplot as plt' to activate live plotting. May require PyQt installation. ```python import matplotlib.pyplot as plt %matplotlib qt # Note: You may need to install the PyQt package if it is not already in your python environment. ``` -------------------------------- ### Octave Parameter Helper Functions (Python) Source: https://github.com/qua-platform/qua-libs/blob/main/Tutorials/intro-to-octave/qm-qua 1.1.4 and below/README.md This Python file contains helper functions designed to set all Octave parameters. These utilities streamline the process of configuring the Octave hardware within the QUA framework, making it easier to manage various settings. ```python # set_octave.py # Contains helper functions to set all octave parameters. # Example structure (actual code not provided in source text): # def set_octave_clock(octave_handle, clock_setting): # # ... implementation ... # pass # def set_octave_lo_frequency(octave_handle, lo_freq): # # ... implementation ... # pass # def set_octave_rf_gain(octave_handle, gain_db): # # ... implementation ... # pass # def set_octave_switch_mode(octave_handle, switch_mode): # # ... implementation ... # pass ``` -------------------------------- ### Randomized Benchmarking Source: https://github.com/qua-platform/qua-libs/blob/main/Quantum-Control-Applications/Optically addressable spin qubits/NV center in a confocal setup/README.md Performs a single-qubit randomized benchmarking (RB) protocol to measure the fidelity of single-qubit gates. It is designed for gates longer than 40ns. ```python from qua.openqasm.qua_parser import qua_parser from qua.qcc import QCC # This script implements single-qubit randomized benchmarking. randomized_benchmarking_program = "" randomized_benchmarking_program += "# Define sequence length (number of Clifford gates)\n" randomized_benchmarking_program += "# For each sequence length (and multiple random sequences):\n" randomized_benchmarking_program += "# Generate a random sequence of Clifford gates\n" randomized_benchmarking_program += "# Apply the sequence to the qubit\n" randomized_benchmarking_program += "# Apply a final gate to return to the initial state\n" randomized_benchmarking_program += "# Measure qubit state\n" randomized_benchmarking_program += "# Analyze results to extract gate fidelity\n" # compiled_rb = qua_parser.parse(randomized_benchmarking_program) # job = qcc.run(compiled_rb) print("Randomized Benchmarking script executed (placeholder).") ``` -------------------------------- ### Execute QUA Program with `execute_qua_program` Source: https://github.com/qua-platform/qua-libs/blob/main/Tutorials/intro-to-QUAlibrate/calibrations/readme.md This snippet details moving `qm.execute(...)` logic into an `execute_qua_program` run action. It connects to the OPX, opens a QM, executes the program, and uses a `fetching_tool` to retrieve and store raw data in `node.results`. ```Python @node.run_action(skip_if=node.parameters.load_data_id is not None or node.parameters.simulate) def execute_qua_program(node): qmm = QuantumMachinesManager(host=qop_ip, cluster_name=cluster_name) qm = qmm.open_qm(config) job = qm.execute(node.namespace["qua_program"]) node.namespace["job"] = job keys = [...] # List of variable names to retrieve from the QUA program data_fetcher = fetching_tool(job, data_list=keys, mode="wait_for_all") values = data_fetcher.fetch_all() node.results["raw_data"] = {} for key, value in zip(keys, values): node.results["raw_data"][key] = value ``` -------------------------------- ### Define Initial Quantum State Source: https://github.com/qua-platform/qua-libs/blob/main/Quantum-Control-Applications/Superconducting/Two-Flux-Tunable-Coupled-Transmons/Use Case 4 - Single- and Two-Qubit State and Process Tomography/README.md Defines a specific initial quantum state, represented as a NumPy array. This state is used as a starting point for quantum experiments, such as state tomography. ```Python ideal_state = np.array([[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 1 / 2, 1j / 2], [0, 0, -1j / 2, 1 / 2]]) ``` -------------------------------- ### Python Environment Setup for QDAC2/OPX Integration Source: https://github.com/qua-platform/qua-libs/blob/main/Tutorials/intro-to-qdac2/Integration_with_the_OPX_and_pyvisa.ipynb Imports necessary Python libraries for QDAC2 and OPX integration, including pyvisa for instrument communication, QUA SDK for quantum experiments, numpy for numerical operations, and matplotlib for plotting. It also sets the matplotlib backend for interactive plotting. ```python import pyvisa as visa from qm import QuantumMachinesManager from qm.qua import * from configuration import * import numpy as np import matplotlib.pyplot as plt from time import time, sleep from qualang_tools.plot import interrupt_on_close from qualang_tools.results import wait_until_job_is_paused, fetching_tool %matplotlib qt ``` -------------------------------- ### Simulate QUA Program with `simulate_qua_program` Source: https://github.com/qua-platform/qua-libs/blob/main/Tutorials/intro-to-QUAlibrate/calibrations/readme.md This snippet shows how to move `qmm.simulate(...)` logic into a `simulate_qua_program` run action. It utilizes `QuantumMachinesManager` and `simulate_and_plot` to run simulations, store results (figure, report, samples) in `node.results`. ```Python @node.run_action(skip_if=node.parameters.load_data_id is not None or not node.parameters.simulate) def simulate_qua_program(node): qmm = QuantumMachinesManager(host=qop_ip, cluster_name=cluster_name) samples, fig, wf_report = simulate_and_plot(qmm, config, node.namespace["qua_program"], node.parameters) node.results["simulation"] = { "figure": fig, "wf_report": wf_report, "samples": samples, } ``` -------------------------------- ### QUA Configuration Structure for Octave Source: https://github.com/qua-platform/qua-libs/blob/main/Tutorials/intro-to-octave/README.md Illustrates the specific structure of the QUA configuration dictionary when integrating Octave. It highlights differences from standard OPX configurations, such as using RF_inputs/RF_outputs and an 'octaves' section for up/down-converter parameters. ```python # Example configuration structure for QUA with Octave: config = { "version": 1, "controllers": { "con1": { "type": "opx_controller", "host": "192.168.0.1", "port": 80, "latency": 300, "buffer_size": 1024 } }, "elements": { "octave_element": { "digital_switch": { "port": (1, 1) }, "RF_inputs": { "q0": { "port": (1, 1), "intermediate_frequency": 100e6, "lo_frequency": 4.5e9, "gain": 0 } }, "RF_outputs": { "q0": { "port": (1, 1), "intermediate_frequency": 100e6, "lo_frequency": 4.5e9, "gain": 0 } } } }, "octaves": { "octave1": { "con": "con1", "port": 50, "RF_inputs": { "q0": { "intermediate_frequency": 100e6, "lo_frequency": 4.5e9, "gain": 0 } }, "RF_outputs": { "q0": { "intermediate_frequency": 100e6, "lo_frequency": 4.5e9, "gain": 0 } } } } } ```