Skip to content

Commit

Permalink
Fix TwoQubitRbDebugger issues and documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
deanpoulos committed Nov 29, 2024
1 parent ac63862 commit 120ea96
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ def __init__(self, rb: TwoQubitRb):
def run_phased_xz_commands(self, qmm: QuantumMachinesManager, num_averages: int):
"""
Run a program testing selected commands containing only combinations of PhasedXZ
gates which lead to a variery of transformations on the |00> staet.
This is useful for testing the 1Q component of your gate implementation.
gates and other fundamental gates, which lead to a variety of transformations on
the |00> state. This is useful for testing the 1Q component of the gate implementation.
"""
sequences_dict = {
r"I \otimes I": [720], # Identity on both qubits
Expand Down Expand Up @@ -53,9 +53,7 @@ def run_phased_xz_commands(self, qmm: QuantumMachinesManager, num_averages: int)
qm = qmm.open_qm(self.rb._config)
job = qm.execute(prog)

for sequence in tqdm(sequences, desc="Running test-sequences", unit="sequence"):
self.sequence_tracker.make_sequence(sequence)
self._insert_all_input_stream(job, sequence)
self._insert_all_input_stream(job, sequences)

job.result_handles.wait_for_all_values()
state = job.result_handles.get("state").fetch_all()
Expand All @@ -64,10 +62,12 @@ def run_phased_xz_commands(self, qmm: QuantumMachinesManager, num_averages: int)
self._analyze_phased_xz_commands_program(state, list(sequences_dict.keys()))

@run_in_thread
def _insert_all_input_stream(self, job, sequence):
job.insert_input_stream("__gates_len_is__", len(sequence))
for qe in self.rb._rb_baker.all_elements:
job.insert_input_stream(f"{qe}_is", self.rb._decode_sequence_for_element(qe, sequence))
def _insert_all_input_stream(self, job, sequences):
for sequence in tqdm(sequences, desc='Running test-sequences', unit='sequence'):
self.sequence_tracker.make_sequence(sequence)
job.insert_input_stream("__gates_len_is__", len(sequence))
for qe in self.rb._rb_baker.all_elements:
job.insert_input_stream(f"{qe}_is", self.rb._decode_sequence_for_element(qe, sequence))

def _phased_xz_commands_program(self, num_sequences: int, num_averages: int) -> Program:
with program() as prog:
Expand Down Expand Up @@ -95,7 +95,7 @@ def _phased_xz_commands_program(self, num_sequences: int, num_averages: int) ->
save(state, state_os)

with stream_processing():
state_os.buffer(num_sequences, num_averages).save("state")
state_os.buffer(num_averages).buffer(num_sequences).save("state")

return prog

Expand Down
28 changes: 27 additions & 1 deletion tests/two_qubit_rb/test_verification.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
cirq = pytest.importorskip("cirq")

from qualang_tools.bakery.bakery import Baking
from qualang_tools.characterization.two_qubit_rb import TwoQubitRb
from qualang_tools.characterization.two_qubit_rb import TwoQubitRb, TwoQubitRbDebugger


def test_all_verification(config):
Expand Down Expand Up @@ -57,3 +57,29 @@ def meas():
rb.print_command_mapping()
rb.print_sequences()
rb.verify_sequences()


def test_debugger(config):
def bake_phased_xz(baker: Baking, q, x, z, a):
pass

def bake_cz(baker: Baking, q1, q2):
pass

def bake_cnot(baker: Baking, q1, q2):
pass

def prep():
pass

def meas():
return None, None

cz_generator = {"CZ": bake_cz}

rb = TwoQubitRb(
config, bake_phased_xz, cz_generator, prep, meas, verify_generation=False, interleaving_gate=None
)

rb_debugger = TwoQubitRbDebugger(rb)
rb_debugger.run_phased_xz_commands(None, 100)

0 comments on commit 120ea96

Please sign in to comment.