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

Qcodes driver fix #190

Open
wants to merge 4 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
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import numpy as np
import os
import qcodes as qc
from qcodes import initialise_or_create_database_at, load_or_create_experiment
Expand Down
1 change: 1 addition & 0 deletions examples/Qcodes_drivers/basic-driver/hello_qcodes.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import numpy as np
import qcodes as qc
from qcodes import initialise_or_create_database_at, load_or_create_experiment
from qcodes.utils.dataset.doNd import do2d, do1d, do0d
Expand Down
1 change: 1 addition & 0 deletions examples/Qcodes_drivers/stability-diagram/raster_scan.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import numpy as np
import qcodes as qc
from qcodes import initialise_or_create_database_at, load_or_create_experiment
from qcodes.utils.dataset.doNd import do2d, do1d, do0d
Expand Down
1 change: 1 addition & 0 deletions examples/Qcodes_drivers/stability-diagram/spiral_scan.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import numpy as np
import qcodes as qc
from qcodes import initialise_or_create_database_at, load_or_create_experiment
from qcodes.utils.dataset.doNd import do2d, do1d, do0d
Expand Down
1 change: 0 additions & 1 deletion qualang_tools/external_frameworks/qcodes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ open a quantum machine, simulate, compile and execute QUA programs.
* ``open_qm()``: Open a quantum machine with a given configuration ready to execute a program.
* ``update_qm()``: Close and re-open a new quantum machine so that it reloads the configuration in case it has been updated.
* ``update_readout_length(readout_element, readout_operation, new_length)``: Update locally the readout length of a given readout operation and readout element.
* ``get_prog()``: Get the implemented QUA program.
* ``get_res()``: Get the results from the OPX.
* ``set_sweep_parameters(scanned_axis, setpoints, unit=None, label=None)``: Set the setpoints based on the sweep parameters.
* ``get_measurement_parameter(scale_factor=[(),])``: Find the correct Parameter shape based on the stream-processing and return the measurement Parameter. If 'I' and 'Q' are saved in the stream_processing, then the amplitude 'R' and phase 'Phi' will also be returned. Additionally, the default unit for the raw adc traces, and the results from the integration and demodulation methods are automatically converted into Volts. It is however possible to convert it to another unit by specifying a scale factor as an input parameter of the form [(name of the variable, conversion factor, new unit), ], as in ``scale_factor=[("I", 1235, "pA"), ("Q", 1235, "pA")]``.
Expand Down
33 changes: 5 additions & 28 deletions qualang_tools/external_frameworks/qcodes/opx_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,12 @@
)
from qcodes.utils.validators import Numbers, Arrays
from qm import SimulationConfig, generate_qua_script
from qm.qua import program
from qm.QuantumMachinesManager import QuantumMachinesManager
from qualang_tools.results import wait_until_job_is_paused
from qualang_tools.results import fetching_tool
from qualang_tools.plot import interrupt_on_close
import matplotlib.pyplot as plt
import numpy as np
import warnings

warnings.filterwarnings("ignore")


# noinspection PyAbstractClass
Expand Down Expand Up @@ -49,6 +45,7 @@ def __init__(
self.qm = None
self.qm_id = None
self.qmm = None
self.qua_program = None
self.close_other_machines = close_other_machines
self.config = None
self.result_handles = None
Expand Down Expand Up @@ -244,24 +241,6 @@ def update_qm(self):
self.qm.close()
self.open_qm(self.close_other_machines)

# Empty method that can be replaced by your pulse sequence in the main script
# This can also be modified so that you can put the sequences here directly...
def qua_program(self):
"""
Custom QUA program

:return: QUA program
"""
with program() as prog:
pass
return prog

# @abstractmethod
def get_prog(self):
"""Get the QUA program from the user"""
prog = self.qua_program
return prog

# @abstractmethod
def get_res(self):
"""
Expand Down Expand Up @@ -414,7 +393,7 @@ def get_measurement_parameter(self, scale_factor=((),)):
}
# Add amplitude and phase if I and Q are in the SP
if len(self.results["names"]) == 0:
self._get_stream_processing(self.get_prog())
self._get_stream_processing(self.qua_program)

if "I" in self.results["names"] and "Q" in self.results["names"]:
self.results["names"].append("R")
Expand Down Expand Up @@ -594,12 +573,11 @@ def run_exp(self):
"""
Execute a given QUA program, initialize the counter to 0 and creates a result handle to fetch the results.
"""
prog = self.get_prog()
if " demod" in generate_qua_script(prog, self.config):
if " demod" in generate_qua_script(self.qua_program, self.config):
self.demod_factor = 2
else:
self.demod_factor = 1
self.job = self.qm.execute(prog)
self.job = self.qm.execute(self.qua_program)
self.counter = 0
self.result_handles = self.job.result_handles

Expand Down Expand Up @@ -637,8 +615,7 @@ def simulate(self):
"""
Simulate a given QUA program and store the simulated waveform into the simulated_wf attribute.
"""
prog = self.get_prog()
self.job = self.qmm.simulate(self.config, prog, SimulationConfig(self.sim_time() // 4))
self.job = self.qmm.simulate(self.config, self.qua_program, SimulationConfig(self.sim_time() // 4))
simulated_samples = self.job.get_simulated_samples()
for con in [f"con{i}" for i in range(1, 10)]:
if hasattr(simulated_samples, con):
Expand Down
Loading