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
Show all changes
31 commits
Select commit Hold shift + click to select a range
e024636
Use explicit static VC runtime on Windows (#851)
swernli Oct 16, 2021
b2e2f80
Append AppId to UserAgent when calling Azure Quantum APIs (#858)
vxfield Oct 21, 2021
1702325
Add `CX`, `CY` and `CZ` to Type1, Type3 target packages. (#842) (#861)
swernli Oct 27, 2021
9239c42
Moving QIR runtime build config into CMakeLists. (#863)
idavis Nov 5, 2021
59e55c0
Basic Runtime Driver (#859)
swernli Nov 9, 2021
5ea517c
Normalize case of target name when creating Quantum Machine (#868)
ricardo-espinoza Nov 10, 2021
b30286c
Preparing the QuantumSimulator for unifying the Dump(). (#867)
kuzminrobin Nov 11, 2021
631727e
Use old Mac OS build until gcc update (#875)
swernli Nov 18, 2021
0f66dfe
Revert "Preparing the QuantumSimulator for unifying the Dump(). (#867…
bettinaheim Nov 18, 2021
f4f2812
Create Rust QIR Runtime Wrapper Library (#878)
idavis Nov 22, 2021
5273e54
Update "use" and "borrow" statements in comments (#860)
tcNickolas Nov 23, 2021
5985170
Migrate native simulator from GCC to Clang. (#881)
kuzminrobin Dec 4, 2021
2080f80
Adding ability to provide content type and encoding for Azure blobs (…
anpaz Dec 5, 2021
0eb449a
Reverting the PR #881 to investigate the QDK Release failures. (#888)
kuzminrobin Dec 6, 2021
8c2a77c
Re-trying the PR #881: Migrating native sim from GCC to Clang. (#889)
kuzminrobin Jan 5, 2022
72f7e96
update project name to not include date (#894)
IsraelMiles Jan 5, 2022
b7668ca
Cherry-Picked: Broken up QuantumSimulator into CommonNativeSimulator …
kuzminrobin Jan 11, 2022
e25fa0f
libomp workaround for Linux, Mac (#897)
swernli Jan 12, 2022
45a92af
Add exponentiation test for runtime (#899)
swernli Jan 13, 2022
7736de7
Fixing sign usage on Y matrix (#893)
swernli Jan 13, 2022
dcb5b1a
Refactored the Dump functionality on Q#RT side. (#898)
kuzminrobin Jan 14, 2022
fb1f714
Minor improvement in build.ps1.
kuzminrobin Jan 15, 2022
ee88b38
Minor commenting.
kuzminrobin Jan 16, 2022
84db35e
Minor fix.
kuzminrobin Jan 19, 2022
9d64f7c
Minor git improvement.
kuzminrobin Jan 19, 2022
755c73e
Merge branch 'main' into feature/sparse-simulator
kuzminrobin Jan 19, 2022
0c0e65d
Fix links to QIR specification (#903)
tcNickolas Jan 19, 2022
a860518
Fix capitalization in xref links (#902)
tcNickolas Jan 19, 2022
d6ec661
Update macOS build scripts for libomp dependency (#906)
swernli Jan 20, 2022
b1793e7
Reverted my accitental commits.
kuzminrobin Jan 20, 2022
73c39dc
Merge remote-tracking branch 'origin/main' into kuzminrobin/sparseSim…
kuzminrobin Jan 20, 2022
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
6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[workspace]

members = [
"src/Simulation/qdk_sim_rs",
"src/Qir/microsoft-quantum-qir-runtime-sys",
]
2 changes: 1 addition & 1 deletion build/e2e.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: $(Build.Major).$(Build.Minor).$(date:yyMM).$(BuildId)
name: $(Build.Major).$(Build.Minor).$(BuildId)

parameters:
- name: validation_level
Expand Down
8 changes: 4 additions & 4 deletions build/pack.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,10 @@ function Pack-Crate() {
$OutPath = Resolve-Path (Join-Path $PSScriptRoot $OutPath);
}
Push-Location (Join-Path $PSScriptRoot $PackageDirectory)
cargo package;
# Copy only the .crate file, since we don't need all the intermediate
# artifacts brought in by the full folder under target/package.
Copy-Item -Force (Join-Path . "target" "package" "*.crate") $OutPath;
cargo package;
# Copy only the .crate file, since we don't need all the intermediate
# artifacts brought in by the full folder under target/package.
Copy-Item -Force (Join-Path $PSScriptRoot .. "target" "package" "*.crate") $OutPath;
Pop-Location
}

Expand Down
2 changes: 1 addition & 1 deletion build/steps-codecheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ steps:

# QIR Runtime:
- pwsh: src/Qir/Runtime/prerequisites.ps1
displayName: "Install QIR Runtime Prerequisistes"
displayName: "Install QIR Runtime Prerequisites"
workingDirectory: $(System.DefaultWorkingDirectory)

- pwsh: src/Qir/Runtime/build-qir-runtime.ps1
Expand Down
98 changes: 97 additions & 1 deletion src/Azure/Azure.Quantum.Client.Test/WorkspaceTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
using System.IO.Compression;
using System.Linq;
using System.Net;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;

using Azure.Identity;
using Azure.Quantum;
using Azure.Quantum.Jobs;
using Azure.Quantum.Jobs.Models;

using Microsoft.Azure.Quantum.Exceptions;
Expand Down Expand Up @@ -176,6 +178,100 @@ public async Task ListProviderStatusTest()
Assert.AreEqual(0, max);
}

[TestMethod]
[TestCategory("Local")]
public async Task ApplicationIdTest()
{
const string ENV_VAR_APPID = "EnvVarAppId";
const string OPTIONS_APPID = "OptionAppId";
const string LONG_ENV_VAR_APPID = "LongEnvVarAppId";
const string LONG_OPTIONS_APPID = "LongOptionAppId";
const string VERY_LONG_ENV_VAR_APPID = "VeryVeryVeryVeryVeryVeryLongEnvVarAppId";
const string VERY_LONG_OPTIONS_APPID = "VeryVeryVeryVeryVeryVeryLongOptionAppId";
const string APPID_ENV_VAR_NAME = "AZURE_QUANTUM_NET_APPID";

Func<QuantumJobClientOptions, Workspace> createWorkspace = (QuantumJobClientOptions options) =>
{
var credential = new ClientSecretCredential(tenantId: "72f988bf-86f1-41af-91ab-2d7cd011db47",
clientId: "00000000-0000-0000-0000-000000000000",
clientSecret: "PLACEHOLDER");
return new Workspace(subscriptionId: "SubscriptionId",
resourceGroupName: "ResourceGroupName",
workspaceName: "WorkspaceName",
location: "WestUs",
options: options,
credential: credential);
};

var originalEnvironmentAppId = Environment.GetEnvironmentVariable(APPID_ENV_VAR_NAME);
try
{

// Test with no Environment AppId and no Options AppId
Environment.SetEnvironmentVariable(APPID_ENV_VAR_NAME, null);
var workspace = createWorkspace(null);
Assert.IsNotNull(workspace.ClientOptions);
Assert.IsNotNull(workspace.ClientOptions.Diagnostics);
Assert.AreEqual("", workspace.ClientOptions.Diagnostics.ApplicationId);

// Test with Environment AppId and no Options AppId
Environment.SetEnvironmentVariable(APPID_ENV_VAR_NAME, ENV_VAR_APPID);
workspace = createWorkspace(null);
Assert.IsNotNull(workspace.ClientOptions);
Assert.IsNotNull(workspace.ClientOptions.Diagnostics);
Assert.AreEqual(ENV_VAR_APPID, workspace.ClientOptions.Diagnostics.ApplicationId);

// Test with no Environment AppId and with Options AppId
Environment.SetEnvironmentVariable(APPID_ENV_VAR_NAME, null);
var options = new QuantumJobClientOptions();
options.Diagnostics.ApplicationId = OPTIONS_APPID;
workspace = createWorkspace(options);
Assert.IsNotNull(workspace.ClientOptions);
Assert.IsNotNull(workspace.ClientOptions.Diagnostics);
Assert.AreEqual(OPTIONS_APPID, workspace.ClientOptions.Diagnostics.ApplicationId);

// Test with Environment AppId and with Options AppId
Environment.SetEnvironmentVariable(APPID_ENV_VAR_NAME, ENV_VAR_APPID);
options = new QuantumJobClientOptions();
options.Diagnostics.ApplicationId = OPTIONS_APPID;
workspace = createWorkspace(options);
Assert.IsNotNull(workspace.ClientOptions);
Assert.IsNotNull(workspace.ClientOptions.Diagnostics);
Assert.AreEqual($"{OPTIONS_APPID}-{ENV_VAR_APPID}", workspace.ClientOptions.Diagnostics.ApplicationId);

// Test with long (>24 chars) combination of Environment AppId and Options AppId
Environment.SetEnvironmentVariable(APPID_ENV_VAR_NAME, LONG_ENV_VAR_APPID);
options = new QuantumJobClientOptions();
options.Diagnostics.ApplicationId = LONG_OPTIONS_APPID;
workspace = createWorkspace(options);
Assert.IsNotNull(workspace.ClientOptions);
Assert.IsNotNull(workspace.ClientOptions.Diagnostics);
var truncatedAppId = $"{LONG_OPTIONS_APPID}-{LONG_ENV_VAR_APPID}".Substring(0, 24);
Assert.AreEqual(truncatedAppId, workspace.ClientOptions.Diagnostics.ApplicationId);

// Test with long (>24 chars) Environment AppId and no Options AppId
Environment.SetEnvironmentVariable(APPID_ENV_VAR_NAME, VERY_LONG_ENV_VAR_APPID);
workspace = createWorkspace(null);
Assert.IsNotNull(workspace.ClientOptions);
Assert.IsNotNull(workspace.ClientOptions.Diagnostics);
Assert.AreEqual(VERY_LONG_ENV_VAR_APPID.Substring(0, 24), workspace.ClientOptions.Diagnostics.ApplicationId);

// Test with long (>24 chars) Options AppId and no Environment AppId
Environment.SetEnvironmentVariable(APPID_ENV_VAR_NAME, null);
options = new QuantumJobClientOptions();
Assert.ThrowsException<System.ArgumentOutOfRangeException>(() =>
options.Diagnostics.ApplicationId = VERY_LONG_OPTIONS_APPID);
}
finally
{
// restore original env var AZURE_QUANTUM_NET_APPID
if (originalEnvironmentAppId != null)
{
Environment.SetEnvironmentVariable(APPID_ENV_VAR_NAME, originalEnvironmentAppId);
}
}
}

private static void AssertJob(CloudJob job)
{
Assert.IsNotNull(job);
Expand Down
38 changes: 33 additions & 5 deletions src/Azure/Azure.Quantum.Client/JobManagement/Workspace.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ namespace Microsoft.Azure.Quantum
using System.Threading;
using System.Threading.Tasks;
using global::Azure.Core;
using global::Azure.Identity;
using global::Azure.Quantum;
using global::Azure.Quantum.Jobs;
using global::Azure.Quantum.Jobs.Models;
Expand Down Expand Up @@ -50,9 +49,10 @@ public Workspace(

// Optional parameters:
credential ??= CredentialFactory.CreateCredential(CredentialType.Default, subscriptionId);
options ??= new QuantumJobClientOptions();
options.Diagnostics.ApplicationId = options.Diagnostics.ApplicationId
?? Environment.GetEnvironmentVariable("AZURE_QUANTUM_NET_APPID");

// Make sure use the property Setter as we have some logic
// tto apply here
this.ClientOptions = options;

this.ResourceGroupName = resourceGroupName;
this.WorkspaceName = workspaceName;
Expand All @@ -65,7 +65,7 @@ public Workspace(
workspaceName,
location,
credential,
options);
this.ClientOptions);
}

public string ResourceGroupName { get; }
Expand All @@ -81,6 +81,34 @@ public Workspace(
/// </summary>
public QuantumJobClient Client { get; }

/// <summary>
/// The options used to create the client to communicate with the service.
/// </summary>
public QuantumJobClientOptions ClientOptions
{
get => this.clientOptions;
set
{
// Set the ApplicationId that will be added as a UserAgent prefix
// in calls to the Azure Quantum API.
var applicationId = string.Join('-',
value?.Diagnostics?.ApplicationId?.Trim(),
Environment.GetEnvironmentVariable("AZURE_QUANTUM_NET_APPID")?.Trim()
)?.Trim('-', ' ');
if (applicationId?.Length > 24)
{
applicationId = applicationId?.Substring(0, 24);
}

value ??= new QuantumJobClientOptions();
value.Diagnostics.ApplicationId = applicationId;

this.clientOptions = value;
}
}

private QuantumJobClientOptions clientOptions;

/// <summary>
/// Submits the job.
/// </summary>
Expand Down
13 changes: 8 additions & 5 deletions src/Azure/Azure.Quantum.Client/Machine/QuantumMachineFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,17 @@ public static class QuantumMachineFactory
public static IQuantumMachine? CreateMachine(
IWorkspace workspace, string targetName, string? storageConnectionString = null)
{
// We normalize the case of the provided target name to lower.
var targetNameNormalized = targetName?.ToLowerInvariant();

var machineName =
targetName is null
targetNameNormalized is null
? null
: targetName.StartsWith("qci.")
: targetNameNormalized.StartsWith("qci.")
? "Microsoft.Quantum.Providers.QCI.Targets.QCIQuantumMachine, Microsoft.Quantum.Providers.QCI"
: targetName.StartsWith("ionq.")
: targetNameNormalized.StartsWith("ionq.")
? "Microsoft.Quantum.Providers.IonQ.Targets.IonQQuantumMachine, Microsoft.Quantum.Providers.IonQ"
: targetName.StartsWith("honeywell.")
: targetNameNormalized.StartsWith("honeywell.")
? "Microsoft.Quantum.Providers.Honeywell.Targets.HoneywellQuantumMachine, Microsoft.Quantum.Providers.Honeywell"
: null;

Expand All @@ -54,7 +57,7 @@ targetName is null
? null
: (IQuantumMachine)Activator.CreateInstance(
machineType,
targetName,
targetNameNormalized,
workspace,
storageConnectionString);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Azure.Core" Version="1.14.0" />
<PackageReference Include="Azure.Core" Version="1.19.0" />
<PackageReference Include="Azure.Identity" Version="1.4.0" />
<PackageReference Include="Azure.Quantum.Jobs" Version="1.0.0-beta.2" />
<PackageReference Include="Azure.Storage.Blobs" Version="12.2.0" />
<PackageReference Include="Azure.Storage.Blobs" Version="12.10.0" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
<PrivateAssets>all</PrivateAssets>
Expand Down
16 changes: 16 additions & 0 deletions src/Azure/Azure.Quantum.Client/Storage/IJobStorageHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,22 @@ public interface IJobStorageHelper
Stream input,
CancellationToken cancellationToken = default);

/// <summary>
/// Uploads the job input.
/// </summary>
/// <param name="jobId">The job id.</param>
/// <param name="input">The input.</param>
/// <param name="contentType">The MIME type indicating the content of the payload.</param>
/// <param name="compress">A flag to indicate if the payload should be uploaded compressed to storage.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Container uri + Input uri.</returns>
Task<(string containerUri, string inputUri)> UploadJobInputAsync(
string jobId,
Stream input,
string contentType,
bool compress,
CancellationToken cancellationToken = default);

/// <summary>
/// Uploads the job program output mapping.
/// </summary>
Expand Down
22 changes: 21 additions & 1 deletion src/Azure/Azure.Quantum.Client/Storage/IStorageHelper.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

#nullable enable

namespace Microsoft.Azure.Quantum.Storage
{
using System;
Expand Down Expand Up @@ -32,14 +34,32 @@ Task DownloadBlobAsync(
/// <param name="containerClient">Container client.</param>
/// <param name="blobName">Name of the BLOB.</param>
/// <param name="input">The input.</param>
/// <param name="contentType">The MIME type indicating the content of the payload.</param>
/// <param name="contentEncoding">The blob encoding.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>async task.</returns>
Task UploadBlobAsync(
BlobContainerClient containerClient,
string blobName,
Stream input,
string? contentType,
string? contentEncoding,
CancellationToken cancellationToken = default);

/// <summary>
/// Uploads the BLOB.
/// </summary>
/// <param name="containerClient">Container client.</param>
/// <param name="blobName">Name of the BLOB.</param>
/// <param name="input">The input.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>async task.</returns>
Task UploadBlobAsync(
BlobContainerClient containerClient,
string blobName,
Stream input,
CancellationToken cancellationToken = default) => this.UploadBlobAsync(containerClient, blobName, input, null, null, cancellationToken);

/// <summary>
/// Gets the BLOB sas URI.
/// </summary>
Expand Down
26 changes: 16 additions & 10 deletions src/Azure/Azure.Quantum.Client/Storage/JobStorageHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,28 +37,34 @@ public JobStorageHelper(string connectionString)
}
}

/// <summary>
/// Uploads the job input.
/// </summary>
/// <param name="jobId">The job id.</param>
/// <param name="input">The input.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>
/// Container uri + Input uri.
/// </returns>
/// <inheritdoc/>
public override async Task<(string containerUri, string inputUri)> UploadJobInputAsync(
string jobId,
Stream input,
string contentType,
bool compress,
CancellationToken cancellationToken = default)
{
string containerName = GetContainerName(jobId);
string encoding = null;
Stream data = input;

if (compress)
{
var compressedInput = new MemoryStream();
await Compression.Compress(input, compressedInput);
data = compressedInput;
encoding = "gzip";
}

BlobContainerClient containerClient = await this.GetContainerClient(containerName);

await this.StorageHelper.UploadBlobAsync(
containerClient,
Constants.Storage.InputBlobName,
input,
input: data,
contentType: contentType,
contentEncoding: encoding,
cancellationToken);

string containerUri = this.StorageHelper.GetBlobContainerSasUri(
Expand Down
Loading