From a060ffeaba39901752ccafc5ddf16ef11624f25c Mon Sep 17 00:00:00 2001 From: Cassandra Granade Date: Thu, 15 Sep 2022 08:12:45 -0700 Subject: [PATCH 1/3] Pass target capabilities when compiling to QIR. (#716) * Pass target capabilities when compiling to QIR. * Addressing feedback. * Add live test. * Split live tests into projects. --- src/AzureClient/AzureClient.cs | 12 +- src/AzureClient/AzureExecutionTarget.cs | 50 ++- .../Mocks/MockAzureExecutionTarget.cs | 3 +- src/Tests/AzureClientMagicTests.cs | 2 +- src/Tests/AzureClientTests.cs | 1 + tests.live/All.Tests.ps1 | 4 +- tests.live/Python/qsharp/ionq/IonQ.csproj | 8 + tests.live/Python/qsharp/ionq/Operations.qs | 25 ++ .../{ => qsharp/quantinuum}/Operations.qs | 23 +- .../qsharp/quantinuum/Quantinuum.csproj | 10 + tests.live/Python/test_live.py | 319 ++++++++++-------- 11 files changed, 275 insertions(+), 182 deletions(-) create mode 100644 tests.live/Python/qsharp/ionq/IonQ.csproj create mode 100644 tests.live/Python/qsharp/ionq/Operations.qs rename tests.live/Python/{ => qsharp/quantinuum}/Operations.qs (69%) create mode 100644 tests.live/Python/qsharp/quantinuum/Quantinuum.csproj diff --git a/src/AzureClient/AzureClient.cs b/src/AzureClient/AzureClient.cs index 085505dad1..a83130bc7f 100644 --- a/src/AzureClient/AzureClient.cs +++ b/src/AzureClient/AzureClient.cs @@ -386,12 +386,14 @@ private async Task SubmitOrExecuteJobAsync( // Thus, we can branch on whether we need a QIR submitter or a translator, // but can use the same task object to represent both return values. Func>? jobTask = null; - if (this.ActiveTarget.TryGetQirSubmitter(this.ActiveWorkspace, this.StorageConnectionString, out var submitter)) + if (this.ActiveTarget.TryGetQirSubmitter(this.ActiveWorkspace, this.StorageConnectionString, this.TargetCapability, out var submitter)) { + Logger?.LogDebug("Using QIR submitter for target {Target} and capability {Capability}.", this.ActiveTarget, this.TargetCapability); jobTask = entryPoint => entryPoint.SubmitAsync(submitter, submissionContext); } else if (AzureFactory.CreateMachine(this.ActiveWorkspace, this.ActiveTarget.TargetId, this.StorageConnectionString) is IQuantumMachine machine) { + Logger?.LogDebug("Using legacy submitter for target {Target} and capability {Capability}.", this.ActiveTarget, this.TargetCapability); jobTask = entryPoint => entryPoint.SubmitAsync(machine, submissionContext); } else @@ -405,7 +407,7 @@ private async Task SubmitOrExecuteJobAsync( try { entryPoint = await EntryPointGenerator.Generate( - submissionContext.OperationName, ActiveTarget.TargetId, ActiveTarget.MaximumCapability + submissionContext.OperationName, ActiveTarget.TargetId, this.TargetCapability ); } catch (TaskCanceledException tce) @@ -569,7 +571,7 @@ public async Task SetActiveTargetAsync(IChannel? channel, strin // Set the active target and load the package. ActiveTarget = executionTarget; - TargetCapability = executionTarget.MaximumCapability; + TargetCapability = executionTarget.DefaultCapability; channel?.Stdout($"Loading package {ActiveTarget.PackageName} and dependencies..."); await References.AddPackage(ActiveTarget.PackageName); @@ -815,7 +817,7 @@ public void ClearActiveTarget() public bool TrySetTargetCapability(IChannel? channel, string? capabilityName, [NotNullWhen(true)] out TargetCapability? targetCapability) { var capability = capabilityName is null - ? ActiveTarget?.MaximumCapability ?? TargetCapabilityModule.Top + ? ActiveTarget?.DefaultCapability ?? TargetCapabilityModule.Top : TargetCapabilityModule.FromName(capabilityName); if (!FSharpOption.get_IsSome(capability)) { @@ -826,7 +828,7 @@ public bool TrySetTargetCapability(IChannel? channel, string? capabilityName, [N if (ActiveTarget != null && !ActiveTarget.SupportsCapability(capability.Value)) { - channel?.Stderr($"Target capability {capability.Value.Name} is not supported by the active target, {ActiveTarget.TargetId}. The active target supports a maximum capability level of {ActiveTarget.MaximumCapability.Name}."); + channel?.Stderr($"Target capability {capability.Value.Name} is not supported by the active target, {ActiveTarget.TargetId}. The active target supports a maximum capability level of {ActiveTarget.DefaultCapability.Name}."); targetCapability = null; return false; } diff --git a/src/AzureClient/AzureExecutionTarget.cs b/src/AzureClient/AzureExecutionTarget.cs index 905083139b..42a37d7f6e 100644 --- a/src/AzureClient/AzureExecutionTarget.cs +++ b/src/AzureClient/AzureExecutionTarget.cs @@ -60,7 +60,7 @@ internal protected AzureExecutionTarget(string? targetId) /// Any other target capability must be subsumed by this maximum /// in order to be supported by this target. /// - public TargetCapability MaximumCapability => GetProvider(TargetId) switch + public TargetCapability DefaultCapability => GetProvider(TargetId) switch { AzureProvider.IonQ => TargetCapabilityModule.BasicQuantumFunctionality, AzureProvider.Quantinuum => TargetCapabilityModule.BasicMeasurementFeedback, @@ -76,13 +76,55 @@ internal protected AzureExecutionTarget(string? targetId) /// level. /// public bool SupportsCapability(TargetCapability capability) => - TargetCapabilityModule.Subsumes(this.MaximumCapability, capability); + // NB: Duplicates logic at https://github.com/microsoft/qsharp-compiler/blob/7714168fda4379fb7e6a6c616f680ec039c482f4/src/QuantumSdk/DefaultItems/DefaultItems.targets#L78, + // but at the level of providers rather than at the level of resolved processors. + (GetProvider(TargetId) switch + { + AzureProvider.Quantinuum or AzureProvider.Honeywell => new[] + { + TargetCapabilityModule.AdaptiveExecution, + TargetCapabilityModule.BasicMeasurementFeedback, + TargetCapabilityModule.BasicQuantumFunctionality, + TargetCapabilityModule.BasicExecution + }, + AzureProvider.IonQ => new[] + { + TargetCapabilityModule.BasicQuantumFunctionality + }, + AzureProvider.QCI => new[] + { + TargetCapabilityModule.AdaptiveExecution, + TargetCapabilityModule.BasicExecution + }, + AzureProvider.Rigetti => new[] + { + TargetCapabilityModule.BasicExecution + }, + AzureProvider.Microsoft => new[] + { + TargetCapabilityModule.FullComputation + }, + _ => new[] + { + TargetCapabilityModule.FullComputation, + TargetCapabilityModule.AdaptiveExecution, + TargetCapabilityModule.BasicMeasurementFeedback, + TargetCapabilityModule.BasicQuantumFunctionality, + TargetCapabilityModule.BasicExecution + } + }) + .Any(c => TargetCapabilityModule.Subsumes(c, capability)); /// /// Attempts to get a instance appropriate /// for use with this target. /// - public virtual bool TryGetQirSubmitter(Azure.Quantum.IWorkspace workspace, string storageConnectionString, [NotNullWhen(true)] out IQirSubmitter? submitter) + public virtual bool TryGetQirSubmitter( + Azure.Quantum.IWorkspace workspace, + string storageConnectionString, + TargetCapability? targetCapability, + [NotNullWhen(true)] out IQirSubmitter? submitter + ) { if (this.TargetId == null || this.TargetId.EndsWith(".mock")) { @@ -90,7 +132,7 @@ public virtual bool TryGetQirSubmitter(Azure.Quantum.IWorkspace workspace, strin return false; } - if (SubmitterFactory.QirSubmitter(this.TargetId, workspace, storageConnectionString, this.MaximumCapability.Name) is IQirSubmitter qirSubmitter) + if (SubmitterFactory.QirSubmitter(this.TargetId, workspace, storageConnectionString, (targetCapability ?? this.DefaultCapability).Name) is IQirSubmitter qirSubmitter) { submitter = qirSubmitter; return true; diff --git a/src/AzureClient/Mocks/MockAzureExecutionTarget.cs b/src/AzureClient/Mocks/MockAzureExecutionTarget.cs index 6c6f7239a7..632eaddac4 100644 --- a/src/AzureClient/Mocks/MockAzureExecutionTarget.cs +++ b/src/AzureClient/Mocks/MockAzureExecutionTarget.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using Microsoft.Azure.Quantum; +using Microsoft.Quantum.QsCompiler; using Microsoft.Quantum.Runtime; using Microsoft.Quantum.Runtime.Submitters; @@ -33,7 +34,7 @@ internal record MockAzureExecutionTarget : AzureExecutionTarget : null; - public override bool TryGetQirSubmitter(Azure.Quantum.IWorkspace workspace, string storageConnectionString, [NotNullWhen(true)] out IQirSubmitter? submitter) + public override bool TryGetQirSubmitter(Azure.Quantum.IWorkspace workspace, string storageConnectionString, TargetCapability? targetCapability, [NotNullWhen(true)] out IQirSubmitter? submitter) { if (this.TargetId?.EndsWith("mock-qir") ?? false) { diff --git a/src/Tests/AzureClientMagicTests.cs b/src/Tests/AzureClientMagicTests.cs index 9429c2be5c..ddba902e75 100644 --- a/src/Tests/AzureClientMagicTests.cs +++ b/src/Tests/AzureClientMagicTests.cs @@ -387,7 +387,7 @@ public async Task SetActiveTargetAsync(IChannel channel, string { LastAction = AzureClientAction.SetActiveTarget; ActiveTarget = MockAzureExecutionTarget.CreateMock(targetId); - TargetCapability = ActiveTarget?.MaximumCapability ?? TargetCapabilityModule.Top; + TargetCapability = ActiveTarget?.DefaultCapability ?? TargetCapabilityModule.Top; return ExecuteStatus.Ok.ToExecutionResult(); } diff --git a/src/Tests/AzureClientTests.cs b/src/Tests/AzureClientTests.cs index ab0f5a00a0..1ecc570599 100644 --- a/src/Tests/AzureClientTests.cs +++ b/src/Tests/AzureClientTests.cs @@ -198,6 +198,7 @@ public void TestManualTargets() [DataRow("--clear", "FullComputation", ExecuteStatus.Ok)] [DataRow("honeywell.mock", "FullComputation", ExecuteStatus.Error)] [DataRow("honeywell.mock", "BasicMeasurementFeedback", ExecuteStatus.Ok)] + [DataRow("quantinuum.mock", "AdaptiveExecution", ExecuteStatus.Ok)] public async Task TestManualCapabilities(string targetId, string capabilityName, ExecuteStatus expectedResult) => await Assert.That .UsingEngine(async services => diff --git a/tests.live/All.Tests.ps1 b/tests.live/All.Tests.ps1 index 0768075c74..0d38c3beda 100644 --- a/tests.live/All.Tests.ps1 +++ b/tests.live/All.Tests.ps1 @@ -11,8 +11,8 @@ BeforeAll { # These are needed for environment credentials: $Env:AZURE_TENANT_ID | Should -Not -BeNullOrEmpty - $Env:AZURE_CLIENT_ID | Should -Not -BeNullOrEmpty - $Env:AZURE_CLIENT_SECRET | Should -Not -BeNullOrEmpty + # $Env:AZURE_CLIENT_ID | Should -Not -BeNullOrEmpty + # $Env:AZURE_CLIENT_SECRET | Should -Not -BeNullOrEmpty } function Test-Notebook([string]$notebook) { diff --git a/tests.live/Python/qsharp/ionq/IonQ.csproj b/tests.live/Python/qsharp/ionq/IonQ.csproj new file mode 100644 index 0000000000..19b223ef58 --- /dev/null +++ b/tests.live/Python/qsharp/ionq/IonQ.csproj @@ -0,0 +1,8 @@ + + + + net6.0 + ionq.simulator + + + diff --git a/tests.live/Python/qsharp/ionq/Operations.qs b/tests.live/Python/qsharp/ionq/Operations.qs new file mode 100644 index 0000000000..ce5df67013 --- /dev/null +++ b/tests.live/Python/qsharp/ionq/Operations.qs @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +namespace Microsoft.Quantum.Tests { + open Microsoft.Quantum.Intrinsic; + open Microsoft.Quantum.Canon; + + /// # Summary + /// A quantum random number generator with a variable number of qubits. + operation SampleQrng(count : Int, name : String) : Result[] { + Message($"Hello {name} again!"); + + mutable r = [Zero, size = count]; + use q = Qubit[count]; + + ApplyToEach(H, q); + + for i in 1..count { + set r w/= i-1 <- M(q[i-1]); + } + + return r; + } + +} diff --git a/tests.live/Python/Operations.qs b/tests.live/Python/qsharp/quantinuum/Operations.qs similarity index 69% rename from tests.live/Python/Operations.qs rename to tests.live/Python/qsharp/quantinuum/Operations.qs index ded2c1781d..b6f7949386 100644 --- a/tests.live/Python/Operations.qs +++ b/tests.live/Python/qsharp/quantinuum/Operations.qs @@ -1,32 +1,14 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -/// Q# code should be in one or more .qs files that live -/// in the same directory as the python classical driver. -/// - namespace Microsoft.Quantum.Tests { open Microsoft.Quantum.Intrinsic; open Microsoft.Quantum.Canon; - /// # Summary - /// A quantum random number generator with a variable number of qubits. - operation SampleQrng(count : Int, name : String) : Result[] { - Message($"Hello {name} again!"); - - mutable r = [Zero, size = count]; - use q = Qubit[count]; - - ApplyToEach(H, q); - - for i in 1..count { - set r w/= i-1 <- M(q[i-1]); - } - - return r; + operation RunTeleportWithPlus() : Result { + return RunTeleport(true); } - /// # Summary /// Direct implementation of Teleport's circuit operation RunTeleport(doPlus: Bool) : Result { @@ -68,4 +50,5 @@ namespace Microsoft.Quantum.Tests { X(q); H(q); } + } diff --git a/tests.live/Python/qsharp/quantinuum/Quantinuum.csproj b/tests.live/Python/qsharp/quantinuum/Quantinuum.csproj new file mode 100644 index 0000000000..38832364b3 --- /dev/null +++ b/tests.live/Python/qsharp/quantinuum/Quantinuum.csproj @@ -0,0 +1,10 @@ + + + + net6.0 + qci.qpu + AdaptiveExecution + true + + + diff --git a/tests.live/Python/test_live.py b/tests.live/Python/test_live.py index 0451c62929..b7fb566e26 100644 --- a/tests.live/Python/test_live.py +++ b/tests.live/Python/test_live.py @@ -9,6 +9,7 @@ ## IMPORTS ## +from os import path import pytest import warnings @@ -52,160 +53,180 @@ def wait_until_completed(job): else poll_wait * 1.5 ) -def test_ionq_targets(): - """ - Tests that we can fetch targets from the service, - and that the workspace includes the targets we need for submission - """ - targets = connect() - assert len(targets) > 2 - - target_ids = [t.id for t in targets] - assert 'ionq.simulator' in target_ids - assert 'ionq.qpu' in target_ids - assert 'ionq.qpu.aria-1' in target_ids - -def test_ionq_submit(): - """ - Test that the SampleQrng operation can be submitted successfully on the ionq.simulator - """ - import time +@pytest.fixture(scope="session") +def ionq_project(): import qsharp - from Microsoft.Quantum.Tests import SampleQrng - - # Make sure we can simulate locally: - count = 3 - result = SampleQrng.simulate(count=count, name='andres') - assert len(result) == count - - import qsharp.azure - connect() - - t = qsharp.azure.target("ionq.simulator") - assert isinstance(t, qsharp.azure.AzureTarget) - assert t.id == "ionq.simulator" - - job = qsharp.azure.submit(SampleQrng, count=count, name="andres") - assert isinstance(job, qsharp.azure.AzureJob) - assert not job.id == '' - print("Submitted job: ", job.id) - - try: - wait_until_completed(job) - except TimeoutError: - warnings.warn("IonQ execution exceeded timeout. Skipping fetching results.") - else: - job = qsharp.azure.status() - assert isinstance(job, qsharp.azure.AzureJob) - assert job.status == "Succeeded" - - histogram = { - '[0,0,0]': 0.125, - '[0,0,1]': 0.125, - '[0,1,0]': 0.125, - '[0,1,1]': 0.125, - '[1,0,0]': 0.125, - '[1,0,1]': 0.125, - '[1,1,0]': 0.125, - '[1,1,1]': 0.125 - } - retrieved_histogram = qsharp.azure.output() - assert isinstance(retrieved_histogram, dict) - assert histogram == retrieved_histogram - -def test_honeywell_targets(): - """ - Tests that we can fetch targets from the service, - and that the workspace includes the targets we need for submission - """ - targets = connect() - assert len(targets) > 2 - - target_ids = [t.id for t in targets] - assert 'honeywell.hqs-lt-s1' in target_ids - assert 'honeywell.hqs-lt-s1-apival' in target_ids - -def test_honeywell_submit(): - """ - Test that the RunTeleport operation can be submitted successfully on the honeywell apival target - """ - import qsharp - from Microsoft.Quantum.Tests import RunTeleport - - # Make sure we can simulate locally: - expected = True - result = RunTeleport.simulate(doPlus=expected) - assert result == 0 if expected else 1 - - import qsharp.azure - connect() - - t = qsharp.azure.target("honeywell.hqs-lt-s1-apival") - assert isinstance(t, qsharp.azure.AzureTarget) - assert t.id == "honeywell.hqs-lt-s1-apival" - - job = qsharp.azure.submit(RunTeleport, doPlus=expected) - assert isinstance(job, qsharp.azure.AzureJob) - assert not job.id == '' - print("Submitted job: ", job.id) - - try: - wait_until_completed(job) - except TimeoutError: - warnings.warn("Honeywell execution exceeded timeout. Skipping fetching results.") - else: - job = qsharp.azure.status() + return qsharp.projects.add(path.join(path.dirname(__file__), "qsharp", "ionq", "IonQ.csproj")) + +@pytest.mark.usefixtures("ionq_project") +class TestIonQ: + def test_ionq_targets(self): + """ + Tests that we can fetch targets from the service, + and that the workspace includes the targets we need for submission + """ + targets = connect() + assert len(targets) > 2 + + target_ids = [t.id for t in targets] + assert 'ionq.simulator' in target_ids + assert 'ionq.qpu' in target_ids + assert 'ionq.qpu.aria-1' in target_ids + + def test_ionq_submit(self): + """ + Test that the SampleQrng operation can be submitted successfully on the ionq.simulator + """ + import time + import qsharp + qsharp.projects.add(path.join(path.dirname(__file__), "qsharp", "ionq", "IonQ.csproj")) + from Microsoft.Quantum.Tests import SampleQrng + + # Make sure we can simulate locally: + count = 3 + result = SampleQrng.simulate(count=count, name='andres') + assert len(result) == count + + import qsharp.azure + connect() + + t = qsharp.azure.target("ionq.simulator") + assert isinstance(t, qsharp.azure.AzureTarget) + assert t.id == "ionq.simulator" + + job = qsharp.azure.submit(SampleQrng, count=count, name="andres") assert isinstance(job, qsharp.azure.AzureJob) - if job.status == "Succeeded": + assert not job.id == '' + print("Submitted job: ", job.id) + + try: + wait_until_completed(job) + except TimeoutError: + warnings.warn("IonQ execution exceeded timeout. Skipping fetching results.") + else: + job = qsharp.azure.status() + assert isinstance(job, qsharp.azure.AzureJob) + assert job.status == "Succeeded" + + histogram = { + '[0,0,0]': 0.125, + '[0,0,1]': 0.125, + '[0,1,0]': 0.125, + '[0,1,1]': 0.125, + '[1,0,0]': 0.125, + '[1,0,1]': 0.125, + '[1,1,0]': 0.125, + '[1,1,1]': 0.125 + } retrieved_histogram = qsharp.azure.output() assert isinstance(retrieved_histogram, dict) - assert '0' in retrieved_histogram - -def test_quantinuum_targets(): - """ - Tests that we can fetch targets from the service, - and that the workspace includes the targets we need for submission - """ - targets = connect() - assert len(targets) > 2 - - target_ids = [t.id for t in targets] - assert 'quantinuum.hqs-lt-s1' in target_ids - assert 'quantinuum.hqs-lt-s1-apival' in target_ids - -def test_quantinuum_submit(): - """ - Test that the RunTeleport operation can be submitted successfully on the quantinuum apival target - """ + assert histogram == retrieved_histogram + +@pytest.fixture(scope="session") +def quantinuum_project(): import qsharp - from Microsoft.Quantum.Tests import RunTeleport + return qsharp.projects.add(path.join(path.dirname(__file__), "qsharp", "quantinuum", "Quantinuum.csproj")) + +@pytest.mark.usefixtures("quantinuum_project") +class TestQuantinuum: + def test_honeywell_targets(self): + """ + Tests that we can fetch targets from the service, + and that the workspace includes the targets we need for submission + """ + targets = connect() + assert len(targets) > 2 + + target_ids = [t.id for t in targets] + assert 'honeywell.hqs-lt-s1' in target_ids + assert 'honeywell.hqs-lt-s1-apival' in target_ids + + def test_honeywell_submit(self): + """ + Test that the RunTeleport operation can be submitted successfully on the honeywell apival target + """ + import qsharp + from Microsoft.Quantum.Tests import RunTeleport + + # Make sure we can simulate locally: + expected = True + result = RunTeleport.simulate(doPlus=expected) + assert result == 0 if expected else 1 + + import qsharp.azure + connect() + + t = qsharp.azure.target("honeywell.hqs-lt-s1-apival") + assert isinstance(t, qsharp.azure.AzureTarget) + assert t.id == "honeywell.hqs-lt-s1-apival" + + job = qsharp.azure.submit(RunTeleport, doPlus=expected) + assert isinstance(job, qsharp.azure.AzureJob) + assert not job.id == '' + print("Submitted job: ", job.id) + + try: + wait_until_completed(job) + except TimeoutError: + warnings.warn("Honeywell execution exceeded timeout. Skipping fetching results.") + else: + job = qsharp.azure.status() + assert isinstance(job, qsharp.azure.AzureJob) + if job.status == "Succeeded": + retrieved_histogram = qsharp.azure.output() + assert isinstance(retrieved_histogram, dict) + assert '0' in retrieved_histogram + + def test_quantinuum_targets(self): + """ + Tests that we can fetch targets from the service, + and that the workspace includes the targets we need for submission + """ + targets = connect() + assert len(targets) > 2 + + target_ids = [t.id for t in targets] + assert 'quantinuum.hqs-lt-s1' in target_ids + assert 'quantinuum.hqs-lt-s1-apival' in target_ids + + @pytest.mark.parametrize("enable_qir", [False, True]) + def test_quantinuum_submit(self, enable_qir): + """ + Test that the RunTeleport operation can be submitted successfully on the quantinuum apival target + """ + import qsharp + from Microsoft.Quantum.Tests import ( + # A version we can use without having to pass mutable parameters. + RunTeleportWithPlus + ) - # Make sure we can simulate locally: - expected = True - result = RunTeleport.simulate(doPlus=expected) - assert result == 0 if expected else 1 + # Make sure we can simulate locally: + result = RunTeleportWithPlus.simulate() + assert result == 0 - import qsharp.azure - connect() - - t = qsharp.azure.target("quantinuum.hqs-lt-s1-apival") - assert isinstance(t, qsharp.azure.AzureTarget) - assert t.id == "quantinuum.hqs-lt-s1-apival" - - job = qsharp.azure.submit(RunTeleport, doPlus=expected) - assert isinstance(job, qsharp.azure.AzureJob) - assert not job.id == '' - print("Submitted job: ", job.id) - - try: - wait_until_completed(job) - except TimeoutError: - warnings.warn("Quantinuum execution exceeded timeout. Skipping fetching results.") - else: - job = qsharp.azure.status() + import qsharp.azure + connect() + + t = qsharp.azure.target("quantinuum.hqs-lt-s1-apival") + assert isinstance(t, qsharp.azure.AzureTarget) + assert t.id == "quantinuum.hqs-lt-s1-apival" + + if enable_qir: + qsharp.azure.target_capability("AdaptiveExecution") + + job = qsharp.azure.submit(RunTeleportWithPlus) assert isinstance(job, qsharp.azure.AzureJob) - if job.status == "Succeeded": - retrieved_histogram = qsharp.azure.output() - assert isinstance(retrieved_histogram, dict) - assert '0' in retrieved_histogram - \ No newline at end of file + assert not job.id == '' + print("Submitted job: ", job.id) + + try: + wait_until_completed(job) + except TimeoutError: + warnings.warn("Quantinuum execution exceeded timeout. Skipping fetching results.") + else: + job = qsharp.azure.status() + assert isinstance(job, qsharp.azure.AzureJob) + if job.status == "Succeeded": + retrieved_histogram = qsharp.azure.output() + assert isinstance(retrieved_histogram, dict) + assert '0' in retrieved_histogram From 0122708446f25730e99e0e7b7361624d85f99296 Mon Sep 17 00:00:00 2001 From: Andres Paz Date: Thu, 15 Sep 2022 16:47:58 -0700 Subject: [PATCH 2/3] Pin pyzmq install version, other dependencies (#720) * Pin pyzmq install to workaround: https://github.com/zeromq/pyzmq/issues/1764 * dependabot --- images/iqsharp-base/Dockerfile | 4 +++- src/Python/requirements.txt | 7 ++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/images/iqsharp-base/Dockerfile b/images/iqsharp-base/Dockerfile index 271104c49c..c4cc7a50c8 100644 --- a/images/iqsharp-base/Dockerfile +++ b/images/iqsharp-base/Dockerfile @@ -7,7 +7,9 @@ RUN pip install --no-cache --upgrade pip RUN pip install \ ipython==8.4.0 \ jupyter==1.0.0 \ - notebook==6.4.12 + notebook==6.4.12 \ + # to workaround: https://github.com/zeromq/pyzmq/issues/1764 + pyzmq==23.2.1 # Install APT prerequisites. RUN apt-get update && \ diff --git a/src/Python/requirements.txt b/src/Python/requirements.txt index 51eb993cf1..f446f6ab06 100644 --- a/src/Python/requirements.txt +++ b/src/Python/requirements.txt @@ -1,11 +1,12 @@ # This file includes requirements to build and test the Python packages. ipython==8.4.0 # to avoid high-severity issue. jupyter==1.0.0 -nbconvert==6.5.0 +nbconvert==7.0.0 notebook==6.4.12 -numpy==1.21.6 +numpy==1.22.0 pytest==7.1.2 -pygments==2.12.0 # to avoid high-severity issue. +pygments==2.12.0 # to avoid high-severity issue. +pyzmq==23.2.1 # to workaround: https://github.com/zeromq/pyzmq/issues/1764 qutip==4.7.0 selenium==4.2.0 setuptools==62.6.0 From 20d1e6e61fdd6a5fbd95cf89cac3f8c5379a7da1 Mon Sep 17 00:00:00 2001 From: Cassandra Granade Date: Fri, 16 Sep 2022 12:54:57 -0700 Subject: [PATCH 3/3] Fix split of IonQ tests into projects. (#721) --- tests.live/Python/test_live.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests.live/Python/test_live.py b/tests.live/Python/test_live.py index b7fb566e26..2a4bd2862e 100644 --- a/tests.live/Python/test_live.py +++ b/tests.live/Python/test_live.py @@ -79,7 +79,6 @@ def test_ionq_submit(self): """ import time import qsharp - qsharp.projects.add(path.join(path.dirname(__file__), "qsharp", "ionq", "IonQ.csproj")) from Microsoft.Quantum.Tests import SampleQrng # Make sure we can simulate locally: