This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### A Pluto.jl notebook ### | |
# v0.19.9 | |
using Markdown | |
using InteractiveUtils | |
# ╔═╡ 195eb152-17e7-11ed-32ab-ab200fb170af | |
using Yao, YaoPlots, Polynomials | |
# ╔═╡ f6f10336-205c-4581-9418-de6fdd9b6418 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# To run this script, you need to install required packages in a Julia REPL: | |
# ```julia | |
# using Pkg; Pkg.add(["GenericTensorNetworks", "CUDA", "Comonicon", "DelimitedFiles"]) | |
# ``` | |
# | |
# Then open a terminal, go to the file folder and type | |
# ```bash | |
# $ julia fib2d.jl 20 | |
# ``` | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using LinearAlgebra: mul! | |
""" | |
strassen!(C, A, B, s0=8) | |
Compute matrix multiplication `C = A * B` using the strassen algorithm. | |
`s0` is the critical size to stop Strassen recursion, it can be slow if it recurse too deep, | |
then one needs to set this value larger. | |
!!!note |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# requires OMEinsum version >= 0.7 | |
using Distributed | |
using OMEinsum, CUDA | |
println("find $(length(devices())) GPU devices") | |
const procs = addprocs(length(devices())-nprocs()+1) | |
const gpus = collect(devices()) | |
const process_device_map = Dict(zip(procs, gpus)) | |
@info process_device_map |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using TropicalNumbers, VectorizationBase | |
using Test | |
using LoopVectorization, Octavian | |
using VectorizationBase: OffsetPrecalc, StaticBool, Bit, static, NativeTypes, Index, gep_quote, VectorIndex | |
function distance(a::AbstractArray{<:Tropical}, b::AbstractArray{<:Tropical}) | |
sum(abs.(content.(a) .- content.(b))) | |
end | |
LoopVectorization.check_args(::Type{T}, ::Type{T}) where T<:Tropical = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# v0.12.17 | |
using Markdown | |
using InteractiveUtils | |
# ╔═╡ f178d9fe-49f4-11eb-0863-21e2e3934592 | |
using Yao, YaoPlots | |
# ╔═╡ d59b39ec-49f5-11eb-3d4a-fb69f2505d3c | |
using SymEngine |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using CUDA | |
using CUDA.WMMA | |
using CUDA.WMMA: ColMajor, load_a, load_b, load_c, mma, store_d | |
using StaticArrays | |
a = rand(Float16, 16, 16) | |
b = rand(Float16, 16, 16) | |
c = zeros(Float16, 16, 16) | |
d = zeros(Float16, 16, 16) | |
a_dev = CuArray(a) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
optimizer: | |
ip: 127.0.0.1 | |
port: 2000 | |
method: spsa | |
initial-params: specified | |
initial-params.random: | |
seed: 2 | |
p: 5 | |
initial-params.specified: | |
- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 3 | |
3 1 | |
3 2 | |
4 4 | |
2 2 | |
5 4 | |
1 2 | |
5 2 | |
2 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Yao | |
using YaoBlocks | |
using YaoBlocks.ConstGate: TGate, SGate, TdagGate, SdagGate | |
function Base.show(io::IO, ::MIME"qasm/open", blk::AbstractBlock) | |
qcode = qasm(blk) | |
println(io, "OPENQASM 2.0") | |
maincode = pop!(qcode, "main") | |
for k in keys | |
println(io, qcode) |
NewerOlder