Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.
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 src/AzureClient/AzureClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

<ItemGroup>
<PackageReference Include="Azure.Quantum.Jobs" Version="1.0.0-beta.3" />
<PackageReference Include="Microsoft.Azure.Quantum.Client" Version="0.22.186614-beta" />
<PackageReference Include="Microsoft.Azure.Quantum.Client" Version="0.23.194209-beta" />
<PackageReference Include="Microsoft.Rest.ClientRuntime" Version="2.3.23" />
<PackageReference Include="Microsoft.Rest.ClientRuntime.Azure" Version="3.3.19" />
<PackageReference Include="System.Reactive" Version="4.3.2" />
Expand Down
46 changes: 37 additions & 9 deletions src/AzureClient/AzureExecutionTarget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,16 @@

namespace Microsoft.Quantum.IQSharp.AzureClient
{
internal enum AzureProvider { IonQ, Honeywell, QCI, Mock }
internal enum AzureProvider
{
IonQ,
Quantinuum,
// NB: This provider name is deprecated, but may exist in older
// workspaces and should still be supported.
Honeywell,
QCI,
Mock
}

internal class AzureExecutionTarget
{
Expand All @@ -21,14 +30,23 @@ protected AzureExecutionTarget(string? targetId)

public string? TargetId { get; }

public virtual string PackageName => $"Microsoft.Quantum.Providers.{GetProvider(TargetId)}";
public virtual string PackageName => GetProvider(TargetId) switch
{

AzureProvider.IonQ => "Microsoft.Quantum.Providers.IonQ",
AzureProvider.Quantinuum => "Microsoft.Quantum.Providers.Honeywell",
AzureProvider.Honeywell => "Microsoft.Quantum.Providers.Honeywell",
AzureProvider.QCI => "Microsoft.Quantum.Providers.QCI",
_ => $"Microsoft.Quantum.Providers.{GetProvider(TargetId)}"
};

public RuntimeCapability RuntimeCapability => GetProvider(TargetId) switch
{
AzureProvider.IonQ => RuntimeCapability.BasicQuantumFunctionality,
AzureProvider.Honeywell => RuntimeCapability.BasicMeasurementFeedback,
AzureProvider.QCI => RuntimeCapability.BasicMeasurementFeedback,
_ => RuntimeCapability.FullComputation
AzureProvider.IonQ => RuntimeCapability.BasicQuantumFunctionality,
AzureProvider.Quantinuum => RuntimeCapability.BasicMeasurementFeedback,
AzureProvider.Honeywell => RuntimeCapability.BasicMeasurementFeedback,
AzureProvider.QCI => RuntimeCapability.BasicMeasurementFeedback,
_ => RuntimeCapability.FullComputation
};

/// <summary>
Expand All @@ -50,7 +68,13 @@ protected AzureExecutionTarget(string? targetId)
/// <summary>
/// It creates the AzureExecutionTarget instance for the given targetId.
/// </summary>
public static AzureExecutionTarget? Create(string? targetId) => GetProvider(targetId) is null
/// <returns>
/// An instance of <see cref="AzureExecutionTarget"/> if
/// <param name="targetId" /> describes a target for a valid
/// provider, and <c>null</c> otherwise.
/// </returns>
public static AzureExecutionTarget? Create(string? targetId) =>
GetProvider(targetId) is null
? null
: new AzureExecutionTarget(targetId);

Expand All @@ -59,10 +83,14 @@ protected AzureExecutionTarget(string? targetId)
/// Gets the Azure Quantum provider corresponding to the given execution target.
/// </summary>
/// <param name="targetId">The Azure Quantum execution target ID.</param>
/// <returns>The <see cref="AzureProvider"/> enum value representing the provider.</returns>
/// <returns>
/// The <see cref="AzureProvider"/> enum value representing the
/// provider, or <c>null</c> if <paramref name="targetId"/> does
/// not describe a valid provider.
/// </returns>
/// <remarks>
/// Valid target IDs are structured as "provider.target".
/// For example, "ionq.simulator" or "honeywell.qpu".
/// For example, "ionq.simulator" or "quantinuum.qpu".
/// </remarks>
protected static AzureProvider? GetProvider(string? targetId)
{
Expand Down
2 changes: 2 additions & 0 deletions src/AzureClient/Mocks/MockTargetStatus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,7 @@ public MockTargetStatus(string id) : base()
}

public override string TargetId { get; }

public override string ToString() => $"MockTargetStatus {{ TargetId = \"{TargetId}\" }}";
}
}
8 changes: 4 additions & 4 deletions src/Core/Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@
<PackageReference Include="Microsoft.CSharp" Version="4.5.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="3.0.0" />
<PackageReference Include="Microsoft.Quantum.Compiler" Version="0.22.191200-beta" />
<PackageReference Include="Microsoft.Quantum.CSharpGeneration" Version="0.22.191200-beta" />
<PackageReference Include="Microsoft.Quantum.Simulators" Version="0.22.191200-beta" />
<PackageReference Include="Microsoft.Quantum.QSharp.Core" Version="0.22.191200-beta" />
<PackageReference Include="Microsoft.Quantum.Compiler" Version="0.23.194209-beta" />
<PackageReference Include="Microsoft.Quantum.CSharpGeneration" Version="0.23.194209-beta" />
<PackageReference Include="Microsoft.Quantum.Simulators" Version="0.23.194209-beta" />
<PackageReference Include="Microsoft.Quantum.QSharp.Core" Version="0.23.194209-beta" />
<PackageReference Include="Microsoft.Windows.Compatibility" Version="5.0.2" />
<PackageReference Include="NuGet.Resolver" Version="5.1.0" />
<PackageReference Include="System.Runtime.Loader" Version="4.3.0" />
Expand Down
2 changes: 1 addition & 1 deletion src/ExecutionPathTracer/ExecutionPathTracer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Quantum.Simulators" Version="0.22.191200-beta" />
<PackageReference Include="Microsoft.Quantum.Simulators" Version="0.23.194209-beta" />
</ItemGroup>

