Skip to content
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

Realistic noise simulation #1576

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
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
268 changes: 268 additions & 0 deletions docs/source/noise.rst

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion pyquil/api/_qpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ def _extract_memory_regions(
ro_sources: Dict[MemoryReference, str],
buffers: Dict[str, np.ndarray],
) -> Dict[str, np.ndarray]:

# hack to extract num_shots indirectly from the shape of the returned data
first, *rest = buffers.values()
num_shots = first.shape[0]
Expand Down
1 change: 0 additions & 1 deletion pyquil/experiment/_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ def __init__(
calibration_counts: Optional[int] = None,
additional_results: Optional[List["ExperimentResult"]] = None,
):

object.__setattr__(self, "setting", setting)
object.__setattr__(self, "expectation", expectation)
object.__setattr__(self, "total_counts", total_counts)
Expand Down
735 changes: 643 additions & 92 deletions pyquil/noise.py

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion pyquil/operator_estimation.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ def _generate_experiment_programs(
programs = []
meas_qubits = []
for settings in tomo_experiment:

# Prepare a state according to the amalgam of all setting.in_state
total_prog = Program()
if active_reset:
Expand Down
1 change: 0 additions & 1 deletion pyquil/quilbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -1233,7 +1233,6 @@ def get_qubits(self, indices: bool = True) -> Set[QubitDesignator]:

class DelayFrames(AbstractInstruction):
def __init__(self, frames: List[Frame], duration: float):

# all frames should be on the same qubits
if len(frames) == 0:
raise ValueError("DELAY expected nonempty list of frames.")
Expand Down
1 change: 0 additions & 1 deletion pyquil/quiltwaveforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,6 @@ def samples(self, rate: float) -> np.ndarray:

@waveform("boxcar_kernel")
class BoxcarAveragerKernel(TemplateWaveform):

scale: Optional[float] = None
""" An optional global scaling factor. """

Expand Down
44 changes: 22 additions & 22 deletions test/unit/test_noise.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,26 @@
from pyquil.api._qam import QAMExecutionResult
from pyquil.gates import RZ, RX, I, CZ
from pyquil.noise import (
pauli_kraus_map,
damping_kraus_map,
dephasing_kraus_map,
tensor_kraus_maps,
_get_program_gates,
_decoherence_noise_model,
add_decoherence_noise,
combine_kraus_maps,
damping_after_dephasing,
INFINITY,
apply_noise_model,
_noise_model_program_header,
KrausModel,
NoiseModel,
corrupt_bitstring_probs,
correct_bitstring_probs,
estimate_bitstring_probs,
bitstring_probs_to_z_moments,
estimate_assignment_probs,
NO_NOISE,
pauli_kraus_map,
damping_kraus_map,
dephasing_kraus_map,
tensor_kraus_maps,
_get_program_gates,
_decoherence_noise_model,
add_single_qubit_noise,
combine_kraus_maps,
damping_after_dephasing,
INFINITY,
apply_noise_model,
_noise_model_program_header,
KrausModel,
NoiseModel,
corrupt_bitstring_probs,
correct_bitstring_probs,
estimate_bitstring_probs,
bitstring_probs_to_z_moments,
estimate_assignment_probs,
NO_NOISE,
)
from pyquil.quil import Pragma, Program
from pyquil.quilbase import DefGate, Gate
Expand Down Expand Up @@ -157,8 +157,8 @@ def test_decoherence_noise():
)
assert headers.out() in new_prog.out()

# verify that high-level add_decoherence_noise reproduces new_prog
new_prog2 = add_decoherence_noise(prog, T1={0: 30e-6}, T2={0: 30e-6})
# verify that high-level add_single_qubit_noise reproduces new_prog
new_prog2 = add_single_qubit_noise(prog, T1={0: 30e-6}, T2={0: 30e-6})
assert new_prog == new_prog2


Expand Down