diff --git a/.github/workflows/hotfix.yml b/.github/workflows/hotfix.yml index 4f20534c..6ae38bc9 100644 --- a/.github/workflows/hotfix.yml +++ b/.github/workflows/hotfix.yml @@ -57,7 +57,10 @@ jobs: python-version: '3.10' - name: Build and test run: | - ./.github/workflows/build-test nomypy + for mod in ${MODULES_TO_TEST} + do + MODULE=${mod} ./.github/workflows/build-test nomypy + done - uses: actions/upload-artifact@v3 with: name: artefacts diff --git a/modules/pytket-braket/_metadata.py b/modules/pytket-braket/_metadata.py index 16ef1b1a..884729ff 100644 --- a/modules/pytket-braket/_metadata.py +++ b/modules/pytket-braket/_metadata.py @@ -1,2 +1,2 @@ -__extension_version__ = "0.19.0" +__extension_version__ = "0.19.1" __extension_name__ = "pytket-braket" diff --git a/modules/pytket-braket/docs/changelog.rst b/modules/pytket-braket/docs/changelog.rst index 2bfd0861..a1986e8d 100644 --- a/modules/pytket-braket/docs/changelog.rst +++ b/modules/pytket-braket/docs/changelog.rst @@ -1,6 +1,11 @@ Changelog ~~~~~~~~~ +0.19.1 (June 2022) +------------------ + +* Fixes to qubit index handling. + 0.19.0 (May 2022) ----------------- diff --git a/modules/pytket-braket/pytket/extensions/braket/backends/braket.py b/modules/pytket-braket/pytket/extensions/braket/backends/braket.py index 26e6743c..e7092e0d 100644 --- a/modules/pytket-braket/pytket/extensions/braket/backends/braket.py +++ b/modules/pytket-braket/pytket/extensions/braket/backends/braket.py @@ -459,7 +459,16 @@ def _get_arch_info( connectivity_graph = dict( (int(k), [int(v) for v in l]) for k, l in connectivity_graph.items() ) - all_qubits = sorted(connectivity_graph.keys()) + # each connectivity graph key will be an int + # connectivity_graph values will be lists + qubit_list = [ + [*connectivity_graph.keys()], + *connectivity_graph.values(), + ] + # summing lists will flatten them + # example [[0,1], [0,2]] would be [0,1,0,2] when summed + # returns unique ordered list since taking set of sum + all_qubits = list(set(sum(qubit_list, []))) if n_qubits < len(all_qubits): # This can happen, at least on rigetti devices, and causes errors. # As a kludgy workaround, remove some qubits from the architecture. @@ -685,6 +694,9 @@ def process_circuits( else: c0, ppcirc, ppcirc_rep = circ, None, None bkcirc, measures = self._to_bkcirc(c0) + # maps to index of measured qubits in the circuit + # this is necessary because qubit number doesn't map to index for Rigetti + measures = {k: self._all_qubits.index(v) for k, v in measures.items()} if want_state: bkcirc.add_result_type(ResultType.StateVector()) if want_dm: @@ -739,13 +751,14 @@ def circuit_status(self, handle: ResultHandle) -> CircuitStatus: if self._device_type == _DeviceType.LOCAL: return CircuitStatus(StatusEnum.COMPLETED) task_id, target_qubits, measures, want_state, want_dm, ppcirc_str = handle + ppcirc_rep = json.loads(ppcirc_str) ppcirc = Circuit.from_dict(ppcirc_rep) if ppcirc_rep is not None else None task = AwsQuantumTask(task_id, aws_session=self._aws_session) state = task.state() if state == "FAILED": return CircuitStatus(StatusEnum.ERROR, task.metadata()["failureReason"]) - elif state == "CANCELLED": + elif state in ["CANCELLED", "CANCELLING"]: return CircuitStatus(StatusEnum.CANCELLED) elif state == "COMPLETED": self._update_cache_result(