docs: fix decoherence noise example missing wrap_in_numshots_loop#1844
Open
ddri wants to merge 1 commit intorigetti:masterfrom
Open
docs: fix decoherence noise example missing wrap_in_numshots_loop#1844ddri wants to merge 1 commit intorigetti:masterfrom
ddri wants to merge 1 commit intorigetti:masterfrom
Conversation
Fixes rigetti#1402 The "Adding Decoherence Noise" example was missing a call to wrap_in_numshots_loop(1000) before executing the quantum program. Without it, the program runs with only 1 shot (the default), making the statistical calculations (np.mean over bitstrings) meaningless. This fix adds the missing line, matching the pattern used in all other examples in the same documentation file (amplitude damping, dephased CZ, readout noise examples). The T2 parameter is left as T2=t1/2, which: - Matches the documented intent (line 670: "By default, T2 = T1 / 2") - Satisfies the physics constraint (T2 <= 2*T1) - Is more realistic than T2=2*t1 (theoretical maximum)
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1402
Summary
The "Adding Decoherence Noise" documentation example was missing a call to
wrap_in_numshots_loop(1000)before executing the quantum program, causing the statistical calculations to be performed on only a single measurement instead of 1000.Changes
noisy.wrap_in_numshots_loop(1000)beforeqc.run(noisy)in the decoherence noise exampleAnalysis
Without
wrap_in_numshots_loop(), programs run with the defaultnum_shots=1, producing a bitstrings array of shape(1, 2). The example then computesnp.mean(bitstrings, axis=0)which averages over a single sample, making the statistics meaningless.This fix matches the pattern used in all other examples in the same documentation file:
wrap_in_numshots_loop(trials)wrap_in_numshots_loop(trials)wrap_in_numshots_loop()Note on T2 Parameter
The T2 parameter was left as
T2=t1/2, which:T2=2*t1(which is the theoretical maximum)The issue originally reported T2 as missing, but it was already added in a previous commit (likely during PR #1574 "Add doctests"), though the
wrap_in_numshots_loopwas still missing.Testing
Verified that:
num_shots = 1(confirmed inpyquil/quil.py:140)wrap_in_numshots_loop()beforeqc.run()(seetest/unit/test_quantum_computer.py)bitstrings.shape == (num_shots, num_qubits)