What is Dr.Jit and how does it work?
masterDr.Jit is a just-in-time (JIT) compiler designed for ordinary and differentiable computation. It is optimized for workloads with extremely large and complex computation graphs (e.g., millions of elementary arithmetic nodes) that might cause standard machine learning frameworks like JAX, TensorFlow, or PyTorch to crash or time out.
Dr.Jit operates through three primary mechanisms:
- Tracing and Vectorization: Instead of executing arithmetic operations immediately, Dr.Jit records them into a computation graph. This graph is then JIT-compiled into efficient fused kernels. Supported backends include:
- GPU:
Metal(macOS) orCUDA(other platforms). - CPU: Host CPU using vector instruction sets like
AVX512orNEONviaLLVM. - Header-only mode: Can be used without JIT-compilation as a standard header-only vector library.
- GPU:
- Differentiation: Supports automatic differentiation (AD) using both
forwardandreverse-modeaccumulation. Tracing and differentiation are integrated to produce specialized derivative evaluation code. - Multi-language Support: Dr.Jit types are accessible in both C++17 and Python. You can develop in either language or mix them, as combinations of Python and C++ code can be jointly traced and differentiated.