</Project>
4 changes: 2 additions & 2 deletions src/MockLibraries/Mock.Chemistry/Mock.Chemistry.csproj
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<Project Sdk="Microsoft.Quantum.Sdk/0.22.191200-beta">
<Project Sdk="Microsoft.Quantum.Sdk/0.23.194209-beta">

<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<IncludeQsharpCorePackages>false</IncludeQsharpCorePackages> <!-- otherwise the standard library is included by the Sdk -->
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Quantum.Simulators" Version="0.22.191200-beta" />
<PackageReference Include="Microsoft.Quantum.Simulators" Version="0.23.194209-beta" />
</ItemGroup>
</Project>
4 changes: 2 additions & 2 deletions src/MockLibraries/Mock.Standard/Mock.Standard.csproj
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<Project Sdk="Microsoft.Quantum.Sdk/0.22.191200-beta">
<Project Sdk="Microsoft.Quantum.Sdk/0.23.194209-beta">

<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<IncludeQsharpCorePackages>false</IncludeQsharpCorePackages> <!-- otherwise the standard library is included by the Sdk -->
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Quantum.Simulators" Version="0.22.191200-beta" />
<PackageReference Include="Microsoft.Quantum.Simulators" Version="0.23.194209-beta" />
</ItemGroup>
</Project>
19 changes: 16 additions & 3 deletions src/Tests/AzureClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,17 @@ public void TestAzureExecutionTarget()
Assert.AreEqual(targetId, executionTarget?.TargetId);
Assert.AreEqual("Microsoft.Quantum.Providers.IonQ", executionTarget?.PackageName);

// Check that deprecated targets still work.
targetId = "HonEYWEll.targetId";
executionTarget = AzureExecutionTarget.Create(targetId);
Assert.AreEqual(targetId, executionTarget?.TargetId);
Assert.AreEqual("Microsoft.Quantum.Providers.Honeywell", executionTarget?.PackageName);

targetId = "QuantiNUUm.targetId";
executionTarget = AzureExecutionTarget.Create(targetId);
Assert.AreEqual(targetId, executionTarget?.TargetId);
Assert.AreEqual("Microsoft.Quantum.Providers.Honeywell", executionTarget?.PackageName);

