Skip to content

Instantly share code, notes, and snippets.

View Roger-luo's full-sized avatar
casting spells

Xiu-zhe (Roger) Luo Roger-luo

casting spells
View GitHub Profile
Roger-luo /
Created November 4, 2021 18:19
use Maddie's code to find the ratio
import qsim
import matplotlib.pyplot as plt
import numpy as np
from qsim.evolution import hamiltonian
from qsim.graph_algorithms.graph import unit_disk_grid_graph, rydberg_graph
from qsim.graph_algorithms.adiabatic import SimulateAdiabatic
from qsim import schrodinger_equation
import matplotlib.gridspec as gridspec
import scipy.sparse
import scipy.optimize
Roger-luo /
Created October 27, 2021 22:09
open a remote file via ssh using vscode
function remote () {
code --remote ssh-remote+desktop /home/roger/code/$1
using Expronicon
using MLStyle
function expand_mlstyle(m::Module, ex)
@switch ex begin
@case Expr(:macrocall, Symbol("@match"), xs...) || Expr(:macrocall, Symbol("@switch"), xs...) ||
Expr(:macrocall, Symbol("@λ"), xs...)
return expand_mlstyle(m, macroexpand(m, ex))
@case ::Expr
return Expr(ex.head, map(x->expand_mlstyle(m, x), ex.args)...)
using YaoLocations
using BenchmarkTools
using BQCESubroutine
using StrideArrays
using BQCESubroutine.Utilities
using LoopVectorization
using ThreadingUtilities
using ArrayInterface
using BQCESubroutine.Utilities: BitSubspace
using Random
using Yao
using Plots
using LinearAlgebra
using QuantumInformation
function run_circuit!(r::AbstractRegister, θs::Matrix, p::Real=0.0)
n = nqubits(r)
for j in 1:size(θs, 2) # each layer
for i in 1:size(θs, 1)÷2 # each wire
Roger-luo / tiny_yao.jl
Created December 20, 2020 07:05
Implement your own (full amplitude) top performance quantum circuit emulator in ONE day!
macro _threads(ex)
return quote
if (Threads.nthreads() > 1) && (length(st) > 4096)
$(Expr(:macrocall, Expr(:(.), :Threads, QuoteNode(Symbol("@threads"))), __source__, ex))
end |> esc
using YaoCompiler
using YaoCompiler.Intrinsics
qasm"""OPENQASM 2.0;
include "";
gate post q {x q;}
@device function circuit()
using Dates
function count_hours(m)
days = filter(Date(2020, m, 14): Day(1):Date(2020, m+1, 13)) do day
!(dayname(day) in ["Saturday", "Sunday"])
return length(days) * 8
count_hours(7) * 30
using CUDA
using ExponentialUtilities
using LinearAlgebra
using BenchmarkTools
using ExponentialUtilities: getV, getH, get_cache, _exp!
using LinearAlgebra: BlasReal, BlasComplex
using SparseArrays
using Flux
struct Linear{T, WT <: AbstractMatrix{T}, BT <: AbstractVector{T}}
Flux.functor(m::Linear) = (m.W, m.b), (W, b) -> Linear(W, b)
m = Linear(rand(2, 2), rand(2))