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

update pytket 1 31 0 #481

Merged
merged 4 commits into from
Aug 2, 2024
Merged
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
2 changes: 1 addition & 1 deletion _metadata.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__extension_version__ = "0.36.0"
__extension_version__ = "0.37.0"
__extension_name__ = "pytket-quantinuum"
5 changes: 3 additions & 2 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
@@ -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)
------------------
Expand Down
2 changes: 1 addition & 1 deletion pytket/extensions/quantinuum/backends/quantinuum.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}. "
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
40 changes: 20 additions & 20 deletions tests/integration/backend_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)


Expand Down Expand Up @@ -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)))


Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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()
Expand All @@ -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 _:
Expand Down Expand Up @@ -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)

Expand All @@ -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()
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/local_emulator_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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})


Expand Down Expand Up @@ -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()
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/offline_backend_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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(
Expand All @@ -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)
Expand All @@ -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
Expand Down
Loading