Skip to content

Instantly share code, notes, and snippets.

View ChrisRackauckas's full-sized avatar
🎯
Focusing

Christopher Rackauckas ChrisRackauckas

🎯
Focusing
View GitHub Profile
View stacktrace_after.jl
ERROR: MethodError: Cannot `convert` an object of type Float32 to an object of type Vector{Float32}
Closest candidates are:
convert(::Type{Array{T, N}}, ::SizedArray{S, T, N, N, Array{T, N}}) where {S, T, N} at C:\Users\accou\.julia\packages\StaticArrays\0T5rI\src\SizedArray.jl:121
convert(::Type{Array{T, N}}, ::SizedArray{S, T, N, M, TData} where {M, TData<:AbstractArray{T, M}}) where {T, S, N} at C:\Users\accou\.julia\packages\StaticArrays\0T5rI\src\SizedArray.jl:115
convert(::Type{<:Array}, ::LabelledArrays.LArray) at C:\Users\accou\.julia\packages\LabelledArrays\lfn1b\src\larray.jl:133
...
Stacktrace:
[1] setproperty!(x::OrdinaryDiffEq.ODEIntegrator{Tsit5, false, Vector{Float32}, Float32}, f::Symbol, v::Float32)
@ Base .\Base.jl:43
[2] initialize!(integrator::OrdinaryDiffEq.ODEIntegrator{Tsit5, false, Vector{Float32}, Float32})
View gist:d0d0324c5c7bcef6012ed12a03e35859
This file has been truncated, but you can view the full file.
function (ˍ₋out, ˍ₋arg1, ˍ₋arg2, t)
#= C:\Users\accou\.julia\packages\SymbolicUtils\v2ZkM\src\code.jl:349 =#
#= C:\Users\accou\.julia\packages\SymbolicUtils\v2ZkM\src\code.jl:350 =#
#= C:\Users\accou\.julia\packages\SymbolicUtils\v2ZkM\src\code.jl:351 =#
begin
begin
#= C:\Users\accou\.julia\packages\Symbolics\vQXbU\src\build_function.jl:452 =#
#= C:\Users\accou\.julia\packages\SymbolicUtils\v2ZkM\src\code.jl:398 =# @inbounds begin
#= C:\Users\accou\.julia\packages\SymbolicUtils\v2ZkM\src\code.jl:394 =#
ˍ₋out[1] = (/)((*)((*)((*)((*)((*)((*)(2, ˍ₋arg2[4]), ˍ₋arg2[2]), ˍ₋arg1[1]), (+)(0.5, (*)(0.5, (tanh)((/)((+)(ˍ₋arg1[14], (/)((*)((*)(ˍ₋arg2[4], ˍ₋arg2[1]), (sqrt)((+)((+)((^)((+)((*)((*)(ˍ₋arg1[9], (sin)(ˍ₋arg1[6])), (sqrt)(ˍ₋arg1[1])), (*)((*)((*)(-1, ˍ₋arg1[10]), (cos)(ˍ₋arg1[6])), (sqrt)(ˍ₋arg1[1]))), 2), (^)((+)((+)((/)((*)((*)(ˍ₋arg1[9], (+)(ˍ₋arg1[2], (*)((+)((+)(2, (*)(ˍ₋arg1[2], (cos)(ˍ₋arg1[6]))), (*)(ˍ₋arg1[3], (
@ChrisRackauckas
ChrisRackauckas / automatic_differentiation_done_quick.html
Created March 27, 2022 15:28
Automatic Differentiation Done Quick: Forward and Reverse Mode Differentiable Programming
View automatic_differentiation_done_quick.html
<!DOCTYPE html>
<HTML lang = "en">
<HEAD>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<title>Forward and Reverse Automatic Differentiation In A Nutshell</title>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
@ChrisRackauckas
ChrisRackauckas / a_pde_bruss_scaling_benchmark_python_julia.md
Last active January 11, 2022 02:19
Brusselator Stiff Partial Differential Equation Benchmark: Julia DifferentialEquations.jl vs Python SciPy. Julia 935x faster
View a_pde_bruss_scaling_benchmark_python_julia.md

Brusselator Stiff Partial Differential Equation Benchmark: Julia DifferentialEquations.jl vs Python SciPy

Tested is DifferentialEquations.jl vs Python's SciPy ODE solvers. Notes:

  • Stiff ODE solvers are used since they are required to solve this problem effectively.
  • The Python code is vectorized with for maximum performance
  • All of the performance features are tried: automatic sparsity detection, preconditioners, etc.

Results

@ChrisRackauckas
ChrisRackauckas / hasbranching.jl
Created June 22, 2021 13:54
hasbranching for automatically specializing ReverseDiff tape compilation
View hasbranching.jl
using Cassette, DiffRules
using Core: CodeInfo, SlotNumber, SSAValue, ReturnNode, GotoIfNot
const printbranch = true
Cassette.@context HasBranchingCtx
function Cassette.overdub(ctx::HasBranchingCtx, f, args...)
if Cassette.canrecurse(ctx, f, args...)
return Cassette.recurse(ctx, f, args...)
@ChrisRackauckas
ChrisRackauckas / diffeqflux_vs_jax_results.md
Last active February 7, 2023 20:08
DiffEqFlux.jl (Julia) vs Jax on an Epidemic Model
View diffeqflux_vs_jax_results.md

DiffEqFlux.jl (Julia) vs Jax on an Epidemic Model

The Jax developers optimized a differential equation benchmark in this issue which used DiffEqFlux.jl as a performance baseline. The Julia code from there was updated to include some standard performance tricks and is the benchmark code here. Thus both codes have been optimized by the library developers.

Results

Forward Pass

@ChrisRackauckas
ChrisRackauckas / gist:c05f580c40378dd6da2274e61fca599a
Created March 11, 2021 07:13
Symbolics.jl Lotka-Volterra Tracing result
View gist:c05f580c40378dd6da2274e61fca599a
retcode: Success
Interpolation: 3rd order Hermite
t: [0.0, 0.5, 1.0]
u: Vector{Num}[[x0, y0], [x0 + 0.08333333333333333((1.5x0) + (1.5(x0 + (0.5((1.5(x0 + (0.25((1.5(x0 + (0.25((1.5x0) - (x0*y0))))) - ((x0 + (0.25((1.5x0) - (x0*y0))))*(y0 + (0.25((x0*y0) - (3y0))))))))) - ((x0 + (0.25((1.5(x0 + (0.25((1.5x0) - (x0*y0))))) - ((x0 + (0.25((1.5x0) - (x0*y0))))*(y0 + (0.25((x0*y0) - (3y0))))))))*(y0 + (0.25(((x0 + (0.25((1.5x0) - (x0*y0))))*(y0 + (0.25((x0*y0) - (3y0))))) - (3(y0 + (0.25((x0*y0) - (3y0))))))))))))) + (2((1.5(x0 + (0.25((1.5x0) - (x0*y0))))) + (1.5(x0 + (0.25((1.5(x0 + (0.25((1.5x0) - (x0*y0))))) - ((x0 + (0.25((1.5x0) - (x0*y0))))*(y0 + (0.25((x0*y0) - (3y0))))))))) - ((x0 + (0.25((1.5x0) - (x0*y0))))*(y0 + (0.25((x0*y0) - (3y0))))) - ((x0 + (0.25((1.5(x0 + (0.25((1.5x0) - (x0*y0))))) - ((x0 + (0.25((1.5x0) - (x0*y0))))*(y0 + (0.25((x0*y0) - (3y0))))))))*(y0 + (0.25(((x0 + (0.25((1.5x0) - (x0*y0))))*(y0 + (0.25((x0*y0) - (3y0))))) - (3(y0 + (0.25((x0*y0) - (3y0))))))))))) - (x0*y0) - ((x0 + (0.5(
@ChrisRackauckas
ChrisRackauckas / lotka_volterra_neural_ode.jl
Last active November 4, 2020 19:28
Lotka-Volterra Learned via a Neural ODE (takes about 1 minute!)
View lotka_volterra_neural_ode.jl
using OrdinaryDiffEq
using Plots
using Flux, DiffEqFlux, Optim
function lotka_volterra(du,u,p,t)
x, y = u
α, β, δ, γ = p
du[1] = dx = α*x - β*x*y
du[2] = dy = -δ*y + γ*x*y
end
@ChrisRackauckas
ChrisRackauckas / ewing-optim-cr.jl
Created September 27, 2020 07:22
State-dependent delay diffeq model from "Modelling the Effects of Temperature on Temperature Mosquito Seasonal Abundance"
View ewing-optim-cr.jl
# --------------------------------------------------------------------------------
# Ewing model
# translation by: slwu89@berkeleu.edu (July 2020)
# --------------------------------------------------------------------------------
using DifferentialEquations
using Plots
using LabelledArrays
using StaticArrays
@ChrisRackauckas
ChrisRackauckas / conservative_package_compiler_results.md
Created September 6, 2020 05:38
Conservative package compiler testing
View conservative_package_compiler_results.md

Conservative Package Compiler Results

  1. Using a ton of standard pervasive packages only helps 10%
  2. Getting DiffEqBase helps 50%
  3. Getting OrdinaryDiffEq without extra precompiles gets to 1.3 seconds, vs 0.6 seconds on the second run. That's pretty good!