Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding parallelization to "tfq.convert_to_tensor" for performance (#336) #793

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

redayzarra
Copy link

@redayzarra redayzarra commented Jul 13, 2023

Overview

Hi, this is a draft pull request for improving the tfq.convert_to_tensor function by adding parallelization (#336). I'm confused about how the benchmarking suite works, so I am creating a draft pull request. For parallelization, I made sure to follow the Python documentation for concurrent.futures and used ProcessPoolExecutor.

Since the convert_item function is mostly CPU-bound and doesn't require heavy communication between processes, using ProcessPoolExecutor should provide a significant speed-up for large inputs.

I have simply added parallelization to the tfq.convert_to_tensor function and need help with benchmarking and testing.

Changes

Parallelization: used concurrent.futures.ProcessPoolExecutor to parallelize the conversion of items. Each item in the list is processed independently, which allows for significant speedup for converting large lists of items.

Docstrings: the original function had informative docstrings that described the tfq.convert_to_tensor function. I made sure to keep most of it and only added the necessary changes and fixed typos.

Concerns

I wasn't able to benchmark my changes or run unit tests. I tried my best to follow the Contribution guidelines but ran into a lot of errors with Bazel. I am still working on the issue and wanted to inform you that the code has not been benchmarked using the Benchmark guidelines.

If the function needs to handle extremely deep nested lists, the convert_item() function may need to be iterative rather than recursive. However, the original author already made a comment to dismiss this concern.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant