Skip to content

Commit

Permalink
Eval before cleanup so model file is unlocked (#1702)
Browse files Browse the repository at this point in the history
  • Loading branch information
zcbenz authored Dec 15, 2024
1 parent f9640e0 commit af5a614
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions python/tests/test_nn.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ def make_model():
m.save_weights(npz_file)
m_load = make_model()
m_load.load_weights(npz_file)

# Eval before cleanup so model file is unlocked.
mx.eval(m_load.state)
tdir.cleanup()

eq_tree = tree_map(mx.array_equal, m.parameters(), m_load.parameters())
Expand All @@ -110,6 +113,9 @@ def make_model():
m.save_weights(safetensors_file)
m_load = make_model()
m_load.load_weights(safetensors_file)

# Eval before cleanup so model file is unlocked.
mx.eval(m_load.state)
tdir.cleanup()

eq_tree = tree_map(mx.array_equal, m.parameters(), m_load.parameters())
Expand Down

0 comments on commit af5a614

Please sign in to comment.