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
166 commits
Select commit Hold shift + click to select a range
b5aeb88
Experiment to hook up Rust crate to cmake.
cgranade Feb 9, 2021
ecc9539
Add experimental simulator as rlib crate.
cgranade Feb 9, 2021
6505213
Expanded C API, started consolidating Cargo.toml.
cgranade Feb 10, 2021
21bd4b1
Just the one crate will do.
cgranade Feb 10, 2021
d496b03
First unit test of QIR ↔ opensim.
cgranade Feb 10, 2021
a30f93a
Add rust to builds.
cgranade Feb 10, 2021
d35a600
Start adding to CI.
cgranade Feb 10, 2021
3e5d1d9
Don't set toolchain in CI.
cgranade Feb 10, 2021
7966708
Started building managed interface.
cgranade Feb 10, 2021
df40286
Add System.Text.Json dependency.
cgranade Feb 10, 2021
890dcc9
Add native opensim sharedlibs to nupkg.
cgranade Feb 10, 2021
e90a971
Updated DLL name in NativeInterface.
cgranade Feb 10, 2021
5ee2983
downgrade s.t.json.
cgranade Feb 10, 2021
16c8e1b
Fix pack.ps1 paths.
cgranade Feb 10, 2021
74d1f8a
Set --release flag in opensim.
cgranade Feb 10, 2021
4af61f9
Add get_name.
cgranade Feb 10, 2021
3be6249
Added rest of c_api to NativeInterface.cs.
cgranade Feb 10, 2021
a48ad55
Initial attempt at type1 implementation.
cgranade Feb 10, 2021
1e9adcd
Add open systems data model.
cgranade Feb 10, 2021
f659395
Fix null reference exception by adding explicit qubit manager.
cgranade Feb 11, 2021
b7f7941
Started using QSharpCore interface temporarily.
cgranade Feb 12, 2021
d6e7b12
Begin adding decompositions for opensim.
cgranade Feb 12, 2021
5fd4e79
Expose noise_model::ideal() through c_api.
cgranade Feb 12, 2021
79c9003
Fix json serialization of instruments.
cgranade Feb 12, 2021
ca5a533
More informative exceptions in SetNoiseModel
cgranade Feb 12, 2021
d376c3b
Merge remote-tracking branch 'origin/main' into cgranade/experimental…
cgranade Feb 17, 2021
438d72c
Pass DumpMachine through OnDisplayableDiagnostic.
cgranade Feb 18, 2021
76f78c5
Began addressing warnings and adding unit tests.
cgranade Feb 18, 2021
2f3bde5
A couple more tests.
cgranade Feb 18, 2021
f4b04ca
Started enabling doctests for Rust runtime.
cgranade Feb 18, 2021
22a7c55
Fix new doctest.
cgranade Feb 18, 2021
59e0bf3
Added more API doc comments.
cgranade Feb 18, 2021
9bb6b31
A bit of code cleanup.
cgranade Feb 18, 2021
22cfe21
Start adding integration tests for experimental simulator in C# runtime.
cgranade Feb 18, 2021
0da2d82
Fix teleport test.
cgranade Feb 18, 2021
500c191
Attempt at fixing project-based tests.
cgranade Feb 19, 2021
3a5e87f
One more Rust-side unit test.
cgranade Feb 19, 2021
f960430
Added opensim to local dev props, and reverted bad change to unittest…
cgranade Feb 19, 2021
49c52cf
Undo one other bad change.
cgranade Feb 19, 2021
b273d18
Disable test that depends on Rz.
cgranade Feb 19, 2021
06fb952
Merge remote-tracking branch 'origin/main' into cgranade/experimental…
cgranade Feb 22, 2021
90d7330
Started adding Rust-language integration tests.
cgranade Feb 22, 2021
e9e9522
Added more informative error message when R is not supported.
cgranade Feb 22, 2021
c3dd0f7
Forgot to add test data to prev commit.
cgranade Feb 22, 2021
522ccea
Merge branch 'main' into cgranade/experimental/opensim
cgranade Mar 11, 2021
e806e1a
Start enabling performance reporting for opensim.
cgranade Mar 16, 2021
b1d254e
Merge remote-tracking branch 'origin/main' into cgranade/experimental…
cgranade Mar 16, 2021
ebd552a
Adapt opensim / managed interface to #538.
cgranade Mar 16, 2021
f32af17
Adapt QIR / opensim interface to #553.
cgranade Mar 16, 2021
b7b8c96
Apply rust-fmt, and reduce extraneous copying in conjugate_by.
cgranade Mar 17, 2021
2944209
Started weakening from owned arrays to views.
cgranade Mar 17, 2021
fa18ebb
Weakened tensor to views by owning views and borrowing owns.
cgranade Mar 17, 2021
5cf54ea
Started adding microbenchmarks.
cgranade Mar 17, 2021
d83e3e6
extend_two_to_n
cgranade Mar 18, 2021
9b17072
Clear diskspace and build microbenchmarks in CI.
cgranade Mar 18, 2021
96cff45
Clean more aggressively to avoid disk space issues.
cgranade Mar 18, 2021
dec89a1
Format, fix warnings, simplify Cargo.toml.
cgranade Mar 18, 2021
fb90746
Merge remote-tracking branch 'origin/main' into cgranade/experimental…
cgranade Apr 13, 2021
37ed0c1
Fix choco rustup in prereqs.
cgranade Apr 13, 2021
0820d75
Disable choco rustup.
cgranade Apr 13, 2021
0f75d25
Fix path to Cargo.toml.
cgranade Apr 14, 2021
467d160
Don't check Rust-style names with clang-tidy.
cgranade Apr 14, 2021
8f47f94
M is no longer overriden.
cgranade Apr 14, 2021
044f7ba
Temporarily disable QIR / opensim integration.
cgranade Apr 14, 2021
5e2ec23
Clean up extra cargo files after testing opensim.
cgranade Apr 14, 2021
245b444
Work on API docs and refactoring of Rust crate.
cgranade May 12, 2021
d6f4a7e
Separate out qdk_sim into its own crate.
cgranade May 14, 2021
d741380
Work on testing and enforcing rust fmt.
cgranade May 14, 2021
22132e0
Run clippy in tests as well.
cgranade May 14, 2021
4109e11
Add code quality checks to build/test.
cgranade May 14, 2021
26c4a40
Ignore jupyter temps and xplat drops.
cgranade May 14, 2021
fa7d2ca
Begin exposing build metadata through to C# callers.
cgranade May 14, 2021
bf2147c
Start injecting version number from build into Cargo.toml.
cgranade May 14, 2021
b12a34f
Started infrastructure to expose simulation functionality to Python.
cgranade May 17, 2021
434cbb4
Ignore Python temporaries and build artifacts.
cgranade May 17, 2021
f404293
More partial progress on exposing to Python.
cgranade May 18, 2021
33b8732
Add initial precommit config.
cgranade May 18, 2021
5a44d30
Introduce fmt error.
cgranade May 18, 2021
37218c1
Add new checks to pre-commit.
cgranade May 18, 2021
37756f7
Continued integrating CHP into simulator API.
cgranade May 19, 2021
c373fab
Address clippy warnings.
cgranade May 19, 2021
6c82ec6
Work on docs.
cgranade May 20, 2021
ec8c4e5
Separate out paulis.rs.
cgranade May 20, 2021
a44a135
Expose more simulation functionality to Python.
cgranade May 20, 2021
d91b7ae
Generalize C API to allow using other state representations.
cgranade May 21, 2021
62bd05d
Merge remote-tracking branch 'origin/main' into cgranade/experimental…
cgranade Jun 2, 2021
ebfd6e7
Enable CFG for C / Rust boundaries.
cgranade Jun 2, 2021
9cb438e
Move Cargo.toml injection into bootstrap.
cgranade Jun 2, 2021
2f2b5e9
Fix path from bootstrap to Cargo.toml injection, debug injection.
cgranade Jun 2, 2021
8315961
One more path fix.
cgranade Jun 2, 2021
3906a49
One more path fix.
cgranade Jun 2, 2021
7943335
Remove --release from cargo package.
cgranade Jun 2, 2021
db0ab9e
Revert CFG change to cmake.
cgranade Jun 2, 2021
2035d67
Fix Rust build script.
cgranade Jun 2, 2021
4b37b2a
Debug artifact paths.
cgranade Jun 3, 2021
527ea8e
Debug drop paths as well.
cgranade Jun 3, 2021
cb79239
More path debugging.
cgranade Jun 3, 2021
335d9a0
Fix build paths.
cgranade Jun 3, 2021
0b279fd
Don't cargo clean build artifacts away.
cgranade Jun 3, 2021
d259969
Fix one character typo in Simulators.Dev.props.
cgranade Jun 3, 2021
bddb295
Fix one more dev props typo.
cgranade Jun 3, 2021
e7dda55
Eliminate unneeded copy.
cgranade Jun 3, 2021
e057dfa
Improve naming conventions in processes.rs.
cgranade Jun 3, 2021
a4ddaf8
Fix pack.ps1 to include qdk_sim_rs drops.
cgranade Jun 3, 2021
8c02857
Expose more information in exceptions.
cgranade Jun 3, 2021
7d4246f
Fix one more path.
cgranade Jun 3, 2021
d04a0c6
Add links on cargo-clippy.
cgranade Jun 3, 2021
906f9f9
Fix issues in C API benchmarking.
cgranade Jun 3, 2021
6d338a1
Improve Python bindings for NoiseModel.
cgranade Jun 3, 2021
f7e167b
Improve readme for qdk_sim_rs crate.
cgranade Jun 3, 2021
54c37b8
Improve noise model handling, add test coverage.
cgranade Jun 3, 2021
afcdeb9
Update System.Text.Json to 4.7.2.
cgranade Jun 3, 2021
9306a8c
Address clippy warnings.
cgranade Jun 3, 2021
f4106d6
Don't use new C# 9 features.
cgranade Jun 3, 2021
65aa212
Don't store cargo lockfile in repo for now.
cgranade Jun 3, 2021
f4c404e
Remove outdated gitignore.
cgranade Jun 3, 2021
ad6fc22
Merge remote-tracking branch 'origin/main' into cgranade/experimental…
cgranade Jun 3, 2021
eb73bf7
Fix serialization test, false negatives.
cgranade Jun 3, 2021
e12568e
Use +nightly to run doctests.
cgranade Jun 3, 2021
b144ced
Allow serializing and deserializing mixed pauli channels.
cgranade Jun 3, 2021
36ebabd
Expose as_json to more Python classes.
cgranade Jun 3, 2021
e2efd44
Added ideal_stabilizer noise model, split up processes, and start CHP…
cgranade Jun 4, 2021
2342e87
Allow applying CHP decompositions.
cgranade Jun 4, 2021
ab66721
Fix clippy warnings.
cgranade Jun 4, 2021
d53e26c
Check error conditions on get_noise_model.
cgranade Jun 4, 2021
65b568c
Allow for getting/setting noise models by name.
cgranade Jun 4, 2021
620fa1d
Expose as_json for State to Python.
cgranade Jun 4, 2021
06bead5
Added stabilizer states to data model for serialization.
cgranade Jun 4, 2021
72977df
Significantly expanded documentation.
cgranade Jun 5, 2021
bb09fc4
Added header explaining how to call cargo doc.
cgranade Jun 5, 2021
7b08bff
Fix doctest.
cgranade Jun 5, 2021
1042e51
Add extra assertions.
cgranade Jun 5, 2021
633d88f
Add more debug outputs to assertion failure.
cgranade Jun 5, 2021
b33e9d1
Fixed assertion.
cgranade Jun 5, 2021
72938ea
Fixed assert.
cgranade Jun 5, 2021
c1d7350
Fix clippy warning.
cgranade Jun 5, 2021
dbebdea
Update src/Simulation/Simulators/OpenSystemsSimulator/NativeInterface.cs
Jun 6, 2021
623cf46
Fixed C# serialization.
cgranade Jun 6, 2021
c7529ca
Slight comment fixes.
cgranade Jun 6, 2021
d9a8222
Merge branch 'cgranade/experimental/qdk-sim-rs' of https://github.com…
cgranade Jun 6, 2021
5a658e2
Fix build failure.
cgranade Jun 6, 2021
8376fc3
Address review comments.
cgranade Jun 7, 2021
42c03ef
qdk_sim → qdk_sim_experimental,improve Python version handling.
cgranade Jun 7, 2021
f3c0382
Revert src/Qir to main.
cgranade Jun 7, 2021
a80fb6f
Add prerequisites.ps1.
cgranade Jun 7, 2021
b2208ad
Finish reverting QIR.
cgranade Jun 7, 2021
394e3a7
Generate C++ headers as well as C.
cgranade Jun 7, 2021
7e0f4f3
Fixed issue building docs locally with python disabled.
cgranade Jun 7, 2021
8f46c55
Updated link to tracking issue for experimental sims.
cgranade Jun 7, 2021
3db934b
Gate `cargo clean` on CI builds.
cgranade Jun 7, 2021
091ace1
Addressing feedback.
cgranade Jun 7, 2021
bb3c291
Force dependency on S.T.Encodings.Web to be >= 4.7.2.
cgranade Jun 7, 2021
939a4b8
Adding comment to explain serialization field.
cgranade Jun 7, 2021
54831b9
Added README link to experimental simulators doc.
cgranade Jun 7, 2021
8847f2a
Fix typo.
cgranade Jun 7, 2021
363b17e
Add stabilizers to state converter.
cgranade Jun 8, 2021
ce0fde5
Move format/linting checks to build from test.
cgranade Jun 8, 2021
9433e45
Fix stabilizer noise model serialization, added new test.
cgranade Jun 8, 2021
55e0a7c
Work on docs.
cgranade Jun 8, 2021
e50dccf
Fixed some slight issues with n_qubits handling.
cgranade Jun 8, 2021
e4bf294
Update documentation notebook.
cgranade Jun 8, 2021
682d440
Regenerate notebook from latest build.
cgranade Jun 8, 2021
069ba53
Fixed some serialization issues.
cgranade Jun 8, 2021
4c24851
Fixed some serialization tests.
cgranade Jun 8, 2021
141536a
Expose build info and fix mixed pauli channels.
cgranade Jun 9, 2021
1b9aa59
Updated documentation notebook from latest build.
cgranade Jun 9, 2021
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
21 changes: 10 additions & 11 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@ RUN apt-get -y update && \
apt-get -y install --no-install-recommends mono-complete nuget && \
apt-get clean && rm -rf /var/lib/apt/lists/