targetId = "qci.target.name.qpu";
executionTarget = AzureExecutionTarget.Create(targetId);
Assert.AreEqual(targetId, executionTarget?.TargetId);
Expand Down Expand Up @@ -150,11 +156,13 @@ public void TestManualTargets()
// set up the mock workspace
var azureWorkspace = azureClient.ActiveWorkspace as MockAzureWorkspace;
Assert.IsNotNull(azureWorkspace);
azureWorkspace?.AddProviders("ionq", "honeywell", "unrecognized");
azureWorkspace?.AddProviders("ionq", "honeywell", "quantinuum", "unrecognized");

// get connection status to verify list of targets
targets = ExpectSuccess<IEnumerable<TargetStatusInfo>>(azureClient.GetConnectionStatusAsync(new MockChannel()));
Assert.AreEqual(4, targets.Count()); // only 2 valid quantum execution targets
// Above, we added 3 valid quantum execution targets, each of which contributes two targets (simulator and mock),
// for a total of six targets.
Assert.That.Enumerable(targets).HasCount(6);

// GetActiveTargetAsync, but no active target set yet
ExpectError(AzureClientError.NoTarget, azureClient.GetActiveTargetAsync(new MockChannel()));
Expand Down Expand Up @@ -306,7 +314,7 @@ public void TestRuntimeCapabilities()
// Set up workspace with mock providers
var azureWorkspace = azureClient.ActiveWorkspace as MockAzureWorkspace;
Assert.IsNotNull(azureWorkspace);
azureWorkspace?.AddProviders("ionq", "honeywell");
azureWorkspace?.AddProviders("ionq", "honeywell", "quantinuum");

// Verify that IonQ job fails to compile (QPRGen0)
ExpectSuccess<TargetStatusInfo>(azureClient.SetActiveTargetAsync(new MockChannel(), "ionq.mock"));
Expand All @@ -316,6 +324,11 @@ public void TestRuntimeCapabilities()
ExpectSuccess<TargetStatusInfo>(azureClient.SetActiveTargetAsync(new MockChannel(), "honeywell.mock"));
var job = ExpectSuccess<CloudJob>(azureClient.SubmitJobAsync(new MockChannel(), submissionContext, CancellationToken.None));
Assert.IsNotNull(job);

// Verify that Quantinuum job can be successfully submitted (QPRGen1)
ExpectSuccess<TargetStatusInfo>(azureClient.SetActiveTargetAsync(new MockChannel(), "quantinuum.mock"));
job = ExpectSuccess<CloudJob>(azureClient.SubmitJobAsync(new MockChannel(), submissionContext, CancellationToken.None));
Assert.IsNotNull(job);
}

