diff --git a/pyquil/api/_qpu.py b/pyquil/api/_qpu.py index 1fdf90b58..b6b12f8be 100644 --- a/pyquil/api/_qpu.py +++ b/pyquil/api/_qpu.py @@ -310,6 +310,10 @@ def _build_patch_values(self) -> Dict[str, List[Union[int, float]]]: # Fill in our patch table for k, v in self._variables_shim.items(): + if k.name not in patch_values: + raise KeyError(f"{k.name} is not one of the valid memory descriptors: {patch_values.keys()}") + if k.index >= len(patch_values[k.name]): + raise IndexError(f"{k.name} has more parameter values ({k.index}) than expected ({len(patch[k.name])})") patch_values[k.name][k.index] = v return patch_values