Skip to content

Program halts before completion #1618

Closed Answered by awni
stockeh asked this question in Q&A
Nov 22, 2024 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

The problem is that you are never evaluating the graph and the graph is very very large. So if you do something like:

for j in range(steps):
   ### do a lot of computation

Then you keep appending operations to your compute graph.. but nothing actually triggers the evaluation. In your case steps=50000 and let's say there are 100 ops per step.. that means the graph is 5 million ops (!).

In general with an iterative numerical computation you can eval the graph at each iteration and that is usually fine.

So just do:

mx.eval(sol, sol_t)

at the end of your loop.

For more on how this all works, check-out the docs and this gist.

One more comment, doing

if mx.any(mx.isnan(w_h)):
    raise ValueError(

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@stockeh
Comment options

Answer selected by stockeh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants