{"id":23633,"library":"drjit","title":"Dr.Jit: A Just-In-Time Compiler for Differentiable Rendering","description":"Dr.Jit is a just-in-time compiler for numerical computation in differentiable rendering, supporting CUDA, LLVM, and scalar backends. It provides automatic differentiation, vectorized operations, and dynamic control flow. Version 1.3.1 is current; releases are active every few months. Requires Python >=3.8.","status":"active","version":"1.3.1","language":"python","source_language":"en","source_url":"https://github.com/mitsuba-renderer/drjit","tags":["JIT","compiler","differentiable rendering","GPU","CUDA","LLVM"],"install":[{"cmd":"pip install drjit","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Python bindings for C++ extensions","package":"nanobind","optional":false},{"reason":"LLVM backend (optional, for CPU JIT)","package":"llvm","optional":true},{"reason":"CUDA toolkit (optional, for GPU backend)","package":"cuda","optional":true}],"imports":[{"note":"Wildcard imports are discouraged; use the 'dr' alias.","wrong":"from drjit import *","symbol":"drjit","correct":"import drjit as dr"},{"note":"Mixing backends will cause runtime errors. Use drjit.llvm for CPU, drjit.cuda for GPU.","wrong":"from drjit.cuda import Array3f as Float3","symbol":"drjit.llvm.Array3f","correct":"from drjit.llvm import Array3f as Float3"},{"note":"Attribute is available at module level; using dr directly is fine, but ensure function name matches.","wrong":"import drjit; drjit.scatter_cas()","symbol":"drjit.scatter_cas","correct":"from drjit import scatter_cas"},{"note":"In v1.0+, if_stmt and cond are top-level; the dynamic module is deprecated.","wrong":"from drjit.dynamic import if_stmt","symbol":"drjit.if_stmt","correct":"from drjit import if_stmt, cond"}],"quickstart":{"code":"import drjit as dr\n\ndr.set_flag(dr.JitFlag.VCallRecord, False)  # disable for simple loops\n\n@dr.syntax\ndef f(x):\n    y = dr.zeros(dr.int32, 4)\n    for i in range(4):\n        y[i] = x[i] + 1\n    return y\n\nx = dr.arange(dr.int32, 4)\nresult = f(x)\nprint(result)","lang":"python","description":"Compile a simple loop with Dr.Jit's syntax transform."},"warnings":[{"fix":"Update imports: replace 'from drjit.dynamic import if_stmt' with 'from drjit import if_stmt'.","message":"v1.0.0 introduced a new nanobind-based API, breaking backward compatibility with v0.x. The 'drjit.dynamic' module is removed; use top-level functions like dr.if_stmt, dr.while_loop, dr.cond.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Set dr.set_flag(dr.JitFlag.VCallRecord, False) to avoid warnings, or omit if not needed.","message":"dr.JitFlag.VCallRecord is deprecated; its use is discouraged and may be removed in future versions.","severity":"deprecated","affected_versions":">=1.2.0"},{"fix":"Always use types from a single backend: e.g., drjit.cuda.Float3 or drjit.llvm.Float3, not both.","message":"Mixing backends (e.g., CUDA arrays with LLVM operations) causes runtime errors. Dr.Jit arrays are backend-specific and non-interoperable.","severity":"gotcha","affected_versions":"all"},{"fix":"Export array to numpy with dr.numpy() and plot with matplotlib.","message":"drjit.plot function has been removed in v1.0.0. Use matplotlib or other plotting libraries for visualization.","severity":"deprecated","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use 'from drjit import if_stmt' (top-level, no submodule).","cause":"Attempting to import if_stmt from drjit (it is available in drjit but the import path may be incorrect if using old code).","error":"ImportError: cannot import name 'if_stmt' from 'drjit'"},{"fix":"Ensure all arrays in a single operation originate from the same backend (e.g., all drjit.cuda.* or all drjit.llvm.*).","cause":"Using a CUDA array in an LLVM context, or vice versa.","error":"RuntimeError: Array types from different backends cannot be mixed"},{"fix":"Use matplotlib: import numpy as np; np_arr = dr.numpy(array); plt.plot(np_arr).","cause":"The plot function was removed in v1.0.0.","error":"AttributeError: module 'drjit' has no attribute 'plot'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}