From 222b584a8e691c9d50f48994cbc22ba6f474bd5b Mon Sep 17 00:00:00 2001 From: Roger-Luo Date: Thu, 28 Apr 2022 23:10:09 -0400 Subject: [PATCH 1/4] add quick start questions --- docs/src/quick-start.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/docs/src/quick-start.md b/docs/src/quick-start.md index 1d2e8525..aa25567c 100644 --- a/docs/src/quick-start.md +++ b/docs/src/quick-start.md @@ -1 +1,11 @@ -# Quick Start \ No newline at end of file +# Quick Start + +In this quick start, we list several common use cases for Yao before you +go deeper into the manual. + +## Create a quantum register +## Create quantum circuit with Yao blocks +## Create Hamiltonian with Yao blocks +## Automatic Differentiate a Yao block +## Combine Yao with ChainRules/Zygote +## Symbolic Calculation with Yao block From f4dd484eb8b51ead249ab56d3b9c496b20162fad Mon Sep 17 00:00:00 2001 From: Roger-Luo Date: Thu, 28 Apr 2022 23:14:31 -0400 Subject: [PATCH 2/4] add more sections --- docs/src/quick-start.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/src/quick-start.md b/docs/src/quick-start.md index aa25567c..fe256f38 100644 --- a/docs/src/quick-start.md +++ b/docs/src/quick-start.md @@ -6,6 +6,9 @@ go deeper into the manual. ## Create a quantum register ## Create quantum circuit with Yao blocks ## Create Hamiltonian with Yao blocks -## Automatic Differentiate a Yao block +## Automatic differentiate a Yao block ## Combine Yao with ChainRules/Zygote -## Symbolic Calculation with Yao block +## Symbolic calculation with Yao block +## Plot quantum circuits +## Convert quantum circuits to tensor network +## Simpllify quantum circuit with ZX calculus From c41996326d06be1a66d5fb2645dc2a388f34540f Mon Sep 17 00:00:00 2001 From: Roger-Luo Date: Thu, 28 Apr 2022 23:14:50 -0400 Subject: [PATCH 3/4] fix typo --- docs/src/quick-start.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/quick-start.md b/docs/src/quick-start.md index fe256f38..1b087e4c 100644 --- a/docs/src/quick-start.md +++ b/docs/src/quick-start.md @@ -11,4 +11,4 @@ go deeper into the manual. ## Symbolic calculation with Yao block ## Plot quantum circuits ## Convert quantum circuits to tensor network -## Simpllify quantum circuit with ZX calculus +## Simplify quantum circuit with ZX calculus From a2460f420c192d81db7f4380b68562b11853851d Mon Sep 17 00:00:00 2001 From: Roger-Luo Date: Fri, 29 Apr 2022 22:17:01 -0400 Subject: [PATCH 4/4] add more contents --- docs/Project.toml | 3 ++ docs/src/quick-start.md | 82 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 84 insertions(+), 1 deletion(-) diff --git a/docs/Project.toml b/docs/Project.toml index d865ea9c..58d3227c 100644 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -1,5 +1,6 @@ [deps] BitBasis = "50ba71b6-fa0f-514d-ae9a-0916efc90dcf" +Compose = "a81c6b42-2e10-5240-aca2-a61377ecd94b" DocThemeIndigo = "8bac0ac5-51bf-41f9-885e-2bf1ac2bec5f" Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" FFTW = "7a1cc6ca-52ef-59f5-83cd-3a7055c09341" @@ -14,4 +15,6 @@ Yao = "5872b779-8223-5990-8dd0-5abbb0748c8c" YaoAPI = "0843a435-28de-4971-9e8b-a9641b2983a8" YaoArrayRegister = "e600142f-9330-5003-8abb-0ebd767abc51" YaoBlocks = "418bc28f-b43b-5e0b-a6e7-61bbc1a2c1df" +YaoPlots = "32cfe2d9-419e-45f2-8191-2267705d8dbc" YaoSym = "3b27209a-d3d6-11e9-3c0f-41eb92b2cb9d" +ZXCalculus = "3525faa3-032d-4235-a8d4-8c2939a218dd" diff --git a/docs/src/quick-start.md b/docs/src/quick-start.md index 1b087e4c..ac132eeb 100644 --- a/docs/src/quick-start.md +++ b/docs/src/quick-start.md @@ -3,12 +3,92 @@ In this quick start, we list several common use cases for Yao before you go deeper into the manual. -## Create a quantum register +## Create a quantum register/state + +A register is an object that describes a device with an internal state. See [Registers](@ref registers) +for more details. Yao use registers to represent quantum states. The most common register +is the [`ArrayReg`](@ref), you can create it by feeding a state vector to it, e.g + +```@repl quick-start +using Yao +ArrayReg(rand(ComplexF64, 2^3)) +zero_state(5) +rand_state(5) +product_state(bit"10100") +ghz_state(5) +``` + +the internal quantum state can be accessed via [`statevec`](@ref) method + +```@repl quick-start +statevec(ghz_state(2)) +``` + +for more functionalities about registers please refer to the manual of [`registers`](@ref). + ## Create quantum circuit with Yao blocks + +Yao uses the quantum "block"s to describe quantum circuits, e.g +the following code creates a 2-qubit circuit + +```@repl quick-start +chain(2, put(1=>H), put(2=>X)) +``` + +where `H` gate is at 1st qubit, `X` gate is at 2nd qubit. +A more advanced example is the quantum Fourier transform circuit + +```@repl quick-start +A(i, j) = control(i, j=>shift(2π/(1<<(i-j+1)))) +B(n, k) = chain(n, j==k ? put(k=>H) : A(j, k) for j in k:n) +qft(n) = chain(B(n, k) for k in 1:n) +qft(3) +``` + ## Create Hamiltonian with Yao blocks + +the quantum "block"s are expressions on quantum operators, thus, it can +also be used to represent a Hamiltonian, e.g we can create a simple Ising +Hamiltonian on 1D chain as following + +```@repl quick-start +sum(kron(5, i=>Z, mod1(i+1, 5)=>Z) for i in 1:5) +``` + ## Automatic differentiate a Yao block + +Yao has its own automatic differentiation rule implemented, this allows one obtain +gradients of a loss function by simply putting a `'` mark behind [`expect`](@ref) +or [`fidelity`](@ref), e.g + +```@repl quick-start +expect'(X, zero_state(1)=>Rx(0.2)) +``` + +or for fiedlity + +```@repl quick-start +fidelity'(zero_state(1)=>Rx(0.1), zero_state(1)=>Rx(0.2)) +``` + ## Combine Yao with ChainRules/Zygote + + ## Symbolic calculation with Yao block +Yao supports symbolic calculation of quantum circuit via `SymEngine`. We can show + + ## Plot quantum circuits + +The [YaoPlots]() in Yao's ecosystem provides plotting for quantum circuits and ZX diagrams. + +```@example quick-start +using Yao.EasyBuild, YaoPlots +using Compose + +# show a qft circuit +Compose.SVG(plot(qft_circuit(5))) +``` + ## Convert quantum circuits to tensor network ## Simplify quantum circuit with ZX calculus