Closed carsonwoods closed 4 months ago
Hey @carsonwoods, thanks for the report.
I think the issues is that parallel gridsearch requires the constituent parts of the pipeline to be picklable.
for instance, BatchRetrieve has __reduce__
etc:
https://github.com/terrier-org/pyterrier/blob/master/pyterrier/batchretrieve.py#L279-L300
but QueryExpansion does not.
For testing, we would need to add some RM3 like pipelines to https://github.com/terrier-org/pyterrier/blob/master/tests/test_pickle.py
If you are super-keen for the functionality, would you be able to try to form a PR for this?
Hi @cmacdonald, thanks for the quick reply! That makes sense as to why I was seeing that issue.
I'd love to work on a PR for this, but I'm currently a bit swamped with work for my academic program. If no one else works on this, I will try to take this on when I have time, but I'm unsure how quickly that will happen.
Hi @carsonwoods
@cmacdonald Thanks for working on this! I tested my environment against your PR and everything works perfectly. Thanks again for getting this capability added so quickly. Feel free to close this issue once the PR is merged!
Ok, I will take it as working and merge. Glad you found it useful.
Describe the bug I am a relatively new user of PyTerrier. As part of familiarizing myself with PyTerrier, I am tuning a pipeline using GridSearch. Using the default
joblib
backend, I tried to parallelize my GridSaerch with 8 jobs (jobs=8
). The GridSearch runs fine sequentially, but when I enabled the parallelization it failed. I've included the full error message in the reproduction steps below.To Reproduce Steps to reproduce the behavior:
pt.TRECCollectionIndexer
function.rm3_pipe = tuned_bm25 >> rm3 >> tuned_bm25
wheretuned_bm25
was a BM25 BatchRetreval andrm3
was apt.rewrite.RM3
object.The above exception was the direct cause of the following exception:
Traceback (most recent call last): File "/Users/carsonwoods/Library/CloudStorage/Dropbox/School/Spring-2024/CS572-Information-Retrieval/cs572-information-retreival/hw1/rm3_ranker.py", line 152, in
rm3_tuned_pipe = pt.GridSearch(
^^^^^^^^^^^^^^
File "/Users/carsonwoods/anaconda3/lib/python3.11/site-packages/pyterrier/pipelines.py", line 752, in GridSearch
grid_outcomes = GridScan(
^^^^^^^^^
File "/Users/carsonwoods/anaconda3/lib/python3.11/site-packages/pyterrier/pipelines.py", line 906, in GridScan
eval_list = parallel_lambda(_evaluate_several_settings, batched_inputs, jobs, backend=backend)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/carsonwoods/anaconda3/lib/python3.11/site-packages/pyterrier/parallel.py", line 52, in parallel_lambda
return _parallel_lambda_joblib(function, inputs, jobs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/carsonwoods/anaconda3/lib/python3.11/site-packages/pyterrier/parallel.py", line 63, in _parallel_lambda_joblib
return parallel_mp(
^^^^^^^^^^^^
File "/Users/carsonwoods/anaconda3/lib/python3.11/site-packages/joblib/parallel.py", line 1098, in call
self.retrieve()
File "/Users/carsonwoods/anaconda3/lib/python3.11/site-packages/joblib/parallel.py", line 975, in retrieve
self._output.extend(job.get(timeout=self.timeout))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/carsonwoods/anaconda3/lib/python3.11/site-packages/joblib/_parallel_backends.py", line 567, in wrap_future_result
return future.result(timeout=timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/carsonwoods/anaconda3/lib/python3.11/concurrent/futures/_base.py", line 456, in result
return self.get_result()
^^^^^^^^^^^^^^^^^^^
File "/Users/carsonwoods/anaconda3/lib/python3.11/concurrent/futures/_base.py", line 401, in get_result
raise self._exception
_pickle.PicklingError: Could not pickle the task to send it to the workers.
/Users/carsonwoods/anaconda3/lib/python3.11/multiprocessing/resource_tracker.py:224: UserWarning: resource_tracker: There appear to be 8 leaked semaphore objects to clean up at shutdown
warnings.warn('resource_tracker: There appear to be %d '