Skip to content

Commit 9b5e85c

Browse files
committed
Resetting fusion cache when fusion exceeds the max_fusions limit.
The FusionCache_CUDA test attempts to reset and get a fresh FusionCache. If the currect cache contains more fusions than what is requested for the new max_fusions limit it will fail to enforce the new max_fusions constraint.
1 parent 3d4ef80 commit 9b5e85c

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

python/python_frontend/fusion_cache.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,27 @@ FusionCache* FusionCache::get(
347347
if (load_from_default_workspace && fs::exists(file_path)) {
348348
try {
349349
singleton_->deserialize(file_path);
350+
351+
// Check if deserialized cache exceeds max_fusions limit
352+
if (singleton_->fusions_.size() > max_fusions) {
353+
std::cout
354+
<< "Warning: Deserialized cache contains "
355+
<< singleton_->fusions_.size()
356+
<< " fusions, which exceeds the requested max_fusions limit of "
357+
<< max_fusions << ". Resetting cache." << std::endl;
358+
359+
// Delete incompatible workspace
360+
std::error_code remove_ec;
361+
fs::remove(file_path, remove_ec);
362+
if (remove_ec) {
363+
std::cout << "Failed to delete common workspace. Exception:\t"
364+
<< remove_ec.message() << std::endl;
365+
}
366+
367+
// Reset FusionCache
368+
delete singleton_;
369+
singleton_ = new FusionCache(max_fusions, selected_device);
370+
}
350371
} catch (const std::exception& deserialize_exception) {
351372
// The saved workspace can become out-of-date between nvfuser updates.
352373
// Send warning and delete the incompatible workspace.

0 commit comments

Comments
 (0)