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
Next Next commit
fix: update connectivity in default transpiler
  • Loading branch information
changsookim committed Oct 17, 2024
commit 2c7190eb9bf245068b520e1096482bd73c86fc79
8 changes: 2 additions & 6 deletions src/qibo/backends/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,8 @@ def _default_transpiler(cls):
and natives is not None
and connectivity_edges is not None
):
# only for q{i} naming
node_mapping = {q: i for i, q in enumerate(qubits)}
edges = [
(node_mapping[e[0]], node_mapping[e[1]]) for e in connectivity_edges
]
connectivity = nx.Graph(edges)
connectivity = nx.Graph(connectivity_edges)
connectivity.add_nodes_from(qubits)

return Passes(
connectivity=connectivity,
Expand Down
5 changes: 2 additions & 3 deletions src/qibo/models/error_mitigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1172,9 +1172,8 @@ def _execute_circuit(circuit, qubit_map, noise_model=None, nshots=10000, backend
elif backend.name == "qibolab": # pragma: no cover
qubits = backend.qubits
connectivity_edges = backend.connectivity
node_mapping = {q: i for i, q in enumerate(qubits)}
edges = [(node_mapping[e[0]], node_mapping[e[1]]) for e in connectivity_edges]
connectivity = nx.Graph(edges)
connectivity = nx.Graph(connectivity_edges)
connectivity.add_nodes_from(qubits)
transpiler = Passes(
connectivity=connectivity,
passes=[Custom(initial_map=qubit_map, connectivity=connectivity)],
Expand Down
9 changes: 7 additions & 2 deletions tests/test_backends_global.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,13 @@ def natives(self):
_Global._backend = backend
transpiler = _Global.transpiler()

assert list(transpiler.connectivity.nodes) == [0, 1, 2, 3, 4]
assert list(transpiler.connectivity.edges) == [(0, 1), (1, 2), (2, 3), (3, 4)]
assert list(transpiler.connectivity.nodes) == ["A1", "A2", "A3", "A4", "A5"]
assert list(transpiler.connectivity.edges) == [
("A1", "A2"),
("A2", "A3"),
("A3", "A4"),
("A4", "A5"),
]
assert (
NativeGates.CZ in transpiler.native_gates
and NativeGates.GPI2 in transpiler.native_gates
Expand Down