Comments (4)
Here is some additional information on this issue:
- Disabling the bufferization inlining (as suggested by @erick-xanadu) makes the compiler output correct results in most cases. We put a Catalyst version with the inlining disabled as d934fa7 .
- For this modified Catalyst, some tests always seem to be correct, but others are sometimes wrong.
- An example of the flickering test is shown below. The fact that
f
returns multiple outputs seems to be important. We didn't see incorrect results from single-output versions off
.
import jax.numpy as jnp
from catalyst import qjit, grad as C_grad
from numpy.testing import assert_allclose
def f(x):
return (x, jnp.stack([1*x, 2*x, 3*x]))
@qjit
def C_workflow():
return C_grad(f, method='fd', argnum=[0])(jnp.zeros([4], dtype=float))
# Check the consistency
r0 = C_workflow()
for i in range(10):
print(f"Iteration {i}")
r1 = C_workflow()
for a,b in zip(r0,r1):
assert_allclose(a, b, rtol=1e-6, atol=1e-6)
An example output:
Iteration 0
Iteration 1
Iteration 2
Traceback (most recent call last):
File "/workspace/src/vjp_study/issue1.py", line 19, in <module>
assert_allclose(a, b, rtol=1e-6, atol=1e-6)
File "/opt/venv/lib/python3.10/site-packages/numpy/testing/_private/utils.py", line 1527, in assert_allclose
assert_array_compare(compare, actual, desired, err_msg=str(err_msg),
File "/opt/venv/lib/python3.10/site-packages/numpy/testing/_private/utils.py", line 844, in assert_array_compare
raise AssertionError(msg)
AssertionError:
Not equal to tolerance rtol=1e-06, atol=1e-06
Mismatched elements: 2 / 16 (12.5%)
Max absolute difference: 1.
Max relative difference: 2.13755206e+302
x: array([[1., 0., 0., 0.],
[0., 1., 0., 0.],
[0., 0., 1., 0.],
[0., 0., 0., 1.]])
y: array([[4.678249e-303, 0.000000e+000, 0.000000e+000, 0.000000e+000],
[4.678249e-303, 0.000000e+000, 0.000000e+000, 0.000000e+000],
[4.678249e-303, 0.000000e+000, 1.000000e+000, 0.000000e+000],
[4.678249e-303, 0.000000e+000, 0.000000e+000, 1.000000e+000]])
from catalyst.
@grwlf can you show here the LLVM-IR?
from catalyst.
@grwlf can you show here the LLVM-IR?
Sure, this one? https://gist.github.com/grwlf/cf485111b55c19c3a2a9c6bbeed84777
from catalyst.
Resolved by #121
from catalyst.
Related Issues (20)
- Document how to install ccache for macOS and virtualenv
- Autograph fails when used with Catalyst's JAX VJP integration
- Support building on conda
- [BUG] `jax.scipy.linalg.expm` doesn't work due to undefined symbols
- Compiling with return signature raises an exception.
- Find a better way to link blas routines from jaxlib HOT 2
- Add exponential fitting functionality to ZNE HOT 4
- Add local folding to ZNE error mitigation HOT 4
- Automatic conversion of operator-based array updates
- [BUG] catalyst.for_loop default argument `i` cannot be used as a concrete value HOT 10
- Can we use `--buffer-results-to-out-params`?
- It would be nice to have an interface (or documentation) for accessing the original function of a QJIT object HOT 3
- [BUG] `jax.value_and_grad` fails when the differentiated circuit has a complex matrix under `QubitUnitary` HOT 3
- [BUG] `jax.value_and_grad` gives different numerical results depending on whether a qnode is `qjit` compiled or not HOT 1
- [BUG] Compiled tutorial_qft.py with Qrack simulator HOT 6
- Consider eliminating redundant "shots" parameters in device back end API HOT 1
- Add EnumAttr to the Gradient Dialect for different differentiation methods.
- Create an operation interface for grad methods.
- Add a function that will be called after the lowering process is finished.
- [BUG] `qml.pauli_decompose` fails inside qjit, even with jnp arrays as inputs and `check_hermitian` turned off HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from catalyst.