Skip to content

Commit

Permalink
support to bias flux pulses and fix error referring rf & dc dacs
Browse files Browse the repository at this point in the history
  • Loading branch information
aorgazf committed Oct 15, 2024
1 parent 2a52cc3 commit b477c2a
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/qibolab/instruments/rfsoc/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def _(qubit: Qubit) -> rfsoc.Qubit:
"""Convert `qibolab.platforms.abstract.Qubit` to
`qibosoq.abstract.Qubit`."""
if qubit.flux:
return rfsoc.Qubit(qubit.flux.offset, parse_port_name("DCO", qubit.flux.port.name))
return rfsoc.Qubit(qubit.flux.offset, parse_port_name("DCO", qubit.flux.port.name), parse_port_name("RFO", qubit.flux.port.name))
return rfsoc.Qubit(0.0, None)


Expand Down
81 changes: 76 additions & 5 deletions src/qibolab/instruments/rfsoc/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from qibolab.result import AveragedSampleResults, IntegratedResults, SampleResults
from qibolab.sweeper import BIAS, Sweeper

from .convert import convert, convert_units_sweeper
from .convert import convert, convert_units_sweeper, parse_port_name

HZ_TO_MHZ = 1e-6
NS_TO_US = 1e-3
Expand All @@ -32,7 +32,21 @@ class RFSoCPort(Port):
name: int
"""DAC number."""
offset: float = 0.0
"""Amplitude factor for biasing."""

# @property
# def offset(self) -> float:
# """Amplitude factor for biasing."""
# return self._offset

# @offset.setter
# def offset(self, value):
# self._offset = value
# dac = parse_port_name("DCO", self.name)
# server_commands = {
# "operation_code": rfsoc.OperationCode.SET_BIAS,
# "dac_bias": {dac: value},
# }
# RFSoC._try_to_execute(server_commands, self.host, self.port)


class RFSoC(Controller):
Expand Down Expand Up @@ -213,12 +227,43 @@ def _execute_sweeps(
}
return self._try_to_execute(server_commands, self.host, self.port)





def set_bias(self, qubits:dict[int, Qubit], mode: str = "sweetspot"):
dac_bias = {}
for qubit in qubits.values():
if qubit.flux:
dac = parse_port_name("DCO", qubit.flux.port.name)
bias = qubit.flux.offset if mode == "sweetspot" else 0
dac_bias[dac] = bias
server_commands = {
"operation_code": rfsoc.OperationCode.SET_BIAS,
"dac_bias": dac_bias,
}
self._try_to_execute(server_commands, self.host, self.port)


def play(
self,
qubits: dict[int, Qubit],
couplers: dict[int, Coupler],
sequence: PulseSequence,
execution_parameters: ExecutionParameters,
) -> dict[str, Union[IntegratedResults, SampleResults]]:
self.set_bias(qubits, "sweetspot")
results = self._play(qubits, couplers, sequence, execution_parameters)
self.set_bias(qubits, "zero")

return results

def _play(
self,
qubits: dict[int, Qubit],
couplers: dict[int, Coupler],
sequence: PulseSequence,
execution_parameters: ExecutionParameters,
) -> dict[str, Union[IntegratedResults, SampleResults]]:
"""Execute the sequence of instructions and retrieves readout results.
Expand Down Expand Up @@ -327,7 +372,7 @@ def play_sequence_in_sweep_recursion(
readout pulses serials and are convert to match the original
sequence (of the sweep) and not the one just executed.
"""
res = self.play(qubits, couplers, sequence, execution_parameters)
res = self._play(qubits, couplers, sequence, execution_parameters)
newres = {}
serials = [pulse.serial for pulse in or_sequence.ro_pulses]
for idx, key in enumerate(res):
Expand Down Expand Up @@ -398,7 +443,17 @@ def recursive_python_sweep(
for jdx, kdx in enumerate(sweeper.indexes):
sweeper_parameter = sweeper.parameters[jdx]
if sweeper_parameter is rfsoc.Parameter.BIAS:
qubits[list(qubits)[kdx]].flux.offset = values[jdx][idx]
qubit = qubits[list(qubits)[kdx]]

dac = parse_port_name("DCO", qubit.flux.port.name)
bias = values[jdx][idx]
qubit.flux.offset = bias
server_commands = {
"operation_code": rfsoc.OperationCode.SET_BIAS,
"dac_bias": {dac: bias},
}
self._try_to_execute(server_commands, self.host, self.port)

elif sweeper_parameter in rfsoc.Parameter.variants(
{
"amplitude",
Expand Down Expand Up @@ -540,7 +595,7 @@ def convert_sweep_results(
results[ro_pulse.qubit] = results[ro_pulse.serial] = result
return results

def sweep(
def _sweep(
self,
qubits: dict[int, Qubit],
couplers: dict[int, Coupler],
Expand Down Expand Up @@ -608,3 +663,19 @@ def sweep(
qubit.flux.offset = initial_biases[idx]

return self.reshape_sweep_results(results, sweepers, execution_parameters)



def sweep(
self,
qubits: dict[int, Qubit],
couplers: dict[int, Coupler],
sequence: PulseSequence,
execution_parameters: ExecutionParameters,
*sweepers: Sweeper,
) -> dict[str, Union[IntegratedResults, SampleResults]]:
self.set_bias(qubits, "sweetspot")
results = self._sweep(qubits, couplers, sequence, execution_parameters, *sweepers)
self.set_bias(qubits, "zero")

return results

0 comments on commit b477c2a

Please sign in to comment.