Skip to content

SymPy integration - #502

Open
DoeringChristian wants to merge 1 commit into
masterfrom
sympy_integration
Open

SymPy integration#502
DoeringChristian wants to merge 1 commit into
masterfrom
sympy_integration

Conversation

@DoeringChristian

@DoeringChristian DoeringChristian commented May 23, 2026

Copy link
Copy Markdown
Contributor

This PR adds integration to sympy using the dr.wrap decorator.

SymPy is a symbolic expressions engine. This PR adds it as a target for dr.wrap, allowing us to compute higher order derivatives (hessians) etc in Dr.Jit. In contrast to other targets for this decorator the SymPy target does not exchange data between the libraries at runtime, but rather traces the symbolic expressions generated by the wrapped function, and compiles it to Dr.Jit. The wrapped function therefore acts like an ordinary Dr.Jit function, while we can use the complicated symbolic operations supported by SymPy. The wrapped functions are restricted to per-lane operations. Inverting a Matrix4f inside of this wrapper will generate the necessary code for Dr.Jit to invert the matrix. Calling the function with a Matrix array in Dr.Jit will therefore invert each matrix per SIMD lane.

@DoeringChristian DoeringChristian changed the title SymPU integration SymPy integration May 23, 2026
@wjakob

wjakob commented May 25, 2026

Copy link
Copy Markdown
Member

Hi Christian,

thank you for the PR, this looks like a very useful feature. My suggestion would be to do another crunching pass over the code. 1.5K is .. a lot! I feel like this code has some of the fluffiness of partly AI-generated and could do with some simplification passes to reduce it to a more minimal form (matching also the documented API surface).

Thanks,
Wenzel

@DoeringChristian
DoeringChristian force-pushed the sympy_integration branch 3 times, most recently from 9e8f222 to 0075a6d Compare May 27, 2026 15:00

@wjakob wjakob left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realize I never submitted my comments from the original PR :-(

Comment thread docs/interop.rst Outdated
Comment thread docs/interop.rst
Comment thread docs/interop.rst Outdated
Comment thread drjit/sympy/custom.py Outdated
Comment thread drjit/sympy/custom.py Outdated
Comment thread tests/test_sympy.py Outdated
Comment thread tests/test_sympy.py Outdated
Comment thread tests/test_sympy.py Outdated
Comment thread docs/interop.rst Outdated
Comment thread docs/interop.rst Outdated
@wjakob
wjakob force-pushed the master branch 3 times, most recently from 3912746 to 45500e3 Compare June 18, 2026 22:11
@wjakob
wjakob force-pushed the master branch 4 times, most recently from 4fc980f to 32bcaa6 Compare June 29, 2026 21:28
@wjakob
wjakob force-pushed the master branch 7 times, most recently from 60b72ec to 23ef9cd Compare August 22, 2026 03:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants