Skip to content

Commit

Permalink
Merge branch 'main' into dev/cuda
Browse files Browse the repository at this point in the history
  • Loading branch information
ytdHuang authored May 17, 2024
2 parents d0b930f + d04d1da commit e48aeef
Show file tree
Hide file tree
Showing 34 changed files with 474 additions and 114 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/Benchmarks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Benchmark Tracking
on:
push:
branches:
- 'main'
paths-ignore:
- 'docs/**'
pull_request:
branches:
- 'main'
paths-ignore:
- 'docs/**'
types:
- opened
- reopened
- synchronize
- ready_for_review

permissions:
actions: write
contents: write
deployments: write

jobs:
benchmark:
runs-on: ubuntu-latest
if: ${{ !github.event.pull_request.draft }}
steps:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v2
with:
version: '1'
arch: x64
- uses: julia-actions/cache@v2
- name: Run benchmark
run: |
cd benchmarks
julia --project --threads=2 --color=yes -e '
using Pkg;
Pkg.develop(PackageSpec(path=joinpath(pwd(), "..")));
Pkg.instantiate();
include("runbenchmarks.jl")'
- name: Parse & Upload Benchmark Results
uses: benchmark-action/github-action-benchmark@v1
with:
name: Benchmark Results
tool: "julia"
output-file-path: benchmarks/benchmarks_output.json
github-token: ${{ secrets.GITHUB_TOKEN }}
alert-threshold: "200%"
fail-on-alert: true
benchmark-data-dir-path: benchmarks
max-items-in-chart: 100
auto-push: ${{ github.event_name != 'pull_request' }}
19 changes: 14 additions & 5 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,9 @@ jobs:
strategy:
fail-fast: false
matrix:
# for core tests
# for core tests (latest and oldest supported versions)
version:
- '1.8'
- '1.9'
- '1.7'
- '1.10'
os:
- ubuntu-latest
Expand All @@ -42,8 +41,18 @@ jobs:
group:
- Core

# for code quality tests
include:
# for core tests (intermediate versions)
- version: '1.8'
os: 'ubuntu-latest'
arch: 'x64'
group: 'Core'
- version: '1.9'
os: 'ubuntu-latest'
arch: 'x64'
group: 'Core'

# for code quality tests
- version: '1'
os: 'ubuntu-latest'
arch: 'x64'
Expand All @@ -55,7 +64,7 @@ jobs:
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: julia-actions/cache@v1
- uses: julia-actions/cache@v2
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-runtest@v1
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- uses: julia-actions/setup-julia@v2
with:
version: '1'
- uses: julia-actions/cache@v1
- uses: julia-actions/cache@v2
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-docdeploy@v1
env:
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
.DS_Store

*.jl.*.cov
*.jl.cov
*.jl.mem
Manifest.toml
docs/build/
.vscode

.vscode
*.json
8 changes: 3 additions & 5 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
name = "QuantumToolbox"
uuid = "6c2fb7c5-b903-41d2-bc5e-5a7c320b9fab"
authors = ["Alberto Mercurio"]
version = "0.7.2"
version = "0.8.0"

[deps]
DiffEqCallbacks = "459566f4-90b8-5000-8ac3-15dfb0a30def"
Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b"
FFTW = "7a1cc6ca-52ef-59f5-83cd-3a7055c09341"
Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6"
IncompleteLU = "40713840-3770-5561-ab4c-a76e7d0d7895"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
LinearMaps = "7a12625a-238d-50fd-b39a-03d52299707e"
LinearSolve = "7ed4a6bd-45f5-4d41-b270-4a48e9bafcae"
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
Expand All @@ -27,7 +27,6 @@ QuantumToolboxCUDAExt = "CUDA"
[compat]
CUDA = "5"
DiffEqCallbacks = "2, 3"
Distributed = "<0.0.1, 1"
FFTW = "1.5"
Graphs = "1.7"
IncompleteLU = "0.2"
Expand All @@ -44,8 +43,7 @@ Test = "<0.0.1, 1"
julia = "1.7"

