Skip to content

Commit

Permalink
Format section
Browse files Browse the repository at this point in the history
  • Loading branch information
mofeing committed Sep 14, 2023
1 parent 9c98a66 commit 74ede73
Showing 1 changed file with 84 additions and 77 deletions.
161 changes: 84 additions & 77 deletions docs/src/transformations.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,84 +13,16 @@ transform
transform!
```

# Example: RQC simplification
Here we show how can we reduce the complexity of the tensor network by applying a tranformation to it. We take as an example the Sycamore circuit from the [Google's quantum supremacy paper](https://www.nature.com/articles/s41586-019-1666-5)

```@setup plot
using Makie
Makie.inline!(true)
## Transformations

using CairoMakie
using Tenet
using NetworkLayout
### Hyperindex converter

using Pkg
Pkg.add("QuacIO")
function smooth_annotation!(f; color=Makie.RGBAf(110 // 256, 170 // 256, 250 // 256, 60 // 256), xlims=[-2, 2], ylims=[-2, 2], offset_x=0.0, offset_y=0.0, radius_x=1.0, radius_y=1.0, num_waves=5, fluctuation_amplitude=0.1, phase_shift=0.0)
ax = Axis(f)
hidedecorations!(ax)
hidespines!(ax)
# Define limits of the plot
xlims!(ax, xlims...)
ylims!(ax, ylims...)
# Create a perturbed filled shape
theta = LinRange(0, 2π, 100)
fluctuations = fluctuation_amplitude .* sin.(num_waves .* theta .+ phase_shift)
# Apply the fluctuations and radius scaling
perturbed_radius_x = radius_x .+ fluctuations
perturbed_radius_y = radius_y .+ fluctuations
circle_points = [Point2f((perturbed_radius_x[i]) * cos(theta[i]) + offset_x,
(perturbed_radius_y[i]) * sin(theta[i]) + offset_y) for i in 1:length(theta)]
poly!(ax, circle_points, color=color, closed=true)
end
bg_blue = Makie.RGBAf(110 // 256, 170 // 256, 250 // 256, 50 // 256) #hide
orange = Makie.RGBf(240 // 256, 180 // 256, 100 // 256) #hide
red = Makie.RGBf(240 // 256, 90 // 256, 70 // 256) #hide
```
```@example plot
using QuacIO
set_theme!(resolution=(800,400)) # hide
sites = [5, 6, 14, 15, 16, 17, 24, 25, 26, 27, 28, 32, 33, 34, 35, 36, 37, 38, 39, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 61, 62, 63, 64, 65, 66, 67, 72, 73, 74, 75, 76, 83, 84, 85, 94]
circuit = QuacIO.parse(joinpath(@__DIR__, "sycamore_53_10_0.qasm"), format=QuacIO.Qflex(), sites=sites)
tn = TensorNetwork(circuit)
# Apply transformations to the tensor network
transformed_tn = transform(tn, [Tenet.AntiDiagonalGauging, Tenet.DiagonalReduction, Tenet.ColumnReduction, Tenet.RankSimplification])
fig = Figure() # hide
ax1 = Axis(fig[1, 1]) # hide
p1 = plot!(ax1, tn; edge_width=0.75, node_size=8., node_attr=(strokecolor=:black, strokewidth=0.5)) # hide
ax2 = Axis(fig[1, 2]) # hide
p2 = plot!(ax2, transformed_tn; edge_width=0.75, node_size=8., node_attr=(strokecolor=:black, strokewidth=0.5)) # hide
ax1.titlesize, ax2.titlesize = 20, 20 # hide
hidedecorations!(ax1) # hide
hidespines!(ax1) # hide
hidedecorations!(ax2) # hide
hidespines!(ax2) # hide
Label(fig[1, 1, Bottom()], "Original") # hide
Label(fig[1, 2, Bottom()], "Transformed") # hide
fig # hide
```

# Transformations

## Hyperindex converter
```@docs
Tenet.HyperindConverter
```

## Diagonal reduction
### Diagonal reduction

```@docs
Tenet.DiagonalReduction
```
Expand Down Expand Up @@ -149,12 +81,14 @@ Label(fig[1, 2, Bottom()], "Transformed") #hide
fig #hide
```

## Anti-diagonal reduction
### Anti-diagonal reduction

```@docs
Tenet.AntiDiagonalGauging
```

## Rank simplification
### Rank simplification

```@docs
Tenet.RankSimplification
```
Expand Down Expand Up @@ -205,7 +139,7 @@ Label(fig[1, 2, Bottom()], "Transformed") #hide
fig #hide
```

## Column reduction
### Column reduction

```@docs
Tenet.ColumnReduction
Expand Down Expand Up @@ -259,7 +193,8 @@ plot!(fig[1, 2], reduced, layout=Spring(iterations=2000, C=40, seed=8); node_col
fig #hide
```

## Split simplification
### Split simplification

```@docs
Tenet.SplitSimplification
```
Expand Down Expand Up @@ -310,4 +245,76 @@ Label(fig[1, 2, Bottom()], "Transformed") #hide
plot!(fig[1, 2], reduced, layout=Spring(iterations=10000, C=13, seed=151); node_color=[orange, orange, red, red, red, :black, :black, :black, :black]) #hide
fig #hide
```
```

## Example: RQC simplification

Here we show how can we reduce the complexity of the tensor network by applying a tranformation to it. We take as an example the Sycamore circuit from the [Google's quantum supremacy paper](https://www.nature.com/articles/s41586-019-1666-5)

```@setup plot
using Makie
Makie.inline!(true)
using CairoMakie
using Tenet
using NetworkLayout
using Pkg
Pkg.add("QuacIO")
function smooth_annotation!(f; color=Makie.RGBAf(110 // 256, 170 // 256, 250 // 256, 60 // 256), xlims=[-2, 2], ylims=[-2, 2], offset_x=0.0, offset_y=0.0, radius_x=1.0, radius_y=1.0, num_waves=5, fluctuation_amplitude=0.1, phase_shift=0.0)
ax = Axis(f)
hidedecorations!(ax)
hidespines!(ax)
# Define limits of the plot
xlims!(ax, xlims...)
ylims!(ax, ylims...)
# Create a perturbed filled shape
theta = LinRange(0, 2π, 100)
fluctuations = fluctuation_amplitude .* sin.(num_waves .* theta .+ phase_shift)
# Apply the fluctuations and radius scaling
perturbed_radius_x = radius_x .+ fluctuations
perturbed_radius_y = radius_y .+ fluctuations
circle_points = [Point2f((perturbed_radius_x[i]) * cos(theta[i]) + offset_x,
(perturbed_radius_y[i]) * sin(theta[i]) + offset_y) for i in 1:length(theta)]
poly!(ax, circle_points, color=color, closed=true)
end
bg_blue = Makie.RGBAf(110 // 256, 170 // 256, 250 // 256, 50 // 256) #hide
orange = Makie.RGBf(240 // 256, 180 // 256, 100 // 256) #hide
red = Makie.RGBf(240 // 256, 90 // 256, 70 // 256) #hide
```

```@example plot
using QuacIO
set_theme!(resolution=(800,400)) # hide
sites = [5, 6, 14, 15, 16, 17, 24, 25, 26, 27, 28, 32, 33, 34, 35, 36, 37, 38, 39, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 61, 62, 63, 64, 65, 66, 67, 72, 73, 74, 75, 76, 83, 84, 85, 94]
circuit = QuacIO.parse(joinpath(@__DIR__, "sycamore_53_10_0.qasm"), format=QuacIO.Qflex(), sites=sites)
tn = TensorNetwork(circuit)
# Apply transformations to the tensor network
transformed_tn = transform(tn, [Tenet.AntiDiagonalGauging, Tenet.DiagonalReduction, Tenet.ColumnReduction, Tenet.RankSimplification])
fig = Figure() # hide
ax1 = Axis(fig[1, 1]) # hide
p1 = plot!(ax1, tn; edge_width=0.75, node_size=8., node_attr=(strokecolor=:black, strokewidth=0.5)) # hide
ax2 = Axis(fig[1, 2]) # hide
p2 = plot!(ax2, transformed_tn; edge_width=0.75, node_size=8., node_attr=(strokecolor=:black, strokewidth=0.5)) # hide
ax1.titlesize, ax2.titlesize = 20, 20 # hide
hidedecorations!(ax1) # hide
hidespines!(ax1) # hide
hidedecorations!(ax2) # hide
hidespines!(ax2) # hide
Label(fig[1, 1, Bottom()], "Original") # hide
Label(fig[1, 2, Bottom()], "Transformed") # hide
fig # hide
```

0 comments on commit 74ede73

Please sign in to comment.