Skip to content

Commit

Permalink
Write tests for channel reuse.:
Browse files Browse the repository at this point in the history
  • Loading branch information
deanpoulos committed Oct 11, 2024
1 parent d5afb07 commit d299db7
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 2 deletions.
42 changes: 42 additions & 0 deletions tests/wirer/test_block_channels.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
from dataclasses import asdict

import pytest

from qualang_tools.wirer import *
from qualang_tools.wirer.connectivity.element import QubitReference
from qualang_tools.wirer.connectivity.wiring_spec import WiringLineType
from qualang_tools.wirer.instruments.instrument_channel import InstrumentChannelLfFemOutput, \
InstrumentChannelMwFemInput, InstrumentChannelMwFemOutput

visualize_flag = pytest.visualize_flag

def test_alternating_blocking_of_used_channels(instruments_2lf_2mw):
connectivity = Connectivity()

connectivity.add_qubit_drive_lines(qubits=1)
allocate_wiring(connectivity, instruments_2lf_2mw, block_used_channels=False)

connectivity.add_qubit_drive_lines(qubits=2)
allocate_wiring(connectivity, instruments_2lf_2mw)

connectivity.add_qubit_drive_lines(qubits=3)
allocate_wiring(connectivity, instruments_2lf_2mw, block_used_channels=False)

connectivity.add_qubit_drive_lines(qubits=4)
allocate_wiring(connectivity, instruments_2lf_2mw)

if visualize_flag:
visualize(connectivity.elements, instruments_2lf_2mw.available_channels)

expected_ports = [
1, # q1 allocated to 1, but channel isn't blocked
1, # q2 allocated to 1, since it wasn't blocked
2, # q3 allocated to 2, since it's the next available channel, but not blocked
2 # q4 allocated to 2, since it wasn't blocked
]
for qubit_index in [1, 2, 3, 4]:
drive_channels = connectivity.elements[QubitReference(qubit_index)].channels[WiringLineType.DRIVE]
for i, channel in enumerate(drive_channels):
assert asdict(channel) == asdict([
InstrumentChannelMwFemOutput(con=1, slot=3, port=expected_ports[qubit_index-1])
][i])
4 changes: 2 additions & 2 deletions tests/wirer/test_wirer_channel_reuse.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ def test_5q_allocation_with_channel_reuse(instruments_2lf_2mw):

allocate_wiring(connectivity, instruments_2lf_2mw, block_used_channels=False)

if visualize_flag:
visualize(connectivity.elements, instruments_2lf_2mw.available_channels)
# if visualize_flag:
visualize(connectivity.elements, instruments_2lf_2mw.available_channels)

for qubit in [1, 3]:
# resonator lines re-used for qubits 1 & 3
Expand Down

0 comments on commit d299db7

Please sign in to comment.