[TestMethod]
Expand Down
2 changes: 2 additions & 0 deletions src/Tests/IQsharpEngineTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -933,6 +933,8 @@ operation RunTeleport() : Unit {
.WithMockAzure()
.Input("%azure.target honeywell.mock")
.ExecutesSuccessfully()
.Input("%azure.target quantinuum.mock")
.ExecutesSuccessfully()
.Input("%azure.submit RunTeleport")
.ExecutesSuccessfully()
.Input("%azure.target ionq.mock")
Expand Down
27 changes: 26 additions & 1 deletion src/Tests/TestExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ await engine
var client = await (await engine).Engine.GetEngineService<IAzureClient>();
if (client is AzureClient azureClient && azureClient.ActiveWorkspace is MockAzureWorkspace workspace)
{
workspace.AddProviders("ionq", "honeywell");
workspace.AddProviders("ionq", "quantinuum", "honeywell");
}
else
{
Expand Down Expand Up @@ -207,6 +207,31 @@ internal static T HasOperation<T>(this T assert, string namespaceName, string na
internal static string NormalizeLineEndings(this string s) =>
Regex.Replace(s, @"\r\n|\n\r|\n|\r", "\r\n");



internal class EnumerableAssert<T>
{
internal IEnumerable<T> Enumerable;
}

internal static EnumerableAssert<T> Enumerable<T>(this Assert assert, IEnumerable<T> enumerable) =>
new EnumerableAssert<T>
{
Enumerable = enumerable
};

internal static EnumerableAssert<T> HasCount<T>(this EnumerableAssert<T> enumerableAssert, int count)
{
// Collect in a list so that we can report on failure.
var elements = enumerableAssert.Enumerable.ToList();
Assert.AreEqual(
count,
elements.Count,
$"Expected {count} elements, but got {elements.Count}. Enumerable yielded values:\n{string.Join("\n", elements.Select(e => $" - {e?.ToString() ?? "<null>"}"))}"
);
return enumerableAssert;
}

}

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.Quantum.Sdk/0.22.191200-beta">
<Project Sdk="Microsoft.Quantum.Sdk/0.23.194209-beta">

<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.Quantum.Sdk/0.22.191200-beta">
<Project Sdk="Microsoft.Quantum.Sdk/0.23.194209-beta">

<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.Quantum.Sdk/0.22.191200-beta">
<Project Sdk="Microsoft.Quantum.Sdk/0.23.194209-beta">

<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
Expand All @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Quantum.Xunit" Version="0.22.191200-beta" />
<PackageReference Include="Microsoft.Quantum.Xunit" Version="0.23.194209-beta" />
</ItemGroup>

<ItemGroup>
Expand Down
32 changes: 16 additions & 16 deletions src/Tool/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@
},
"AllowedHosts": "*",
"DefaultPackageVersions": [
"Microsoft.Quantum.Compiler::0.22.191200-beta",
"Microsoft.Quantum.CSharpGeneration::0.22.191200-beta",
"Microsoft.Quantum.Development.Kit::0.22.191200-beta",
"Microsoft.Quantum.Simulators::0.22.191200-beta",
"Microsoft.Quantum.Xunit::0.22.191200-beta",
"Microsoft.Quantum.Standard::0.22.191200-beta",
"Microsoft.Quantum.Standard.Visualization::0.22.191200-beta",
"Microsoft.Quantum.Chemistry::0.22.191200-beta",
"Microsoft.Quantum.Chemistry.Jupyter::0.22.191200-beta",
"Microsoft.Quantum.MachineLearning::0.22.191200-beta",
"Microsoft.Quantum.Numerics::0.22.191200-beta",
"Microsoft.Quantum.Katas::0.22.191200-beta",
"Microsoft.Quantum.Research::0.22.191200-beta",
"Microsoft.Quantum.Providers.IonQ::0.22.191200-beta",
"Microsoft.Quantum.Providers.Honeywell::0.22.191200-beta",
"Microsoft.Quantum.Providers.QCI::0.22.191200-beta"
"Microsoft.Quantum.Compiler::0.23.194209-beta",
"Microsoft.Quantum.CSharpGeneration::0.23.194209-beta",
"Microsoft.Quantum.Development.Kit::0.23.194209-beta",
"Microsoft.Quantum.Simulators::0.23.194209-beta",
"Microsoft.Quantum.Xunit::0.23.194209-beta",
"Microsoft.Quantum.Standard::0.23.194209-beta",
"Microsoft.Quantum.Standard.Visualization::0.23.194209-beta",
"Microsoft.Quantum.Chemistry::0.23.194209-beta",
"Microsoft.Quantum.Chemistry.Jupyter::0.23.194209-beta",
"Microsoft.Quantum.MachineLearning::0.23.194209-beta",
"Microsoft.Quantum.Numerics::0.23.194209-beta",
"Microsoft.Quantum.Katas::0.23.194209-beta",
"Microsoft.Quantum.Research::0.23.194209-beta",
"Microsoft.Quantum.Providers.IonQ::0.23.194209-beta",
"Microsoft.Quantum.Providers.Honeywell::0.23.194209-beta",
"Microsoft.Quantum.Providers.QCI::0.23.194209-beta"
]
}
5 changes: 5 additions & 0 deletions tests.live/All.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ Describe "Test Python Integration" {
python -m pytest -k honeywell --junitxml="junit/TestResults-Honeywell.xml" | Write-Verbose
$LASTEXITCODE | Should -Be 0
}

It "Runs pytest successfully for Quantinuum" -Tag "submit.quantinuum" {
python -m pytest -k quantinuum --junitxml="junit/Quantinuum.xml" | Write-Verbose
$LASTEXITCODE | Should -Be 0
}

AfterAll { Pop-Location }
}
Expand Down
48 changes: 48 additions & 0 deletions tests.live/Python/test_live.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,4 +159,52 @@ def test_honeywell_submit():
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
"""
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("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()
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