# Install CMake, Ninja, LLVM/Clang tools
RUN apt-get -y update && \
apt-get install -y cmake && \
apt-get install -y ninja-build && \
apt-get install -y clang-11 && \
apt-get install -y clang-tidy-11 && \
apt-get clean && rm -rf /var/lib/apt/lists/
RUN apt update \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fyi: left a bunch of general items on my review comment for you to consider. thanks!

&& apt-get install -y cmake \
ninja-build \
clang-11 \
clang-tidy-11 \
build-essential \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/

# Install C/C++ build tools and libraries
RUN apt-get -y update && \
apt-get install -y build-essential && \
apt-get clean && rm -rf /var/lib/apt/lists/
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y
CMD [ "pwsh" ]
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -339,3 +339,9 @@ ASALocalRun/
/src/Simulation/Simulators.Tests/TestProjects/QSharpExe/built
/src/Simulation/Simulators.Tests/TestProjects/TargetedExe/built
dbw_test

# Jupyter caches
.ipynb_checkpoints

# Ignore drops from building native simulators.
xplat
19 changes: 19 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# This file configures the pre-commit tool to run an initial
# suite of lightweight tests on each commit, reducing the
# probability of failing in CI.
# For more information on pre-commit, see https://pre-commit.com/.
repos:
- repo: https://github.com/doublify/pre-commit-rust
rev: v1.0
hooks:
- id: fmt
args: ['--manifest-path', 'src/Simulation/qdk_sim_rs/Cargo.toml', '--']
- id: cargo-check
args: ['--manifest-path', 'src/Simulation/qdk_sim_rs/Cargo.toml', '--']
# This step runs cargo-clippy, a linting tool provided with the
# Rust toolchain. Please see https://github.com/rust-lang/rust-clippy
# and https://rust-lang.github.io/rust-clippy/master/index.html
# for more information.
- id: clippy
args: ['--manifest-path', 'src/Simulation/qdk_sim_rs/Cargo.toml', '--']

