From 37f4002523020a2806e415375fd2786562b09bc3 Mon Sep 17 00:00:00 2001 From: Melf Date: Fri, 2 Aug 2024 16:25:34 +0100 Subject: [PATCH 1/4] update version and changelog --- _metadata.py | 2 +- docs/changelog.rst | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/_metadata.py b/_metadata.py index 7c271f87..48edd4f4 100644 --- a/_metadata.py +++ b/_metadata.py @@ -1,2 +1,2 @@ -__extension_version__ = "0.36.0" +__extension_version__ = "0.37.0" __extension_name__ = "pytket-quantinuum" diff --git a/docs/changelog.rst b/docs/changelog.rst index 9ad859cb..3df47a7c 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -1,12 +1,13 @@ Changelog ~~~~~~~~~ -Unreleased ----------- +0.37.0 (August 2024) +-------------------- * Determine maximum classical register width from backend info. * Permit numpy 2. * Update pytket_pecos version requirement to 0.1.29. +* Updated pytket version requirement to 1.31. 0.36.0 (July 2024) ------------------ From f920ec5c4a45f0c42fdb02d5bb49a460913e7cd9 Mon Sep 17 00:00:00 2001 From: Melf Date: Fri, 2 Aug 2024 16:26:03 +0100 Subject: [PATCH 2/4] update pytket version --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 86bee30e..c51d4c53 100644 --- a/setup.py +++ b/setup.py @@ -43,7 +43,7 @@ packages=find_namespace_packages(include=["pytket.*"]), include_package_data=True, install_requires=[ - "pytket >= 1.30.1rc0", + "pytket >= 1.31.0", "pytket-qir >= 0.12.0", "requests >= 2.2", "types-requests", From b61d8f13c9a98fa3d858b13eb5da5b71b1240342 Mon Sep 17 00:00:00 2001 From: Melf Date: Fri, 2 Aug 2024 16:36:35 +0100 Subject: [PATCH 3/4] fix mypy --- tests/integration/backend_test.py | 40 ++++++++++++------------ tests/integration/local_emulator_test.py | 4 +-- tests/unit/offline_backend_test.py | 8 ++--- 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/tests/integration/backend_test.py b/tests/integration/backend_test.py index db9c4b56..61cca92d 100644 --- a/tests/integration/backend_test.py +++ b/tests/integration/backend_test.py @@ -104,7 +104,7 @@ def test_quantinuum( assert backend.circuit_status(handle).status is StatusEnum.COMPLETED assert np.all(shots == correct_shots) assert counts == correct_counts - res = backend.run_circuit(c, n_shots=4, timeout=49, language=language) # type: ignore + res = backend.run_circuit(c, n_shots=4, timeout=49, language=language) newshots = res.get_shots() assert np.all(newshots == correct_shots) newcounts = res.get_counts() @@ -157,7 +157,7 @@ def test_bell( c.measure_all() c = b.get_compiled_circuit(c) n_shots = 10 - shots = b.run_circuit(c, n_shots=n_shots, language=language).get_shots() # type: ignore + shots = b.run_circuit(c, n_shots=n_shots, language=language).get_shots() assert all(q[0] == q[1] for q in shots) @@ -190,7 +190,7 @@ def test_multireg( c = b.get_compiled_circuit(c) n_shots = 10 - shots = b.run_circuit(c, n_shots=n_shots, language=language).get_shots() # type: ignore + shots = b.run_circuit(c, n_shots=n_shots, language=language).get_shots() assert np.array_equal(shots, np.zeros((10, 2))) @@ -423,7 +423,7 @@ def test_classical( backend = authenticated_quum_backend_qa c = backend.get_compiled_circuit(c) - assert backend.run_circuit(c, n_shots=10, language=language).get_counts() # type: ignore + assert backend.run_circuit(c, n_shots=10, language=language).get_counts() @pytest.mark.skipif(skip_remote_tests, reason=REASON) @@ -459,7 +459,7 @@ def test_division( c = backend.get_compiled_circuit(c) with pytest.raises(ValueError): - backend.run_circuit(c, n_shots=10, language=language).get_counts() # type: ignore + backend.run_circuit(c, n_shots=10, language=language).get_counts() @pytest.mark.skipif(skip_remote_tests, reason=REASON) @@ -481,7 +481,7 @@ def test_postprocess( c.add_gate(OpType.ZZMax, [0, 1]) c.measure_all() c = b.get_compiled_circuit(c) - h = b.process_circuit(c, n_shots=10, postprocess=True, language=language) # type: ignore + h = b.process_circuit(c, n_shots=10, postprocess=True, language=language) ppcirc = Circuit.from_dict(json.loads(cast(str, h[1]))) ppcmds = ppcirc.get_commands() assert len(ppcmds) > 0 @@ -560,12 +560,12 @@ def test_simulator( circ = state_backend.get_compiled_circuit(circ) - noisy_handle = state_backend.process_circuit(circ, n_shots, language=language) # type: ignore + noisy_handle = state_backend.process_circuit(circ, n_shots, language=language) pure_handle = state_backend.process_circuit( - circ, n_shots, noisy_simulation=False, language=language # type: ignore + circ, n_shots, noisy_simulation=False, language=language ) stab_handle = stabilizer_backend.process_circuit( - circ, n_shots, noisy_simulation=False, language=language # type: ignore + circ, n_shots, noisy_simulation=False, language=language ) noisy_counts = state_backend.get_result(noisy_handle).get_counts() @@ -587,7 +587,7 @@ def test_simulator( ) non_stab_circ = stabilizer_backend.get_compiled_circuit(non_stab_circ) broken_handle = stabilizer_backend.process_circuit( - non_stab_circ, n_shots, language=language # type: ignore + non_stab_circ, n_shots, language=language ) with pytest.raises(GetResultFailed) as _: @@ -654,7 +654,7 @@ def test_submission_with_group( c, n_shots=n_shots, group=os.getenv("PYTKET_REMOTE_QUANTINUUM_GROUP", default="DEFAULT"), - language=language, # type: ignore + language=language, ).get_shots() assert all(q[0] == q[1] for q in shots) @@ -681,7 +681,7 @@ def test_zzphase( assert c0.n_gates_of_type(backend.default_two_qubit_gate) > 0 n_shots = 4 - handle = backend.process_circuits([c0], n_shots, language=language)[0] # type: ignore + handle = backend.process_circuits([c0], n_shots, language=language)[0] correct_counts = {(0, 0): 4} res = backend.get_result(handle, timeout=49) counts = res.get_counts() @@ -780,7 +780,7 @@ def test_wasm_qa( c = b.get_compiled_circuit(c) h = b.process_circuits( - [c], n_shots=10, wasm_file_handler=wasfile, language=language # type: ignore + [c], n_shots=10, wasm_file_handler=wasfile, language=language )[0] r = b.get_result(h) @@ -813,7 +813,7 @@ def test_wasm( c = b.get_compiled_circuit(c) h = b.process_circuits( - [c], n_shots=10, wasm_file_handler=wasfile, language=language # type: ignore + [c], n_shots=10, wasm_file_handler=wasfile, language=language )[0] r = b.get_result(h) @@ -893,7 +893,7 @@ def test_options( c0 = Circuit(1).H(0).measure_all() b = authenticated_quum_backend_qa c = b.get_compiled_circuit(c0, 0) - h = b.process_circuits([c], n_shots=1, options={"ignoreme": 0}, language=language) # type: ignore + h = b.process_circuits([c], n_shots=1, options={"ignoreme": 0}, language=language) r = b.get_results(h)[0] shots = r.get_shots() assert len(shots) == 1 @@ -921,7 +921,7 @@ def test_tk2( b = authenticated_quum_backend_qa b.set_compilation_config_target_2qb_gate(OpType.TK2) c = b.get_compiled_circuit(c0, 2) - h = b.process_circuit(c, n_shots=1, language=language) # type: ignore + h = b.process_circuit(c, n_shots=1, language=language) r = b.get_result(h) shots = r.get_shots() assert len(shots) == 1 @@ -1057,7 +1057,7 @@ def test_qir_conversion(authenticated_quum_backend_qa: QuantinuumBackend) -> Non c0 = Circuit(2).H(0).CX(0, 1).measure_all() b = authenticated_quum_backend_qa c = b.get_compiled_circuit(c0) - h = b.process_circuit(c, n_shots=10, language=Language.QIR) # type: ignore + h = b.process_circuit(c, n_shots=10, language=Language.QIR) r = b.get_result(h) shots = r.get_shots() assert len(shots) == 10 @@ -1168,7 +1168,7 @@ def test_wasm_collatz( c = backend.get_compiled_circuit(c) h = backend.process_circuit( - c, n_shots=10, wasm_file_handler=wasfile, language=language # type: ignore + c, n_shots=10, wasm_file_handler=wasfile, language=language ) r = backend.get_result(h) @@ -1231,7 +1231,7 @@ def test_wasm_state( c = backend.get_compiled_circuit(c) h = backend.process_circuit( - c, n_shots=10, wasm_file_handler=wasfile, language=language # type: ignore + c, n_shots=10, wasm_file_handler=wasfile, language=language ) r = backend.get_result(h) @@ -1289,7 +1289,7 @@ def test_noiseless_emulation( c = Circuit(2).H(0).CX(0, 1).measure_all() c1 = backend.get_compiled_circuit(c) h = backend.process_circuit( - c1, n_shots=100, language=language, noisy_simulation=False # type: ignore + c1, n_shots=100, language=language, noisy_simulation=False ) r = backend.get_result(h) counts = r.get_counts() diff --git a/tests/integration/local_emulator_test.py b/tests/integration/local_emulator_test.py index e526c4b8..79161699 100644 --- a/tests/integration/local_emulator_test.py +++ b/tests/integration/local_emulator_test.py @@ -349,7 +349,7 @@ def test_wasm(authenticated_quum_backend_prod: QuantinuumBackend) -> None: c = b.get_compiled_circuit(c) n_shots = 10 - counts = b.run_circuit(c, wasm_file_handler=wasfile, n_shots=n_shots).get_counts() # type: ignore + counts = b.run_circuit(c, wasm_file_handler=wasfile, n_shots=n_shots).get_counts() assert counts == Counter({(1, 0, 0, 0, 0, 0, 0, 0): n_shots}) @@ -379,7 +379,7 @@ def test_wasm_collatz(authenticated_quum_backend_prod: QuantinuumBackend) -> Non backend = authenticated_quum_backend_prod c = backend.get_compiled_circuit(c) - h = backend.process_circuit(c, n_shots=10, wasm_file_handler=wasfile) # type: ignore + h = backend.process_circuit(c, n_shots=10, wasm_file_handler=wasfile) r = backend.get_result(h) shots = r.get_shots() diff --git a/tests/unit/offline_backend_test.py b/tests/unit/offline_backend_test.py index 992cce07..57cec1d6 100644 --- a/tests/unit/offline_backend_test.py +++ b/tests/unit/offline_backend_test.py @@ -49,7 +49,7 @@ def test_quantinuum_offline(language: Language) -> None: c.measure_all() c = backend.get_compiled_circuit(c) n_shots = 4 - _ = backend.process_circuits([c], n_shots, language=language)[0] # type: ignore + _ = backend.process_circuits([c], n_shots, language=language)[0] expected_result = { "name": "test 1", "count": 4, @@ -111,7 +111,7 @@ def test_tket_pass_submission(language: Language) -> None: c.measure_all() c = backend.get_compiled_circuit(c) n_shots = 4 - backend.process_circuits([c], n_shots, pytketpass=sequence_pass, language=language) # type: ignore + backend.process_circuits([c], n_shots, pytketpass=sequence_pass, language=language) @given( @@ -130,7 +130,7 @@ def test_shots_bits_edgecases(n_shots, n_bits, language: Language) -> None: c = Circuit(n_bits, n_bits) # TODO TKET-813 add more shot based backends and move to integration tests - h = quantinuum_backend.process_circuit(c, n_shots, language=language) # type: ignore + h = quantinuum_backend.process_circuit(c, n_shots, language=language) res = quantinuum_backend.get_result(h) correct_shots = np.zeros((n_shots, n_bits), dtype=int) @@ -142,7 +142,7 @@ def test_shots_bits_edgecases(n_shots, n_bits, language: Language) -> None: assert res.get_counts() == correct_counts # Direct - res = quantinuum_backend.run_circuit(c, n_shots=n_shots, language=language) # type: ignore + res = quantinuum_backend.run_circuit(c, n_shots=n_shots, language=language) assert np.array_equal(res.get_shots(), correct_shots) assert res.get_shots().shape == correct_shape assert res.get_counts() == correct_counts From 4abd6e5ee6520d03c4803131b972ab22fb5af68a Mon Sep 17 00:00:00 2001 From: Melf Date: Fri, 2 Aug 2024 16:39:45 +0100 Subject: [PATCH 4/4] fix mypy ii --- pytket/extensions/quantinuum/backends/quantinuum.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pytket/extensions/quantinuum/backends/quantinuum.py b/pytket/extensions/quantinuum/backends/quantinuum.py index 32e3f990..26769cf6 100644 --- a/pytket/extensions/quantinuum/backends/quantinuum.py +++ b/pytket/extensions/quantinuum/backends/quantinuum.py @@ -1414,7 +1414,7 @@ def cost( raise ValueError(f"Device {backend._device_name} is not a syntax checker.") try: - handle = backend.process_circuit(circuit, n_shots, kwargs=kwargs) # type: ignore + handle = backend.process_circuit(circuit, n_shots, kwargs=kwargs) except DeviceNotAvailable as e: raise ValueError( f"Cannot find syntax checker for device {self._device_name}. "