Skip to content

Commit

Permalink
Merge branch 'main' into u/smeeks/rm_sphinx
Browse files Browse the repository at this point in the history
  • Loading branch information
tanujkhattar authored Jan 19, 2024
2 parents 00dfb84 + ba4c6aa commit ebe1283
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
12 changes: 8 additions & 4 deletions cirq-core/cirq/experiments/qubit_characterizations.py
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,9 @@ def _create_parallel_rb_circuit(
num_moments = max(len(sequence) for sequence in sequences_to_zip)
for q, sequence in zip(qubits, sequences_to_zip):
if (n := len(sequence)) < num_moments:
sequence.extend([ops.SingleQubitCliffordGate.I(q)] * (num_moments - n))
sequence.extend(
[ops.SingleQubitCliffordGate.I.to_phased_xz_gate()(q)] * (num_moments - n)
)
moments = zip(*sequences_to_zip)
return circuits.Circuit.from_moments(*moments, ops.measure_each(*qubits))

Expand Down Expand Up @@ -739,13 +741,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-core/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():
qubits = [GridQubit(0, i) for i in range(4)]
clifford_group = cirq.experiments.qubit_characterizations._single_qubit_cliffords()
c = cirq.experiments.qubit_characterizations._create_parallel_rb_circuit(
qubits, 5, clifford_group.c1_in_xy
)
device = cirq.testing.ValidatingTestDevice(
qubits=qubits, allowed_gates=(cirq.ops.PhasedXZGate, cirq.MeasurementGate)
)
device.validate_circuit(c)

0 comments on commit ebe1283

Please sign in to comment.