Skip to content

Commit

Permalink
Merge pull request #72 from gcalin/develop
Browse files Browse the repository at this point in the history
Add support for multi-register circuit conversion
  • Loading branch information
yao-cqc authored Dec 22, 2023
2 parents e17574a + 243f1a4 commit 8e46736
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 1 addition & 2 deletions pytket/extensions/qulacs/backends/qulacs_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
from pytket.circuit import Pauli
from pytket.passes import auto_rebase_pass
from pytket.pauli import QubitPauliString
from pytket.architecture import Architecture
from pytket.utils.operators import QubitPauliOperator
from pytket.utils.outcomearray import OutcomeArray
from pytket.extensions.qulacs.qulacs_convert import (
Expand Down Expand Up @@ -291,7 +290,7 @@ def get_operator_expectation_value(
self._check_all_circuits([state_circuit], nomeasure_warn=False)

observable = Observable(state_circuit.n_qubits)
for (qps, coeff) in operator._dict.items():
for qps, coeff in operator._dict.items():
_items = []
if qps != QubitPauliString():
for qubit, pauli in qps.map.items():
Expand Down
5 changes: 5 additions & 0 deletions pytket/extensions/qulacs/qulacs_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import numpy as np
from qulacs import QuantumCircuit, gate
from pytket.circuit import Circuit, OpType
from pytket.passes import FlattenRegisters

_ONE_QUBIT_GATES = {
OpType.X: gate.X,
Expand All @@ -43,6 +44,10 @@ def tk_to_qulacs(
) -> QuantumCircuit:
"""Convert a pytket circuit to a qulacs circuit object."""
circ = circuit.copy()

if not circ.is_simple:
FlattenRegisters().apply(circ)

if replace_implicit_swaps:
circ.replace_implicit_wire_swaps()
n_qubits = circ.n_qubits
Expand Down

0 comments on commit 8e46736

Please sign in to comment.