22 changes: 22 additions & 0 deletions bootstrap.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,35 @@ Push-Location (Join-Path $PSScriptRoot "build")
.\prerequisites.ps1
Pop-Location

Push-Location (Join-Path $PSScriptRoot "./src/Simulation/qdk_sim_rs")
# We use dotnet-script to inject the version number into Cargo.toml,
# so we go on ahead here and restore any missing tools.
# Since that Cargo.toml is referenced by CMake lists in the QIR
# runtime, this injection has to be the first thing we do.
dotnet tool restore
dotnet script inject-version.csx -- `
--template Cargo.toml.template `
--out-path Cargo.toml `
--version $Env:NUGET_VERSION;
Pop-Location

if (-not (Test-Path Env:AGENT_OS)) {
if ($Env:ENABLE_NATIVE -ne "false") {
Write-Host "Build release flavor of the native simulator"
$Env:BUILD_CONFIGURATION = "Release"
Push-Location (Join-Path $PSScriptRoot "src/Simulation/Native")
.\build-native-simulator.ps1
Pop-Location
Push-Location (Join-Path $PSScriptRoot "src/Simulation/qdk_sim_rs")
# Don't run the experimental simulator build if we're local
# and prerequisites are missing.
$IsCI = "$Env:TF_BUILD" -ne "" -or "$Env:CI" -eq "true";
if ((Get-Command cargo -ErrorAction SilentlyContinue) -or $IsCI) {
.\build-qdk-sim-rs.ps1
} else {
Write-Verbose "cargo was not installed, skipping qdk_sim_rs build.";
}
Pop-Location
$Env:BUILD_CONFIGURATION = $null
}
if ($Env:ENABLE_QIRRUNTIME -ne "false") {
Expand Down
27 changes: 27 additions & 0 deletions build/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,33 @@ if ($Env:ENABLE_QIRRUNTIME -ne "false") {
Write-Host "Skipping build of qir runtime because ENABLE_QIRRUNTIME variable is set to: $Env:ENABLE_QIRRUNTIME"
}

if ($Env:ENABLE_EXPERIMENTALSIM -ne "false") {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While the feature is still experimental (or at least until we have a good automatic install story for rustup), should this part of the build also get skipped if cargo is not found in the path? That would bridge the gap for a bit for local build while some folks' environments don't yet have Rust. Something like -and (Get-Command cargo -ErrorAction SilentlyContinue) would do the trick.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. Broke it up a little bit more than your suggestion to make it obvious to the user what they need to do to proceed, and to make sure that we don't have surprising CI failures if prereq installation breaks, but I think this should bridge the gap that you point out. Thanks for flagging that!

if (-not (Get-Command cargo -ErrorAction SilentlyContinue)) {
# Cargo was missing, so cannot build experimental simulators.
# That's fine if running locally, we'll warn the user and then skip.
# On CI, though, we should fail when the experimental simulator build
# is turned on by ENABLE_EXPERIMENTALSIM, but we can't actually
# proceed.
if ("$Env:TF_BUILD" -ne "" -or "$Env:CI" -eq "true") {
Write-Host "##[error]Experimental simulators enabled, but cargo was not installed in CI pipeline.";
} else {
Write-Warning `
"Experimental simulators enabled, but cargo missing. " + `
"Either install cargo, or set `$Env:ENABLE_EXPERIMENTALSIM " + `
"to `"false`". Skipping experimental simulators.";
}
} else {
# Prerequisites are met, so let's go.
$expSim = (Join-Path $PSScriptRoot "../src/Simulation/qdk_sim_rs")
& "$expSim/build-qdk-sim-rs.ps1"
if ($LastExitCode -ne 0) {
$script:all_ok = $False
}
}
} else {
Write-Host "Skipping build of experimental simulators because ENABLE_OPENSIM variable is set to: $Env:ENABLE_OPENSIM."
}

function Build-One {
param(
[string]$action,
Expand Down
85 changes: 76 additions & 9 deletions build/pack.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,36 @@ $ErrorActionPreference = 'Stop'
& "$PSScriptRoot/set-env.ps1"
$all_ok = $True

$RepoRoot = Resolve-Path (Join-Path $PSScriptRoot "..");

Write-Host "##[info]Copy Native simulator xplat binaries"
pushd ../src/Simulation/Native
If (-not (Test-Path 'osx')) { mkdir 'osx' }
If (-not (Test-Path 'linux')) { mkdir 'linux' }
$DROP = "$Env:DROP_NATIVE/src/Simulation/Native/build/drop"
If (Test-Path "$DROP/libMicrosoft.Quantum.Simulator.Runtime.dylib") { copy "$DROP/libMicrosoft.Quantum.Simulator.Runtime.dylib" "osx/Microsoft.Quantum.Simulator.Runtime.dll" }
If (Test-Path "$DROP/libMicrosoft.Quantum.Simulator.Runtime.so") { copy "$DROP/libMicrosoft.Quantum.Simulator.Runtime.so" "linux/Microsoft.Quantum.Simulator.Runtime.dll" }
popd
Push-Location (Join-Path $PSScriptRoot ../src/Simulation/Native)
If (-not (Test-Path 'osx')) { mkdir 'osx' }
If (-not (Test-Path 'linux')) { mkdir 'linux' }
If (-not (Test-Path 'win10')) { mkdir 'win10' }

$DROP = "$Env:DROP_NATIVE/src/Simulation/Native/build/drop"
Write-Host "##[info]Copying Microsoft.Quantum.Simulator.Runtime files from $DROP...";
If (Test-Path "$DROP/libMicrosoft.Quantum.Simulator.Runtime.dylib") {
Copy-Item -Verbose "$DROP/libMicrosoft.Quantum.Simulator.Runtime.dylib" "osx/Microsoft.Quantum.Simulator.Runtime.dll"
}
If (Test-Path "$DROP/libMicrosoft.Quantum.Simulator.Runtime.so") {
Copy-Item -Verbose "$DROP/libMicrosoft.Quantum.Simulator.Runtime.so" "linux/Microsoft.Quantum.Simulator.Runtime.dll"
}


$DROP = "$Env:DROP_NATIVE/src/Simulation/qdk_sim_rs/drop";
Write-Host "##[info]Copying qdk_sim_rs files from $DROP...";
if (Test-Path "$DROP/libqdk_sim.dylib") {
Copy-Item -Verbose "$DROP/libqdk_sim.dylib" "osx/Microsoft.Quantum.Experimental.Simulators.Runtime.dll"
}
if (Test-Path "$DROP/libqdk_sim.so") {
Copy-Item -Verbose "$DROP/libqdk_sim.so" "linux/Microsoft.Quantum.Experimental.Simulators.Runtime.dll"
}
if (Test-Path "$DROP/qdk_sim.dll") {
Copy-Item -Verbose "$DROP/qdk_sim.dll" "win10/Microsoft.Quantum.Experimental.Simulators.Runtime.dll"
}
Pop-Location


function Pack-One() {
Expand All @@ -31,7 +53,7 @@ function Pack-One() {
$version = $Env:NUGET_VERSION
}

nuget pack $project `
nuget pack (Join-Path $PSScriptRoot $project) `
-OutputDirectory $Env:NUGET_OUTDIR `
-Properties Configuration=$Env:BUILD_CONFIGURATION `
-Version $version `
Expand Down Expand Up @@ -68,7 +90,7 @@ function Pack-Dotnet() {
$version = $Env:NUGET_VERSION
}

