Skip to content

Commit

Permalink
Merge branch 'develop' into 'main'
Browse files Browse the repository at this point in the history
Rivet v1.0.11

See merge request haiqu-ai/qml-transpiler!38
  • Loading branch information
ogorodnikov committed Sep 24, 2024
2 parents faec4aa + b316b55 commit 9598b6b
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 14 deletions.
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
readme = "README.md"
authors = [{ name = "Haiqu Inc.", email = "info@haiqu.ai" }]
license = { file = "LICENSE" }
version = "1.0.10"
version = "1.0.11"
requires-python = ">= 3.10"
dependencies = [
"qiskit <= 1.0.2",
Expand Down Expand Up @@ -46,7 +46,7 @@

[project.optional-dependencies]

bqskit = ["bqskit >= 1.1.1"]
bqskit = ["bqskit <= 1.1.2"]

pytket = ["pytket >= 1.31.0",
"pytket-qiskit >= 0.51.0",
Expand Down
18 changes: 6 additions & 12 deletions rivet_transpiler/transpiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,9 @@ def transpile_right(central_circuit, right_circuit,

# Transpile and Compose

if backend is not None and backend.coupling_map is not None:
full_map = get_full_map(central_circuit)

full_map = get_full_map(central_circuit)

key_arguments['initial_layout'] = full_map[:right_circuit.num_qubits]
key_arguments['initial_layout'] = full_map[:right_circuit.num_qubits]

transpiled_right_circuit = transpile(
right_circuit,
Expand Down Expand Up @@ -189,7 +187,10 @@ def transpile_right(central_circuit, right_circuit,

if transpiled_right_circuit.layout.final_layout is None:

right_routing = list(range(transpiled_right_circuit.num_qubits))
resulting_qubits_count = max(central_circuit.num_qubits,
transpiled_right_circuit.num_qubits)

right_routing = list(range(resulting_qubits_count))

else:
right_routing = [transpiled_right_circuit.layout.final_layout[qubit]
Expand All @@ -211,13 +212,6 @@ def transpile_right(central_circuit, right_circuit,

resulting_circuit._layout = transpile_layout

# Printouts

# print("central_routing:", central_routing)
# print("right_routing:", right_routing)
# print("final_routing:", final_routing)
# print("final_layout:", final_layout)

return resulting_circuit


Expand Down
27 changes: 27 additions & 0 deletions tests/test_transpiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

from rivet_transpiler import get_full_map
from rivet_transpiler import get_litmus_circuit
from rivet_transpiler import get_used_qubit_indices


# Test Transpile Functions
Expand Down Expand Up @@ -65,6 +66,32 @@ def test_transpile_right(litmus_circuit, backend):
assert transpiled_right_circuit


def test_transpile_right_target(litmus_circuit, backend):

target = backend.target if backend else None

transpiled_litmus_circuit = qiskit.transpile(
litmus_circuit,
target=target,
seed_transpiler=1234)

transpiled_right_circuit = transpile_right(
central_circuit=transpiled_litmus_circuit,
right_circuit=litmus_circuit,
target=target,
seed_transpiler=1234)

litmus_qubits_count = len(
get_used_qubit_indices(
litmus_circuit))

transpiled_right_qubits_count = len(
get_used_qubit_indices(
transpiled_right_circuit))

assert litmus_qubits_count == transpiled_right_qubits_count


def test_transpile_left(litmus_circuit, backend):

transpiled_litmus_circuit = qiskit.transpile(
Expand Down

0 comments on commit 9598b6b

Please sign in to comment.