From 22f34d40458ad4103a1036803d996d2d8f4d313d Mon Sep 17 00:00:00 2001 From: Julien Dumazert Date: Thu, 18 May 2023 08:47:06 +0200 Subject: [PATCH] Add support for delay instruction This is made possible by a temporary fork of qiskit-qir. Discussions to add the delay instruction to the upstream repo (or to let the user define custom translation rules) are engaged in https://github.com/microsoft/qiskit-qir/pull/40 --- pyproject.toml | 2 +- tests/test_backend.py | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 1c2c4f4..2c51825 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -31,7 +31,7 @@ requires-python = ">=3.7" dependencies = [ "requests", "qiskit-terra", - "qiskit-qir @ git+https://github.com/microsoft/qiskit-qir" + "qiskit-qir @ git+https://github.com/jrj-d/qiskit-qir@add_delay_instruction_using_an_extern" ] [project.optional-dependencies] diff --git a/tests/test_backend.py b/tests/test_backend.py index ffb06c5..1cff725 100644 --- a/tests/test_backend.py +++ b/tests/test_backend.py @@ -23,6 +23,7 @@ from requests_mock.mocker import Mocker from qiskit_alice_bob_provider.api.client import AliceBobApiException +from qiskit_alice_bob_provider.backend import _qiskit_to_qir from qiskit_alice_bob_provider.provider import AliceBobProvider @@ -111,3 +112,17 @@ def test_failed_server_side_validation(failed_validation_job: Mocker) -> None: backend = provider.get_backend('SINGLE_CAT_SIMULATOR') with pytest.raises(AliceBobApiException): execute(c, backend) + + +def test_delay_instruction_recognized() -> None: + c = QuantumCircuit(1, 2) + c.initialize('+', 0) + c.measure_x(0, 0) + c.delay(3000, 0, unit='ns') + c.measure(0, 1) + qir = _qiskit_to_qir(c) + delay_call = ( + 'call void @__quantum__qis__delay__body' + '(double 3.000000e+00, %Qubit* null)' + ) + assert delay_call in qir