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

Tuple unpacking bug fix in cut finder. (backport #591) #593

Merged
merged 1 commit into from
May 15, 2024
Merged
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
2 changes: 1 addition & 1 deletion circuit_knitting/cutting/cut_finding/cutting_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ def next_state_primitive(
new_state.bell_pairs.append((r2, rnew_2))
new_state.gamma_UB *= 16

new_state.add_action(self, gate_spec, ((1, w1, rnew_1), (2, w2, rnew_2)))
new_state.add_action(self, gate_spec, (1, w1, rnew_1), (2, w2, rnew_2))

return [new_state]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Action(NamedTuple):

action: DisjointSearchAction
gate_spec: GateSpec
args: list
args: list | tuple


class GateCutLocation(NamedTuple):
Expand Down Expand Up @@ -430,12 +430,12 @@ def add_action(
self,
action_obj: DisjointSearchAction,
gate_spec: GateSpec,
args: tuple | None = None,
*args: tuple,
) -> None:
"""Append the specified action to the list of search-space actions that have been performed."""
if action_obj.get_name() is not None:
self.actions = cast(list, self.actions)
self.actions.append(Action(action_obj, gate_spec, [args]))
self.actions.append(Action(action_obj, gate_spec, args))

def get_search_level(self) -> int:
"""Return the search level."""
Expand Down
6 changes: 3 additions & 3 deletions test/cutting/cut_finding/test_best_first_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,23 +114,23 @@ def test_best_first_search(test_circuit: SimpleGateList):
gate=CircuitElement(name="cx", params=[], qubits=[3, 4], gamma=3),
cut_constraints=None,
),
[((1, 3), (2, 4))],
(((1, 3), (2, 4)),),
),
(
GateSpec(
instruction_id=13,
gate=CircuitElement(name="cx", params=[], qubits=[3, 5], gamma=3),
cut_constraints=None,
),
[((1, 3), (2, 5))],
(((1, 3), (2, 5)),),
),
(
GateSpec(
instruction_id=14,
gate=CircuitElement(name="cx", params=[], qubits=[3, 6], gamma=3),
cut_constraints=None,
),
[((1, 3), (2, 6))],
(((1, 3), (2, 6)),),
),
]

Expand Down