Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions cirq-core/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]] + [
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm surprised that this didn't cause any unit tests to fail.

Can you add a test that validates the generated circuit(s) against a known gateset that resembles what we've already published via the Virtual Quantum Engine? e.g., you might check against a ValidatingTestDevice.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's because none of the test examin the internals of the circuits but treat the circuits as blackboxes with a specific behaviour => it checks things like pauli errors and other characterisitics.

added a test for now

adjoint.to_phased_xz_gate()(qubit)
]


def _random_two_q_clifford(
Comment thread
wcourtney marked this conversation as resolved.
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():
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)