Multiple invocation of a jax FFI binded function leads to incorrect results #28005
Unanswered
Vandermode
asked this question in
Q&A
Replies: 1 comment 3 replies
-
I don't think there's enough information here to provide any feedback! I don't see why there would be any JAX-specific interactions with allocated temporary buffers - JAX just executes your C++ code! If you can make a small reproducible example that doesn't depend on your external library, I'd be happy to help debug that. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi @dfm ,
Apologies for the follow-up, but I’ve encountered an unexpected behavior while using the FFI API, building on our previous discussion in #27763.
Your guidance helped me successfully bind my C function, and initial results matched expectations. However, further testing revealed a peculiar issue with the JAX binding that I’d like to clarify.
below is the code for performance benchmarking.
Observations:
Root Cause:
After extensive testing, I traced the issue to temporary buffers allocated automatically within my C function. This is confirmed because:
Core Question:
How can we safely wrap a C function that internally allocates temporary buffers? The current behavior suggests that JAX FFI interactions with these buffers lead to incorrect results upon subsequent invocations.
Beta Was this translation helpful? Give feedback.
All reactions