MIT
Cassette is a tool for injecting user-defined code transformation passes into Julia’s JIT compilation cycle, enabling normal Julia packages to analyze, optimize, and modify Cassette-unaware Julia programs via both low-level IR transformation and high-level dispatch using Cassette’s context types. This latter feature, dubbed “contextual dispatch”, allows users to safely and quickly overload existing Julia methods with context-specific behaviors, like graph construction or derivative computation, without ever needing to handle Julia’s IR directly. Importantly, Cassette requires no manual source annotation or refactoring of target code. Cassette even works in the presence of structural and/or dispatch type constraints. This renders traditionally “invasive” techniques, like automatic differentiation, applicable to previously inapplicable Julia programs. Downstream applications for Cassette include lightweight multistage programming, dynamic code analysis (e.g. profiling, rr-style debugging, etc.), compilation to new hardware/software backends, automatic differentiation, interval constraint programming, automatic parallelization/rescheduling, automatic memoization, and more. In this talk, I’ll discuss Cassette’s design, implementation, and show how it can be used to implement automatic differentiation for native Julia code.
I like to make Julia code differentiate itself.