Skip to content

Commit

Permalink
[BUG] Clear _job_queue in parallel_imap for tests (#204)
Browse files Browse the repository at this point in the history
If compilation with `nvcc` failed `_job_queue` might be not empty caused followed tests will fail with "Cannot call parallel_map recursively."

Clear `_job_queue` in `parallel_imap` before every test. 


Tested manually. 
Before: subsequent tests failed with "Cannot call parallel_map recursively."
After: only one test failed.
  • Loading branch information
vadiklyutiy committed Jul 22, 2024
1 parent ebd3d85 commit ec93d68
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,17 @@ def pytest_collection_modifyitems(config, items):


@pytest.fixture(autouse=True)
def clear_memory_cache():
def clear_before_test():
"""
Clear the memory cache before each test.
"""
# run before each test
import gc
import torch

# If previous test failed job queue for `paralles_imap` might be not free
hidet.utils.multiprocess._job_queue = None

torch.cuda.empty_cache()
hidet.runtime.storage.current_memory_pool('cuda').clear()
gc.collect() # release resources with circular references but are unreachable
Expand Down

0 comments on commit ec93d68

Please sign in to comment.