Skip to content

Instantly share code, notes, and snippets.

View wangleiphy's full-sized avatar

Lei Wang wangleiphy

View GitHub Profile
@Roger-luo
Roger-luo / Register.jl
Created May 13, 2018 12:14
A naive quanutm register
#################
# Utils
#################
"""
log2i(x)
logrithm for integer pow of 2
"""
function log2i(x::T)::T where T
@arthurmensch
arthurmensch / double_backward.py
Created May 19, 2018 10:25
Custom twice differentiable functions in Pytorch.
"""
Custom twice differentiable functions in Pytorch.
Author: Arthur Mensch
"""
import torch
import torch.nn as nn
@kylemcdonald
kylemcdonald / Adversarial Variational Bayes toy example.ipynb
Last active May 3, 2024 00:03
Adversarial Variational Bayes toy example in PyTorch
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kylemcdonald
kylemcdonald / ACAI (PyTorch).ipynb
Last active March 12, 2023 18:37
PyTorch ACAI (1807.07543).
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
from jax.interpreters import ad
from jax.interpreters import partial_eval as pe
from jax import custom_transforms
from jax import core
from jax import grad
@custom_transforms
def f(x, y):
return x**2 + 3 * y
@GiggleLiu
GiggleLiu / naive_einsum.jl
Last active January 20, 2020 09:16
CUDAnative based einsum! on GPU - the prototype
using TupleTools
using Base.Cartesian
using CuArrays, CUDAnative
"""
A naive implementation of `einsum!`
* `ixs`: input tensor indices,
* `xs`: input tensors,
* `iy`: output tensor indices,
* `y`: accumulated tensor, notice it is initialized to 0 as output!
@caryan
caryan / Quantum Optimal Control with SciML.ipynb
Created June 10, 2020 04:32
Quantum Optimal Control with SciML and Julia
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@shoyer
shoyer / simple-jax-gmres.ipynb
Created July 7, 2020 21:11
Simple JAX GMRES
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@shoyer
shoyer / jax-harmonic-oscillator-odeint.ipynb
Last active December 11, 2021 16:43
JAX harmonic oscillator odeint.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Roger-luo
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))
else
$ex
end
end |> esc
end