Skip to content

Commit

Permalink
Merge pull request #1139 from qiboteam/to_circuit
Browse files Browse the repository at this point in the history
Add `Clifford.to_circuit` and `Clifford.copy` methods + initialization via circuits
  • Loading branch information
MatteoRobbiati authored Jan 10, 2024
2 parents 374f743 + 6844488 commit 2b7e4d8
Show file tree
Hide file tree
Showing 5 changed files with 834 additions and 144 deletions.
4 changes: 4 additions & 0 deletions doc/source/api-reference/qibo.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1420,6 +1420,10 @@ passing a symplectic matrix to the constructor.
symplectic_matrix = backend.zero_state(nqubits=3)
clifford = Clifford(symplectic_matrix, engine=NumpyBackend())
# The initialization above is equivalent to the initialization below
circuit = Circuit(nqubits=3)
clifford = Clifford(circuit, engine=NumpyBackend())

The generators of the stabilizers can be extracted with the
:meth:`qibo.quantum_info.clifford.Clifford.generators` method,
or the complete set of :math:`d = 2^{n}` stabilizers operators can be extracted through the
Expand Down
4 changes: 3 additions & 1 deletion src/qibo/backends/clifford.py
Original file line number Diff line number Diff line change
Expand Up @@ -627,13 +627,15 @@ def execute_circuit(self, circuit, initial_state=None, nshots: int = 1000):
for gate in circuit.queue:
state = gate.apply_clifford(self, state, nqubits)

return Clifford(
clifford = Clifford(
state,
measurements=circuit.measurements,
nshots=nshots,
engine=self.engine,
)

return clifford

except self.oom_error: # pragma: no cover
raise_error(
RuntimeError,
Expand Down
Loading

0 comments on commit 2b7e4d8

Please sign in to comment.