-
-
Notifications
You must be signed in to change notification settings - Fork 162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Classical Shadows] quantum processing and test #1906
[Classical Shadows] quantum processing and test #1906
Conversation
…dows/rotation-gates
This reverts commit 517266f.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Min-Li it looks like a few of my previous comments were resolved without a change / comment. I unresolved a few of my previous comments. Please make sure to leave a comment if you are not going to make the requested change before resolving.
Co-authored-by: nate stemen <nate@stemen.email>
Co-authored-by: nate stemen <nate@stemen.email>
@natestemen Hi Nate, I resolved some conversations without leaving comments since I already address your comments in some previous commits. I will add comments before resolving conversations later. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank @Min-Li, LGTM, for the api-doc part.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @Min-Li, good form my side. But please let's wait for Nate's approval before merging this PR.
I also left a suggestion to explain that the executor is expected to return a single shot.
Co-authored-by: Andrea Mari <andreamari84@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work Min. I think this is pretty much ready to go from my POV.
Please make sure to add tqdm
to our dev_requirements.txt
file.
@pytest.mark.parametrize("executor", [cirq_executor, qiskit_executor]) | ||
def test_random_pauli_measurement_time_power_growth( | ||
executor: Callable, | ||
): | ||
"""Test that random_pauli_measurement scales follow power law with the | ||
number of measurements.""" | ||
n_qubits = [3, 6, 9, 12, 15] | ||
|
||
times = [] | ||
for n in n_qubits: | ||
qubits = cirq.LineQubit.range(n) | ||
circuit = simple_test_circuit(qubits) | ||
start_time = time.time() | ||
random_pauli_measurement( | ||
circuit, | ||
100, # number of total measurements | ||
executor=executor, | ||
) | ||
|
||
times.append(time.time() - start_time) | ||
for i in range(1, len(times)): | ||
log_ratio_times = np.log(times[i] / times[i - 1]) | ||
log_ratio_qubits = np.log(n_qubits[i] / n_qubits[i - 1]) | ||
assert log_ratio_times == pytest.approx(log_ratio_qubits, rel=5) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we remove this test? It's quite slow, and it's not testing the correctness of the code. I ran pytest mitiq/shadows --durations=15
to get the tests ordered by speed in descending order.
==================================================================== slowest 15 durations =============================================
13.96s call mitiq/shadows/test/test_quantum_processing.py::test_random_pauli_measurement_time_power_growth[qiskit_executor]
3.96s call mitiq/shadows/test/test_quantum_processing.py::test_random_pauli_measurement_time_growth[qiskit_executor]
1.14s call mitiq/shadows/test/test_quantum_processing.py::test_random_pauli_measurement_time_power_growth[cirq_executor]
0.40s call mitiq/shadows/test/test_quantum_processing.py::test_generate_random_pauli_strings_time
0.30s call mitiq/shadows/test/test_quantum_processing.py::test_random_pauli_measurement_output_types[qiskit_executor-2]
0.30s call mitiq/shadows/test/test_quantum_processing.py::test_random_pauli_measurement_output_dimensions[qiskit_executor-5]
0.30s call mitiq/shadows/test/test_quantum_processing.py::test_random_pauli_measurement_output_dimensions[qiskit_executor-2]
0.29s call mitiq/shadows/test/test_quantum_processing.py::test_random_pauli_measurement_no_errors[qiskit_executor-5]
0.29s call mitiq/shadows/test/test_quantum_processing.py::test_random_pauli_measurement_output_types[qiskit_executor-5]
0.28s call mitiq/shadows/test/test_quantum_processing.py::test_random_pauli_measurement_no_errors[qiskit_executor-1]
0.27s call mitiq/shadows/test/test_quantum_processing.py::test_random_pauli_measurement_no_errors[qiskit_executor-2]
0.20s call mitiq/shadows/test/test_quantum_processing.py::test_random_pauli_measurement_output_types[qiskit_executor-1]
0.20s call mitiq/shadows/test/test_quantum_processing.py::test_random_pauli_measurement_output_dimensions[qiskit_executor-1]
0.15s call mitiq/shadows/test/test_quantum_processing.py::test_random_pauli_measurement_time_growth[cirq_executor]
0.01s call mitiq/shadows/test/test_quantum_processing.py::test_random_pauli_measurement_output_dimensions[cirq_executor-5]
@natestemen, @Min-Li, I hesitate to add a new dependency to Mitiq. My understanding is that |
Wanted just to comment that the errors in CI in build-docs occurred in the |
…` if len(result.get_counts().keys()) > 1: assert len(result.get_counts().keys()) == 1, ( "The `executor` must return a `MeasurementResult`" " for a single shot" )`
Co-authored-by: nate stemen <nate@stemen.email>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your patience Min. This looks good! 🚢
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After updating the warning in the function docstring consistently with the new ValueError
, this looks good to me!
Co-authored-by: Andrea Mari <andreamari84@gmail.com>
@Misty-W Hey Misty, thanks for your comment |
Description
z basis measurement and test from #1899
License
Before opening the PR, please ensure you have completed the following where appropriate.