Skip to content

Commit

Permalink
convert cliffords to xz in qubit characterization (quantumlib#6420)
Browse files Browse the repository at this point in the history
  • Loading branch information
NoureldinYosri authored Jan 19, 2024
1 parent 8caa497 commit 3dbbdf1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
8 changes: 5 additions & 3 deletions cirq/experiments/qubit_characterizations.py
Original file line number Diff line number Diff line change
Expand Up @@ -739,13 +739,15 @@ def _two_qubit_clifford_matrices(


def _random_single_q_clifford(
qubit: 'cirq.Qid', num_cfds: int, cfds: Sequence[Sequence['cirq.Gate']]
qubit: 'cirq.Qid', num_cfds: int, cfds: Sequence[Sequence['cirq.ops.SingleQubitCliffordGate']]
) -> List['cirq.Operation']:
clifford_group_size = 24
operations = [[gate(qubit) for gate in gates] for gates in cfds]
operations = [[gate.to_phased_xz_gate()(qubit) for gate in gates] for gates in cfds]
gate_ids = list(np.random.choice(clifford_group_size, num_cfds))
adjoint = _reduce_gate_seq([gate for gate_id in gate_ids for gate in cfds[gate_id]]) ** -1
return [op for gate_id in gate_ids for op in operations[gate_id]] + [adjoint(qubit)]
return [op for gate_id in gate_ids for op in operations[gate_id]] + [
adjoint.to_phased_xz_gate()(qubit)
]


def _random_two_q_clifford(
Expand Down
12 changes: 12 additions & 0 deletions cirq/experiments/qubit_characterizations_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,3 +227,15 @@ def test_tomography_plot_raises_for_incorrect_number_of_axes():
with pytest.raises(ValueError):
_, axes = plt.subplots(1, 3)
result.plot(axes)


def test_single_qubit_cliffords_gateset():
qubit = GridQubit(0, 0)
clifford_group = cirq.experiments.qubit_characterizations._single_qubit_cliffords()
c = cirq.experiments.qubit_characterizations._create_parallel_rb_circuit(
(qubit,), 3, clifford_group.c1_in_xy
)
device = cirq.testing.ValidatingTestDevice(
qubits=(qubit,), allowed_gates=(cirq.ops.PhasedXZGate, cirq.MeasurementGate)
)
device.validate_circuit(c)

0 comments on commit 3dbbdf1

Please sign in to comment.