Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.

Commit 5c38f9c

Browse files
authored
Merge branch 'main' into t-abalaji/update-resource-estimator
2 parents 3aa4661 + 5604fc6 commit 5c38f9c

File tree

86 files changed

+1401
-2030
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+1401
-2030
lines changed

bootstrap.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Push-Location (Join-Path $PSScriptRoot "./src/Simulation/qdk_sim_rs")
1919
--version $Env:NUGET_VERSION;
2020
Pop-Location
2121

22-
if (-not (Test-Path Env:AGENT_OS)) { # If not CI build, i.e. local build (if AGENT_OS envvar is not defined)
22+
if (-not (Test-Path Env:/AGENT_OS)) { # If not CI build, i.e. local build (if AGENT_OS envvar is not defined)
2323
if ($Env:ENABLE_NATIVE -ne "false") {
2424
Write-Host "Build release flavor of the native simulator"
2525
$Env:BUILD_CONFIGURATION = "Release"

build/ci-codecheck.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: $(date:yyMM).$(DayOfMonth)$(rev:rr)
2+
3+
trigger: none
4+
5+
pr:
6+
- main
7+
- feature/*
8+
- features/*
9+
- release/*
10+
11+
schedules:
12+
- cron: "0 9 * * Sat"
13+
displayName: 'Build for Component Governance'
14+
branches:
15+
include:
16+
- main
17+
always: true
18+
19+
variables:
20+
CI: "true"
21+
22+
jobs:
23+
- job: build
24+
displayName: Build
25+
strategy:
26+
matrix:
27+
linux:
28+
imageName: 'ubuntu-latest'
29+
mac:
30+
imageName: 'macOS-latest'
31+
#windows: # No sanitizers supported on Win at the moment.
32+
# imageName: 'windows-latest'
33+
pool:
34+
vmImage: $(imageName)
35+
36+
steps:
37+
- template: steps-codecheck.yml

build/steps-codecheck.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
##
2+
# Run all build steps.
3+
##
4+
steps:
5+
6+
- task: NuGetToolInstaller@0
7+
displayName: 'Use NuGet 5.6.0'
8+
inputs:
9+
versionSpec: '5.6.0'
10+
11+
# QIR Runtime:
12+
- pwsh: src/Qir/Runtime/prerequisites.ps1
13+
displayName: "Install QIR Runtime Prerequisistes"
14+
workingDirectory: $(System.DefaultWorkingDirectory)
15+
16+
- pwsh: src/Qir/Runtime/build-qir-runtime.ps1
17+
displayName: "Build QIR Runtime"
18+
workingDirectory: $(System.DefaultWorkingDirectory)
19+
20+
- pwsh: src/Qir/Runtime/test-qir-runtime.ps1
21+
displayName: "Test QIR Runtime"
22+
workingDirectory: $(System.DefaultWorkingDirectory)
23+
24+
# Native Simulator (needed to build and run the QIR tests):
25+
- pwsh: src/Simulation/Native/prerequisites.ps1
26+
displayName: "Install Native Simulator Prerequisites"
27+
workingDirectory: $(System.DefaultWorkingDirectory)
28+
29+
- powershell: |
30+
.\build-native-simulator.ps1
31+
displayName: "Build Native Simulator"
32+
workingDirectory: $(System.DefaultWorkingDirectory)/src/Simulation/Native
33+
34+
# QIR Tests:
35+
- pwsh: src/Qir/Tests/build-qir-tests.ps1
36+
displayName: "Build QIR Tests"
37+
workingDirectory: $(System.DefaultWorkingDirectory)
38+
39+
- pwsh: src/Qir/Tests/test-qir-tests.ps1
40+
displayName: "Run QIR Tests"
41+
workingDirectory: $(System.DefaultWorkingDirectory)
42+
43+
# QIR Samples:
44+
- pwsh: src/Qir/Samples/build-qir-samples.ps1
45+
displayName: "Build QIR Samples"
46+
workingDirectory: $(System.DefaultWorkingDirectory)
47+
48+
- pwsh: src/Qir/Samples/test-qir-samples.ps1
49+
displayName: "Run QIR Samples"
50+
workingDirectory: $(System.DefaultWorkingDirectory)

src/Azure/Azure.Quantum.Client.Test/Authentication/TokenFileCredentialTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,19 +49,19 @@ public class TokenFileCredentialTests
4949
[TestInitialize]
5050
public void TestInitialize()
5151
{
52-
Environment.SetEnvironmentVariable("AZUREQUANTUM_TOKEN_FILE", _tokenFilePath);
52+
Environment.SetEnvironmentVariable("AZURE_QUANTUM_TOKEN_FILE", _tokenFilePath);
5353
}
5454

5555
[TestCleanup]
5656
public void TestCleanup()
5757
{
58-
Environment.SetEnvironmentVariable("AZUREQUANTUM_TOKEN_FILE", null);
58+
Environment.SetEnvironmentVariable("AZURE_QUANTUM_TOKEN_FILE", null);
5959
}
6060

6161
[TestMethod]
6262
public void Test_WhenFileNotSet_Throws_CredentialUnavailableException()
6363
{
64-
Environment.SetEnvironmentVariable("AZUREQUANTUM_TOKEN_FILE", null);
64+
Environment.SetEnvironmentVariable("AZURE_QUANTUM_TOKEN_FILE", null);
6565
var credential = new TokenFileCredential();
6666

6767
var exception = Assert.ThrowsException<CredentialUnavailableException>(() =>

src/Azure/Azure.Quantum.Client.Test/WorkspaceTest.cs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ public class WorkspaceTest
2424
{
2525
private const string SETUP = @"
2626
Live tests require you to configure your environment with these variables:
27-
* AZUREQUANTUM_WORKSPACE_NAME: the name of an Azure Quantum workspace to use for live testing.
28-
* AZUREQUANTUM_SUBSCRIPTION_ID: the Azure Quantum workspace's Subscription Id.
29-
* AZUREQUANTUM_WORKSPACE_RG: the Azure Quantum workspace's resource group.
30-
* AZUREQUANTUM_WORKSPACE_LOCATION: the Azure Quantum workspace's location (region).
27+
* AZURE_QUANTUM_WORKSPACE_NAME: the name of an Azure Quantum workspace to use for live testing.
28+
* AZURE_QUANTUM_SUBSCRIPTION_ID: the Azure Quantum workspace's Subscription Id.
29+
* AZURE_QUANTUM_WORKSPACE_RG: the Azure Quantum workspace's resource group.
30+
* AZURE_QUANTUM_WORKSPACE_LOCATION: the Azure Quantum workspace's location (region).
3131
3232
We'll also try to authenticate with Azure using an instance of DefaultCredential. See
3333
https://docs.microsoft.com/en-us/dotnet/api/overview/azure/identity-readme#authenticate-the-client
@@ -187,24 +187,24 @@ private static void AssertJob(CloudJob job)
187187

188188
private IWorkspace GetLiveWorkspace()
189189
{
190-
if (string.IsNullOrWhiteSpace(System.Environment.GetEnvironmentVariable("AZUREQUANTUM_SUBSCRIPTION_ID")) ||
191-
string.IsNullOrWhiteSpace(System.Environment.GetEnvironmentVariable("AZUREQUANTUM_WORKSPACE_RG")) ||
192-
string.IsNullOrWhiteSpace(System.Environment.GetEnvironmentVariable("AZUREQUANTUM_WORKSPACE_NAME")) ||
193-
string.IsNullOrWhiteSpace(System.Environment.GetEnvironmentVariable("AZUREQUANTUM_SUBSCRIPTION_ID")))
190+
if (string.IsNullOrWhiteSpace(System.Environment.GetEnvironmentVariable("AZURE_QUANTUM_SUBSCRIPTION_ID")) ||
191+
string.IsNullOrWhiteSpace(System.Environment.GetEnvironmentVariable("AZURE_QUANTUM_WORKSPACE_RG")) ||
192+
string.IsNullOrWhiteSpace(System.Environment.GetEnvironmentVariable("AZURE_QUANTUM_WORKSPACE_NAME")) ||
193+
string.IsNullOrWhiteSpace(System.Environment.GetEnvironmentVariable("AZURE_QUANTUM_SUBSCRIPTION_ID")))
194194
{
195195
Assert.Inconclusive(SETUP);
196196
}
197197

198198
var options = new QuantumJobClientOptions();
199-
options.Diagnostics.ApplicationId = "ClientTests";
199+
options.Diagnostics.ApplicationId = Environment.GetEnvironmentVariable("AZURE_QUANTUM_NET_APPID") ?? "ClientTests";
200200

201201
var credential = Authentication.CredentialFactory.CreateCredential(Authentication.CredentialType.Default);
202202

203203
return new Workspace(
204-
subscriptionId: System.Environment.GetEnvironmentVariable("AZUREQUANTUM_SUBSCRIPTION_ID"),
205-
resourceGroupName: System.Environment.GetEnvironmentVariable("AZUREQUANTUM_WORKSPACE_RG"),
206-
workspaceName: System.Environment.GetEnvironmentVariable("AZUREQUANTUM_WORKSPACE_NAME"),
207-
location: System.Environment.GetEnvironmentVariable("AZUREQUANTUM_WORKSPACE_LOCATION"),
204+
subscriptionId: System.Environment.GetEnvironmentVariable("AZURE_QUANTUM_SUBSCRIPTION_ID"),
205+
resourceGroupName: System.Environment.GetEnvironmentVariable("AZURE_QUANTUM_WORKSPACE_RG"),
206+
workspaceName: System.Environment.GetEnvironmentVariable("AZURE_QUANTUM_WORKSPACE_NAME"),
207+
location: System.Environment.GetEnvironmentVariable("AZURE_QUANTUM_WORKSPACE_LOCATION"),
208208
options: options,
209209
credential: credential);
210210
}

src/Azure/Azure.Quantum.Client/Authentication/TokenFileCredential.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace Microsoft.Azure.Quantum.Authentication
1717
/// <summary>
1818
/// Implements a custom TokenCredential to use a local file as the source for an AzureQuantum token.
1919
///
20-
/// It will only use the local file if the <c>AZUREQUANTUM_TOKEN_FILE</c> environment variable is set, and references
20+
/// It will only use the local file if the <c>AZURE_QUANTUM_TOKEN_FILE</c> environment variable is set, and references
2121
/// an existing json file that contains the access_token and expires_on timestamp in milliseconds.
2222
///
2323
/// If the environment variable is not set, the file does not exist, or the token is invalid in any way(expired, for example),
@@ -28,7 +28,7 @@ public class TokenFileCredential : TokenCredential
2828
/// <summary>
2929
/// Environment variable name for the token file path.
3030
/// </summary>
31-
private const string TokenFileEnvironmentVariable = "AZUREQUANTUM_TOKEN_FILE";
31+
private const string TokenFileEnvironmentVariable = "AZURE_QUANTUM_TOKEN_FILE";
3232

3333
/// <summary>
3434
/// File system dependency injected so that unit testing is possible.

src/Azure/Azure.Quantum.Client/JobManagement/Workspace.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ public Workspace(
5151
// Optional parameters:
5252
credential ??= CredentialFactory.CreateCredential(CredentialType.Default, subscriptionId);
5353
options ??= new QuantumJobClientOptions();
54+
options.Diagnostics.ApplicationId = options.Diagnostics.ApplicationId
55+
?? Environment.GetEnvironmentVariable("AZURE_QUANTUM_NET_APPID");
5456

5557
this.ResourceGroupName = resourceGroupName;
5658
this.WorkspaceName = workspaceName;

src/Qir/.clang-tidy

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
Checks:
2-
'-*,bugprone-*,-readability-*,readability-identifier-*,readability-braces-around-statements'
2+
'bugprone-*,readability-identifier-*,readability-braces-around-statements,cert*,\
3+
-llvmlibc-callee-namespace,-llvmlibc-implementation-in-namespace,\
4+
-llvmlibc-restrict-system-libc-headers,-modernize-use-trailing-return-type,\
5+
-fuchsia-default-arguments-calls,-fuchsia-default-arguments-declarations,
6+
-google-readability-casting'
7+
# TODO(rokuzmin): '*, . . .'
8+
39
WarningsAsErrors: '*'
410
HeaderFilterRegex: '.*'
511

src/Qir/CommandLineTool/Program.cs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,14 @@ private static Command CreateBuildCommand()
4242
{
4343
var buildCommand = new Command("build", "(default) Build the executables from a QIR DLL.")
4444
{
45-
Handler = CommandHandler.Create((BuildOptions settings) =>
46-
QirTools.BuildFromQSharpDll(settings.QSharpDll, settings.LibraryDirectories, settings.IncludeDirectories, settings.ExecutablesDirectory))
45+
Handler = CommandHandler.Create((BuildOptions settings) => QirTools.BuildFromQSharpDll(
46+
settings.QSharpDll,
47+
settings.LibraryDirectories,
48+
settings.IncludeDirectories,
49+
settings.ExecutablesDirectory,
50+
settings.Debug)),
51+
TreatUnmatchedTokensAsErrors = true
4752
};
48-
buildCommand.TreatUnmatchedTokensAsErrors = true;
4953

5054
buildCommand.AddOption(new Option<FileInfo>(
5155
aliases: new string[] { "--qsharp-dll", "--dll" },
@@ -83,6 +87,10 @@ private static Command CreateBuildCommand()
8387
Required = true
8488
});
8589

90+
buildCommand.AddOption(new Option<bool>(
91+
alias: "--debug",
92+
description: "Enable additional debugging checks at runtime."));
93+
8694
return buildCommand;
8795
}
8896

@@ -145,6 +153,11 @@ public sealed class BuildOptions
145153
/// The path to the output directory where the created executables will be placed.
146154
/// </summary>
147155
public DirectoryInfo ExecutablesDirectory { get; set; }
156+
157+
/// <summary>
158+
/// Enable additional debugging checks at runtime.
159+
/// </summary>
160+
public bool Debug { get; set; }
148161
}
149162
}
150163
}

src/Qir/Runtime/lib/QIR/.clang-tidy

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)