My Journey and Lessons Learned
Zachary Sunberg, Assistant Professor
University of Colorado Boulder
Scientific computing is pretty good these days
How many have...
- Rewritten MATLAB or Python code in C?
- Written Python or MATLAB bindings for C code so that others can use it?
Julia solves the two language problem!!
Julia is
- as easy to read, write, maintain, and collaborate with as Python or MATLAB
- as fast as C
EASIER
FASTER
Be skeptical
Find out for yourself!
My Journey
2011
2013
2014
Also ~2011: Improving TCAS
ACAS X
POMDP Models
+
=
Optimization
Specification
Previous C++ framework: APPL
"At the moment, the three packages are independent. Maybe one day they will be merged in a single coherent framework."
JuliaPOMDP
POMDPs.jl - An interface for defining and solving MDPs and POMDPs in Julia
[Egorov, Sunberg, et al., 2017]
POMCP Tree Vis
POMCPOW + Friends
Future
Short Term (next month 🙂)
Long Term
- New classes of problems (games)
- Composability (dynamic decision diagrams)
Lessons
1. Composability
Think about 3 People
1. You (package writer)
2. User
3. Other Package Writer
# HybridAStar.jl
Environment(xlim, ylim, obstacles)
# Polygons.jl
Base.in(x::AbstractVector, p::Polygon)
if collision(state, obstacle)
# ...
end
if state[1:2] in obstacle
# ...
end
2. Make the easy things easy
Old:
Tip for Julia: Let the user pass functions that define behavior
(they can make custom types <: Function if they want)
transition!(m::YourMDP, s::State, a::Action)
New:
transition(m::YourMDP, s, a)
(And the complex things possible)
Old:
value_estimate = SquaredStateValueEstimator()
New:
estimate_value = s->s^2
3. Communication (simplicity) is key
Old:
transition!(m::YourMDP, s, a, d=create_transition_distribution(m))
New:
transition(m::YourMDP, s, a)
Old:
generate_s(m::YourMDP, s, a, rng) = s + a + randn(rng)
New:
transition(m::YourMDP, s, a) = ImplicitDistribution(rng->s+a+randn(rng))
Thank You!
Why should I believe it's fast?
Julia - Speed
Celeste Project
1.54 Petaflops
Why should I believe it's easy to use?
How does it work?
Speed: Just-in-time LLVM Compilation
Code: Multiple Dispatch,
Optional Type Indications,
First Class Arrays
+
=
Julia is
- as easy to read, write, maintain, and collaborate with as Python or MATLAB
- as fast as C
EASIER
FASTER
Cool things that Julia can do
- Auto-differentiation
- CUDA
- Multithreading
- Distributed Computing, from single chip to a cluster
using CUDA
x_d = CUDA.fill(1.0f0, N) # a vector stored on the GPU filled with 1.0 (Float32)
y_d = CUDA.fill(2.0f0, N) # a vector stored on the GPU filled with 2.0
function add_broadcast!(y, x)
CUDA.@sync y .+= x
return
end
add_broadcast!(y_d, x_d)
numblocks = ceil(Int, length(y)/256)
CUDA.@sync begin
@cuda threads=256 blocks=numblocks gpu_add!(y, x)
end
Compatibility with other languages: C
#include <julia.h>
JULIA_DEFINE_FAST_TLS() // only define this once, in an executable (not in a shared library) if you want fast code.
int main(int argc, char *argv[])
{
/* required: setup the Julia context */
jl_init();
/* run Julia commands */
jl_eval_string("print(sqrt(2.0))");
/* strongly recommended: notify Julia that the
program is about to terminate. this allows
Julia time to cleanup pending write requests
and run all finalizers
*/
jl_atexit_hook(0);
return 0;
}
x=ccall((:mean,"libmean"),Float64,(Float64,Float64),2.0,5.0)
println(x)
3.5
double mean(double a, double b) {
return (a+b) / 2;
}
Julia from C
C from Julia
Compatibility with other languages: Python
Questions?
zachary.sunberg@colorado.edu
CTU Julia POMDP Hackathon
By Zachary Sunberg
CTU Julia POMDP Hackathon
- 440