Struggling to understand this error: ValueError: [eval] Attempting to eval an array without a primitive. #1047
-
I've gone through the docs but I just don't understand what causes the "ValueError: [eval] Attempting to eval an array without a primitive." error? For example, I'm training a mamba implementation that can be found at: https://github.com/alxndrTL/mamba.py/tree/main/mlx, in which I replaced the stock linear output with a custom classification output. In the training code, the following function raised this error:
Commenting out the compilation line fixed the issue after a whole day of trying to figure it out; I still don't know why. Similarly, the following vectorised map function (I'm new to vmap), for two identically shaped arrays, throws the same value error:
And I'm yet again confused. What am I doing wrong and what exactly does the error mean? The docs say something about primitives defining the way arrays are evaluated, but I'm not sure I really understand the explanation. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Sorry that message is not so helpful, we should add a documentation on that. There's basically two cases in which you could see that message:
For example, updating z = []
@mx.compile
def fun(x, y):
z.append(x + y)
return x * y
out = fun(mx.array(1.0), mx.array(1.0))
print(z) # ValueError: [eval] Attempting to eval an array without a primitive.
|
Beta Was this translation helpful? Give feedback.
There should be some other state you are using. The common one that people miss is the RNG state if they are using the global RNG. See here for example. If that's not it, I don't know why it's throwing that error for you. I'd be happy to take a look if you are able to share some code to reproduce.