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

Transpiler refactor #1500

Merged
merged 37 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
2c7190e
fix: update connectivity in default transpiler
Oct 17, 2024
e1e769a
fix: remove initial_layout & use wire_names & update test files
Oct 22, 2024
2a888ad
fix: update code-examples
Oct 23, 2024
05b6f68
fix: update comparison in test_bell_state_3q
Oct 23, 2024
876b79c
feat: circuit draw with int qubit names
Oct 23, 2024
02e9945
fix: placer.py coverage
Oct 23, 2024
05f36e7
fix: circuit.py coverage
Oct 23, 2024
01b667d
fix: router.py coverage
Oct 23, 2024
4e21132
fix: remove dead codes
Oct 24, 2024
12bf8b0
fix: refactor connectivity graphs in test files
Oct 24, 2024
36c1348
fix: return type of a router
Oct 24, 2024
f19dc6e
fix: minor changes
Oct 25, 2024
7534ef2
fix: remove add_nodes_from when setting backend
Oct 25, 2024
67fae1f
fix: Circuit remove default wire_names / dict wire_names
Oct 28, 2024
2ac1a85
fix: wire_names update docstrings
Oct 28, 2024
788fd06
fix: line connectivity remove fixture
Oct 28, 2024
4e3dbce
fix: test files default qubit
Oct 28, 2024
d4e507c
fix: refactor assert functions
Oct 28, 2024
5cf75b5
fix: refactor assert funcs
Oct 28, 2024
942991a
fix: pandoc update result draw()
Oct 28, 2024
25d8788
fix: pandoc update
Oct 28, 2024
93ac772
feat: Circuit __init__ int/list first arg init
Oct 28, 2024
41f5eff
fix: Circuit._parse -> _resolve_qubits
Oct 28, 2024
a4f2092
fix: minor updates / update docstring of qibo.Circuit
Oct 30, 2024
10be459
fix: update test files _resolve_qubits / wire_names setter
Oct 30, 2024
a1d3302
fix: combine similar assert func to assert_placement
Oct 30, 2024
0851eeb
fix: minor test files update
Oct 30, 2024
ec37f34
Merge branch 'master' into transpiler_refactor
Nov 4, 2024
32c9ac2
Merge branch 'master' into transpiler_refactor
csookim Nov 8, 2024
ff89c58
Merge branch 'master' into transpiler_refactor
Nov 19, 2024
824bb76
passes move connectivity check to __call__
Nov 21, 2024
214a4ea
fix: remove Trivial and Custom
Nov 22, 2024
abed4b9
fix: remove default star transpiler / enforce connectivity
Nov 22, 2024
ad079de
fix: modify is_satisfied
Nov 22, 2024
1f55f3c
fix: revert, make connectivity optiona
Nov 22, 2024
797331e
fix: type errors, Preprocessor connectivity check, utils.py -> assert…
Nov 25, 2024
049ff01
fix: utils -> asserts
Nov 25, 2024
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
Prev Previous commit
Next Next commit
fix: placer.py coverage
  • Loading branch information
changsookim committed Oct 23, 2024
commit 02e99457a90a37cbb23f391be981f42812159ae0
6 changes: 0 additions & 6 deletions src/qibo/transpiler/placer.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,6 @@ class Custom(Placer):
def __init__(self, initial_map: Union[list, dict], connectivity: nx.Graph):
self.initial_map = initial_map
self.connectivity = connectivity
if self.initial_map is None:
raise_error(ValueError, "Initial mapping must be provided.")
if self.connectivity is None:
raise_error(ValueError, "Connectivity graph must be provided.")

def __call__(self, circuit: Circuit):
"""Apply the custom placement to the given circuit.
Expand Down Expand Up @@ -198,8 +194,6 @@ class Subgraph(Placer):

def __init__(self, connectivity: nx.Graph):
self.connectivity = connectivity
if self.connectivity is None:
raise_error(ValueError, "Connectivity graph must be provided.")

def __call__(self, circuit: Circuit):
"""Find the initial layout of the given circuit using subgraph isomorphism.
Expand Down
20 changes: 20 additions & 0 deletions tests/test_transpiler_placer.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ def test_assert_placement_false(qubits, names):
assert_placement(circuit, connectivity)


@pytest.mark.parametrize("qubits", [10, 1])
def test_assert_placement_error(qubits):
connectivity = star_connectivity()
circuit = Circuit(qubits)
with pytest.raises(PlacementError):
assert_placement(circuit, connectivity)


@pytest.mark.parametrize("names", [["A", "B", "C", "D", "E"], [0, 1, 2, 3, 4]])
def test_mapping_consistency(names):
assert_mapping_consistency(names, star_connectivity(names))
Expand Down Expand Up @@ -106,6 +114,13 @@ def test_trivial():
assert_placement(circuit, connectivity)


def test_trivial_error():
connectivity = star_connectivity()
placer = Trivial(connectivity=connectivity)
with pytest.raises(ValueError):
placer()


def test_trivial_restricted():
names = ["q0", "q2"]
circuit = Circuit(2, wire_names=names)
Expand Down Expand Up @@ -313,3 +328,8 @@ def test_star_connectivity_placer_error(first):
placer = StarConnectivityPlacer(connectivity)
with pytest.raises(PlacementError):
placer(circ)

chip = nx.Graph()
chip.add_edges_from([(0, 1), (1, 2), (2, 3), (3, 4)])
with pytest.raises(ValueError):
StarConnectivityPlacer(chip)