Skip to content

Commit 1038679

Browse files
authored
Clean up main thread compile cache before python interpreter shuts down (#4373)
1 parent 846d176 commit 1038679

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

python/src/transforms.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1538,4 +1538,11 @@ void init_transforms(nb::module_& m) {
15381538
A callable that recomputes intermediate states during gradient
15391539
computation.
15401540
)pbdoc");
1541+
1542+
// Clean up main thread compile cache before python interpreter shuts down.
1543+
auto atexit = nb::module_::import_("atexit");
1544+
atexit.attr("register")(
1545+
nb::cpp_function([cache = mx::detail::compile_cache()]() {
1546+
mx::detail::compile_clear_cache(cache);
1547+
}));
15411548
}

0 commit comments

Comments
 (0)