Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CI, depend on newest Braket.jl and get doc build working #2

Merged
merged 10 commits into from
Apr 26, 2024
77 changes: 77 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: CI
on:
push:
branches:
- main
tags: ['*']
pull_request:
workflow_dispatch:
concurrency:
# Skip intermediate builds: always.
# Cancel intermediate builds: only if it is a pull request build.
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
jobs:
test:
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
runs-on: ${{ matrix.os }}
timeout-minutes: 60
permissions: # needed to allow julia-actions/cache to proactively delete old caches that it has created
actions: write
contents: read
strategy:
fail-fast: false
matrix:
version:
- '1.9'
- 'nightly'
os:
- ubuntu-latest
- macOS-latest
- windows-latest
arch:
- x64
steps:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v1
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: julia-actions/cache@v1
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-runtest@v1
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v3
kshyatt-aws marked this conversation as resolved.
Show resolved Hide resolved
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: lcov.info
docs:
name: Documentation
runs-on: ubuntu-latest
permissions:
actions: write # needed to allow julia-actions/cache to proactively delete old caches that it has created
contents: write
statuses: write
steps:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v1
with:
version: '1'
- uses: julia-actions/cache@v1
- name: Configure doc environment
shell: julia --project=docs --color=yes {0}
run: |
using Pkg
Pkg.develop(PackageSpec(path=pwd()))
Pkg.instantiate()
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-docdeploy@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Run doctests
shell: julia --project=docs --color=yes {0}
run: |
using Documenter: DocMeta, doctest
using Braket, BraketSimulator
DocMeta.setdocmeta!(BraketSimulator, :DocTestSetup, :(using Braket, BraketSimulator); recursive=true)
doctest(BraketSimulator)
25 changes: 25 additions & 0 deletions .github/workflows/Documentation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Documentation

on:
push:
branches:
- main # update to match your development branch (master, main, dev, trunk, ...)
tags: '*'

jobs:
build:
permissions:
contents: write
statuses: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@v1
with:
version: '1.6'
- name: Install dependencies
run: julia --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()'
- name: Build and deploy
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: julia --project=docs/ docs/make.jl
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ BraketSimulatorPythonExt = "PythonCall"

[compat]
Aqua = "=0.8"
Braket = "=0.8.2"
Braket = "=0.8.3"
Combinatorics = "=1.0.2"
Dates = "1.6"
JSON3 = "=1.14.0"
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# BraketSimulator

[![Aqua](https://raw.githubusercontent.com/JuliaTesting/Aqua.jl/master/badge.svg)](https://github.com/JuliaTesting/Aqua.jl)
[![Stable docs](https://img.shields.io/badge/docs-stable-blue.svg)](https://amazon-braket.github.io/BraketSimulator.jl/stable)
[![Latest docs](https://img.shields.io/badge/docs-dev-blue.svg)](https://amazon-braket.github.io/BraketSimulator.jl/dev)
[![CI](https://github.com/amazon-braket/braketsimulator.jl/actions/workflows/CI.yml/badge.svg)](https://github.com/amazon-braket/braketsimulator.jl/actions/workflows/CI.yml)
[![Coverage](https://codecov.io/gh/amazon-braket/BraketSimulator.jl/graph/badge.svg?token=TvAJbwbNcn)](https://codecov.io/gh/amazon-braket/BraketSimulator.jl)

This package is a quantum circuit simulator written in the [Julia programming language](https://julialang.org/), meant to be compatible with the [Amazon Braket SDK](https://github.com/aws/amazon-braket-sdk-python). It can simulate gate-based quantum circuits using both statevectors and density matrices (when noise is present).

Expand Down
5 changes: 2 additions & 3 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ makedocs(;
],
)

# TODO UNCOMMENT ME WHEN PUBLIC
#=deploydocs(;
deploydocs(;
repo="github.com/amazon-braket/BraketSimulator.jl",
devbranch="main",
)=#
)
12 changes: 8 additions & 4 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,14 @@ using Pkg
Pkg.add("BraketSimulator")
```

Then you can run a simulation of a simple [GHZ state](https://en.wikipedia.org/wiki/Greenberger%E2%80%93Horne%E2%80%93Zeilinger_state) preparation circuit:
Then you can run a simulation of a simple [GHZ state](https://en.wikipedia.org/wiki/Greenberger%E2%80%93Horne%E2%80%93Zeilinger_state) preparation circuit.

!!! note
To simulate OpenQASM3 programs, you will need to load the Python extension `BraketSimulatorPythonExt` like so: `using PythonCall, BraketSimulator`. If
you prefer not to install or use Python, make sure to set the default `IRType` for `Braket.jl` to JAQCD: `Braket.IRType[] = :JAQCD`.

```jldoctest
julia> using Braket, BraketSimulator
julia> using Braket, BraketSimulator

julia> n_qubits = 10;

Expand All @@ -44,9 +48,9 @@ julia> foreach(q->CNot(c, 0, q), 1:n_qubits-1);

julia> Amplitude(c, [repeat("0", n_qubits), repeat("1", n_qubits)]);

julia> sim = LocalSimulator("braket_sv"); # use the state vector simulator (without noise)
julia> sim = LocalSimulator("braket_sv_v2"); # use the state vector simulator (without noise)

julia> res = result(sim(c, shots=0));
julia> res = result(simulate(sim, ir(c, Val(:JAQCD)), shots=0));

julia> res.values
1-element Vector{Any}:
Expand Down
11 changes: 2 additions & 9 deletions docs/src/sims.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,6 @@ and an **array type** (so that we can specialize for GPU arrays, for example).

Each simulator can be initialized with a `qubit_count` and `shots` value. You may query the [`properties`](@ref Braket.properties) of a simulator to learn what gate types, result types, and other operations it supports.

```@docs
AbstractSimulator
StateVectorSimulator
DensityMatrixSimulator
Braket.properties(::StateVectorSimulator)
Braket.properties(::DensityMatrixSimulator)
BraketSimulator.evolve!
expectation
probabilities
```@autodocs
Modules = [BraketSimulator]
```
4 changes: 3 additions & 1 deletion test/test_braket_integration.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ end
NOISE_DEVICES = [NOISE_DEVICE]
SHOT_LIST = (0, 8000)

# looser tolerance bounds here to account
# for differences in `np.allclose` vs `isapprox`
get_tol(shots::Int) = return (
shots > 0 ? Dict("atol" => 0.1, "rtol" => 0.15) : Dict("atol" => 0.01, "rtol" => 0)
shots > 0 ? Dict("atol" => 0.2, "rtol" => 0.25) : Dict("atol" => 0.01, "rtol" => 0)
)

bell_circ() = Circuit([(H, 0), (CNot, 0, 1)])
Expand Down
Loading