dotnet pack $project `
dotnet pack (Join-Path $PSScriptRoot $project) `
-o $Env:NUGET_OUTDIR `
-c $Env:BUILD_CONFIGURATION `
-v detailed `
Expand All @@ -87,6 +109,49 @@ function Pack-Dotnet() {
}


function Pack-Crate() {
param(
[string]
$PackageDirectory,

[string]
$OutPath
);

"##[info]Packing crate at $PackageDirectory to $OutPath..." | Write-Host

# Resolve relative to where the build script is located,
# not the PackageDirectory.
if (-not [IO.Path]::IsPathRooted($OutPath)) {
$OutPath = Resolve-Path (Join-Path $PSScriptRoot $OutPath);
}
Push-Location (Join-Path $PSScriptRoot $PackageDirectory)
cargo package;
Copy-Item -Force -Recurse (Join-Path . "target" "package") $OutPath;
Pop-Location
}

function Pack-Wheel() {
param(
[string]
$PackageDirectory,

[string]
$OutPath
);

"##[info]Packing wheel at $PackageDirectory to $OutPath..." | Write-Host

# Resolve relative to where the build script is located,
# not the PackageDirectory.
if (-not [IO.Path]::IsPathRooted($OutPath)) {
$OutPath = Resolve-Path (Join-Path $PSScriptRoot $OutPath);
}
Push-Location (Join-Path $PSScriptRoot $PackageDirectory)
pip wheel --wheel-dir $OutPath .;
Pop-Location
}

Write-Host "##[info]Using nuget to create packages"
Pack-Dotnet '../src/Azure/Azure.Quantum.Client/Microsoft.Azure.Quantum.Client.csproj'
Pack-One '../src/Simulation/CSharpGeneration/Microsoft.Quantum.CSharpGeneration.fsproj' '-IncludeReferencedProjects'
Expand All @@ -101,6 +166,8 @@ Pack-Dotnet '../src/Simulation/Type3Core/Microsoft.Quantum.Type3.Core.csproj'
Pack-One '../src/Simulation/Simulators/Microsoft.Quantum.Simulators.nuspec'
Pack-One '../src/Quantum.Development.Kit/Microsoft.Quantum.Development.Kit.nuspec'
Pack-One '../src/Xunit/Microsoft.Quantum.Xunit.csproj'
Pack-Crate -PackageDirectory "../src/Simulation/qdk_sim_rs" -OutPath $Env:CRATE_OUTDIR;
Pack-Wheel -PackageDirectory "../src/Simulation/qdk_sim_rs" -OutPath $Env:WHEEL_OUTDIR;
Pack-One '../src/Qir/Runtime/Microsoft.Quantum.Qir.Runtime.nuspec' -ForcePrerelease

if (-not $all_ok) {
Expand Down
20 changes: 19 additions & 1 deletion build/set-env.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ If ($Env:BUILD_BUILDNUMBER -eq $null) { $Env:BUILD_BUILDNUMBER ="0.0.1.0" }
If ($Env:BUILD_CONFIGURATION -eq $null) { $Env:BUILD_CONFIGURATION ="Debug" }
If ($Env:BUILD_VERBOSITY -eq $null) { $Env:BUILD_VERBOSITY ="m" }
If ($Env:ASSEMBLY_VERSION -eq $null) { $Env:ASSEMBLY_VERSION ="$Env:BUILD_BUILDNUMBER" }
If ($Env:NUGET_VERSION -eq $null) { $Env:NUGET_VERSION ="$Env:ASSEMBLY_VERSION-alpha" }
If ($Env:PYTHON_VERSION -eq $null) { $Env:PYTHON_VERSION = "${Env:ASSEMBLY_VERSION}a1" }
If ($Env:NUGET_VERSION -eq $null) { $Env:NUGET_VERSION ="0.0.1-alpha" }

If (($Env:ENABLE_NATIVE -ne "false") -and ($Env:NATIVE_SIMULATOR -eq $null) ) {
$Env:NATIVE_SIMULATOR = (Join-Path $PSScriptRoot "..\src\Simulation\Native\build\drop")
Expand All @@ -20,10 +21,27 @@ if ($Env:ENABLE_QIRRUNTIME -ne "false" -and $Env:QIR_DROPS -eq $null) {
}

If ($Env:DROPS_DIR -eq $null) { $Env:DROPS_DIR = [IO.Path]::GetFullPath((Join-Path $PSScriptRoot "..\drops")) }
if ($Env:DROP_NATIVE -eq $null) {
$Env:DROP_NATIVE = (Join-Path $PSScriptRoot "..")
}

If ($Env:NUGET_OUTDIR -eq $null) { $Env:NUGET_OUTDIR = (Join-Path $Env:DROPS_DIR "nugets") }
If (-not (Test-Path -Path $Env:NUGET_OUTDIR)) { [IO.Directory]::CreateDirectory($Env:NUGET_OUTDIR) }

If ($Env:CRATE_OUTDIR -eq $null) { $Env:CRATE_OUTDIR = (Join-Path $Env:DROPS_DIR "crates") }
If (-not (Test-Path -Path $Env:CRATE_OUTDIR)) { [IO.Directory]::CreateDirectory($Env:CRATE_OUTDIR) }

If ($Env:WHEEL_OUTDIR -eq $null) { $Env:WHEEL_OUTDIR = (Join-Path $Env:DROPS_DIR "wheels") }
If (-not (Test-Path -Path $Env:WHEEL_OUTDIR)) { [IO.Directory]::CreateDirectory($Env:WHEEL_OUTDIR) }

If ($Env:DOCS_OUTDIR -eq $null) { $Env:DOCS_OUTDIR = (Join-Path $Env:DROPS_DIR "docs") }
If (-not (Test-Path -Path $Env:DOCS_OUTDIR)) { [IO.Directory]::CreateDirectory($Env:DOCS_OUTDIR) }

Get-ChildItem @(
"Env:\DROPS_DIR",
"Env:\DROP_NATIVE",
"Env:\NUGET_OUTDIR",
"Env:\CRATE_OUTDIR",
"Env:\WHEEL_OUTDIR",
"Env:\DOCS_OUTDIR"
) | Format-Table
17 changes: 17 additions & 0 deletions build/steps-init.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,23 @@ steps:
packageType: sdk
version: '3.1.300'

- script: |
curl https://sh.rustup.rs -sSf | sh -s -- -y
echo "##vso[task.setvariable variable=PATH;]$PATH:$HOME/.cargo/bin"
displayName: Install rust
condition: ne( variables['Agent.OS'], 'Windows_NT' )
- script: |
curl -sSf -o rustup-init.exe https://win.rustup.rs
rustup-init.exe -y
echo "##vso[task.setvariable variable=PATH;]%PATH%;%USERPROFILE%\.cargo\bin"
displayName: Windows install rust
condition: eq( variables['Agent.OS'], 'Windows_NT' )

- script: |
rustup install nightly
rustup component add rustfmt clippy
rustup component add rustfmt clippy --toolchain nightly
displayName: Enable Rust formatting and nightly options.

##
# Custom pre-reqs
Expand Down
11 changes: 11 additions & 0 deletions build/test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,17 @@ if ($Env:ENABLE_QIRRUNTIME -ne "false") {
Write-Host "Skipping test of qir runtime because ENABLE_QIRRUNTIME variable is set to: $Env:ENABLE_QIRRUNTIME."
}


if ($Env:ENABLE_EXPERIMENTALSIM -ne "false") {
$expSim = (Join-Path $PSScriptRoot "../src/Simulation/qdk_sim_rs")
& "$expSim/test-qdk-sim-rs.ps1"
if ($LastExitCode -ne 0) {
$script:all_ok = $False
}
} else {
Write-Host "Skipping test of experimental simulators because ENABLE_OPENSIM variable is set to: $Env:ENABLE_OPENSIM."
}

if (-not $all_ok) {
throw "At least one project failed during testing. Check the logs."
}
Loading