Support PyArrow - #202
Conversation
alexdavey
left a comment
There was a problem hiding this comment.
Thanks @younik! The PR looks great. I have a few comments below, and also a few inline comments in the diff.
-
I believe there is a small issue with how seeds are stored. If the first episode has
seed=None, all subsequent seeds will not be recorded, and silently ignored. Always storing an explicit seed (storingNoneif none is set), seems to fix this issue. See the related comment in the diff. -
The
combine_datasets()utility currently always combines into anhdf5dataset. For feature parity, we could add adata_formatoption there to allow combining intoarrowdatasets as well. -
Some of the tests do not check both data formats, initialising only the default
DataCollector. I think the following tests could be parameterised to cover thearrowformat as well:test_data_collector_step_data_callback()test_data_collector_step_data_callback_info_correction()test_combine_datasets()
-
The info shape check function
_check_infos_same_shape()is no longer used, and can be removed since that check is now covered implicitly byjtu.tree_map().
The read timing speeds for the larger datasets is somewhat concerning. I don't think this should prevent this PR from going through, but ideally we could investigate to see if some performance tuning is possible, in the near future.
|
Thanks @alexdavey for the review!
Wow, nice catch, thanks! I fixed it
Good observation. However, we plan in the near future to allow combining datasets without creating new storages, but just sampling from multiple underline storages. This will make combining datasets much faster, which is very important to train foundation models on a multitude of different datasets. When we will do this, we would need to remove the data_format arg, which would be a breaking change. For now, I changed it to use the format of the first dataset; how does it sounds to you? I also fixed the other problems.
True, this surprised me as well. I believe in the multithreading scenario Arrow will show better performances, but I didn't have the chance to check. |
alexdavey
left a comment
There was a problem hiding this comment.
The proposal re combine_datasets makes sense, and thank you for taking a look at the performance issues! It all LGTM. Feel free to merge when ready :)
|
Indeed, I managed to improve reading performances of Arrow. Instead of using I updated the PR comment with the new plots. |
* add arrow storage * use two different methods for info/spaces * fix info shape * add deps * fix pre-commit * fix None seed * fix docs * fix minari show * fix docs * remove max_buffer steps * add EpisodeBuffer utility * fix tests * fix docs * add docstring * fix h5py storage * reformat * test both storages * improve tests * reformat * use arrow instead of parquet * change default to hdf5 * refactor data_collector * add typing to EpisodeBuffer * address comments * add data_format to tests * fix dataset combine test * improve arrow efficiency
Description
This PR adds:
However, this introduces important changes:
MinariDataset#134). We should agree on a common API.This should be fixed before the PyPi release.
jax[cpu](as utility to stack PyTrees),pyarrow. We should consider minimizing mandatory dependencies.Benchmark
I run a benchmark comparing HDF5 and Arrow for different sizes/spaces on an AMD EPYC 7543 32-Core Processor (code here).