[extras]
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Pkg", "Test"]
test = ["Test"]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[![Build Status](https://github.com/albertomercurio/QuantumToolbox.jl/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/albertomercurio/QuantumToolbox.jl/actions/workflows/CI.yml?query=branch%3Amain)
[![Aqua QA](https://raw.githubusercontent.com/JuliaTesting/Aqua.jl/master/badge.svg)](https://github.com/JuliaTesting/Aqua.jl)
[![Coverage](https://codecov.io/gh/albertomercurio/QuantumToolbox.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/albertomercurio/QuantumToolbox.jl)
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.10822817.svg)](https://doi.org/10.5281/zenodo.10822817)
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.11096277.svg)](https://doi.org/10.5281/zenodo.11096277)

## Introduction
[QuantumToolbox.jl](https://github.com/albertomercurio/QuantumToolbox.jl) is a cutting-edge Julia package designed for quantum physics simulations, closely emulating the popular Python [QuTiP](https://github.com/qutip/qutip) package. It uniquely combines the simplicity and power of Julia with advanced features like GPU acceleration and distributed computing, making simulation of quantum systems more accessible and efficient.
Expand Down
3 changes: 3 additions & 0 deletions benchmarks/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[deps]
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
QuantumToolbox = "6c2fb7c5-b903-41d2-bc5e-5a7c320b9fab"
18 changes: 18 additions & 0 deletions benchmarks/correlations_and_spectrum.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
function benchmark_correlations_and_spectrum()
N = 15
ω = 1
γ = 0.1
nth = 0.02

a = destroy(N)
H = ω * a' * a
c_ops = [sqrt* (nth + 1)) * a, sqrt* nth) * a']

ω_l = range(0, 3, length=1000)

SUITE["Correlations and Spectrum"]["FFT Correlation"] = @benchmarkable spectrum($H, $ω_l, $(a'), $a, $c_ops, solver=FFTCorrelation(), progress_bar=false)

SUITE["Correlations and Spectrum"]["Exponential Series"] = @benchmarkable spectrum($H, $ω_l, $(a'), $a, $c_ops)
end

benchmark_correlations_and_spectrum()
33 changes: 33 additions & 0 deletions benchmarks/dynamical_fock_dimension.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
function H_dfd2(dims, p)
Δ = p.Δ
F = p.F
J = p.J
a = tensor(destroy(dims[1]), qeye(dims[2]))
b = tensor(qeye(dims[1]), destroy(dims[2]))
Δ * a' * a + F * (a + a') + Δ * b' * b + J * (a' * b + a * b')
end
function c_ops_dfd2(dims, p)
κ = p.κ
a = tensor(destroy(dims[1]), qeye(dims[2]))
b = tensor(qeye(dims[1]), destroy(dims[2]))
[κ * a, κ * b]
end
function e_ops_dfd2(dims, p)
a = tensor(destroy(dims[1]), qeye(dims[2]))
b = tensor(qeye(dims[1]), destroy(dims[2]))
[a' * a, b' * b]
end

function benchmark_dfd()
F, Δ, κ, J = 1, 0.25, 1, 0.05
maxdims = [50, 50]

ψ0 = tensor(fock(3, 0), fock(20, 15))
dfd_params ==Δ, F=F, κ=κ, J=J)

tlist = range(0, 15 / κ, 100)

SUITE["Time Evolution"]["Dynamical Fock Dimension"] = @benchmarkable dfd_mesolve(H_dfd2, $ψ0, $tlist, c_ops_dfd2, $maxdims, $dfd_params, e_ops=e_ops_dfd2, progress_bar=false)
end

benchmark_dfd()
22 changes: 22 additions & 0 deletions benchmarks/eigenvalues.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
function benchmark_eigenvalues()
N = 5
a = tensor(destroy(N), qeye(N))
a_d = a'
b = tensor(qeye(N), destroy(N))
b_d = b'

ωc = 1
ωb = 1
g = 0.2
κ = 0.01
n_thermal = 0.1

H = ωc * a_d * a + ωb * b_d * b + g * (a + a_d) * (b + b_d)
c_ops = [((1+n_thermal)*κ) * a, κ * b, (n_thermal*κ) * a_d]
L = liouvillian(H, c_ops)

SUITE["Eigenvalues"]["eigenstates"]["dense"] = @benchmarkable eigenstates($L)
SUITE["Eigenvalues"]["eigenstates"]["sparse"] = @benchmarkable eigenstates($L, sparse=true, sigma=0.01, k=5)
end

benchmark_eigenvalues()
18 changes: 18 additions & 0 deletions benchmarks/runbenchmarks.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using BenchmarkTools
using QuantumToolbox

BLAS.set_num_threads(1)

const SUITE = BenchmarkGroup()

include("correlations_and_spectrum.jl")
include("dynamical_fock_dimension.jl")
include("eigenvalues.jl")
include("steadystate.jl")
include("timeevolution.jl")

BenchmarkTools.tune!(SUITE)
results = BenchmarkTools.run(SUITE, verbose = true)
display(median(results))

BenchmarkTools.save("benchmarks_output.json", median(results))
15 changes: 15 additions & 0 deletions benchmarks/steadystate.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
function benchmark_steadystate()
N = 50
Δ = 0.1
F = 2
γ = 1
nth = 5

a = destroy(N)
H = Δ * a' * a + F * (a + a')
c_ops = [sqrt* (nth + 1)) * a, sqrt* nth) * a']

SUITE["Steadystate"]["Direct"] = @benchmarkable steadystate($H, $c_ops)
end

benchmark_steadystate()
47 changes: 47 additions & 0 deletions benchmarks/timeevolution.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
function benchmark_timeevolution()
ωc = 1
ωq = 1
g = 0.1
ωd = 0.99
F = 0.07

Δc = ωc - ωd
Δq = ωq - ωd

# Operators definition
N = 20 # cutoff for the cavity Hilbert space
a = tensor(destroy(N), qeye(2))
σm = tensor(qeye(N), sigmam())
σz = tensor(qeye(N), sigmaz())

# Hamiltonian
H = Δc * a' * a + Δq * σz / 2 + g * (a' * σm + a * σm') + F * (a + a')

e_ops = [a'*a, σz]

# Initial state
ψ0 = tensor(coherent(N, 0), fock(2, 1))

## sesolve ##

tlist = range(0, 2π * 10 / g, 1000)

SUITE["Time Evolution"]["time-independent"]["sesolve"] = @benchmarkable sesolve($H, $ψ0, $tlist, e_ops=$e_ops, progress_bar=false)

## mesolve ##

nth = 0.01
γ = 0.05
c_ops = [sqrt* (nth + 1)) * a, sqrt* nth) * a', sqrt(γ) * σm]

tlist = range(0, 10/γ, 100)

SUITE["Time Evolution"]["time-independent"]["mesolve"] = @benchmarkable mesolve($H, $ψ0, $tlist, $c_ops, e_ops=$e_ops, progress_bar=false)

## mcsolve ##

SUITE["Time Evolution"]["time-independent"]["mcsolve"]["Serial"] = @benchmarkable mcsolve($H, $ψ0, $tlist, $c_ops, n_traj=100, e_ops=$e_ops, progress_bar=false, ensemble_method=EnsembleSerial())
SUITE["Time Evolution"]["time-independent"]["mcsolve"]["Multithreaded"] = @benchmarkable mcsolve($H, $ψ0, $tlist, $c_ops, n_traj=100, e_ops=$e_ops, progress_bar=false, ensemble_method=EnsembleThreads())
end

benchmark_timeevolution()
3 changes: 1 addition & 2 deletions docs/Project.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
[deps]
CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
LaTeXStrings = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
4 changes: 3 additions & 1 deletion docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ DocMeta.setdocmeta!(QuantumToolbox, :DocTestSetup, :(using QuantumToolbox); recu
makedocs(;
modules=[QuantumToolbox],
authors="Alberto Mercurio",
# repo="https://github.com/albertomercurio/QuantumToolbox.jl/blob/{commit}{path}#{line}",
repo = Remotes.GitHub("albertomercurio", "QuantumToolbox.jl"),
sitename="QuantumToolbox.jl",
format=Documenter.HTML(;
Expand All @@ -30,6 +29,9 @@ makedocs(;
"api.md",
"Users Guide" => [
"Low Rank Master Equation" => "lowrank.md",
],
"Benchmarks" => [
"Benchmark History" => "benchmarks/benchmark_history.md",
]
],
)
Expand Down
6 changes: 6 additions & 0 deletions docs/src/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,9 @@ _adjM_condition_ratio
_pinv!
dBdz!
```

## [Miscellaneous](@id API: Miscellaneous)
```@docs
QuantumToolbox.versioninfo
QuantumToolbox.about
```
3 changes: 3 additions & 0 deletions docs/src/benchmarks/benchmark_history.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```@raw html
<iframe src="https://albertomercurio.github.io/QuantumToolbox.jl/benchmarks/" style="width:100%;height:500px; border: none;"></iframe>
```
Loading

0 comments on commit e48aeef

Please sign in to comment.