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

[Torchscript] Parallelized Text/Sequence Preprocessing #2206

Merged
merged 10 commits into from
Jun 29, 2022

Conversation

geoffreyangus
Copy link
Collaborator

@geoffreyangus geoffreyangus commented Jun 28, 2022

This PR parallelizes sequence tokenization for sequence and text features. This gives us better or equal inference throughput relative to vanilla Ludwig Model preprocessing.

One thing to note: there were/are strange interactions with torch.no_grad and the added parallelism. It seems that torch.no_grad affects some global flag that activates/deactivates gradient computation (link), and it seems that this flag is not properly reset after some scripted, parallelized operation.

The workaround has to do with the insight that gradients are not computed during preprocessing time and that the extraneous torch.no_grad statements could be removed (particularly around preprocessing and postprocessing). Applying the torch.no_grad context exclusively at the predictor stage of inference is enough to ensure that the module output tensors contain no gradients. Added tests confirm this. That said, we should keep this issue in mind if we decide to introduce parallelism in our ECD architecture.

AGNEWS_small_batches_cpu
AGNEWS_large_batches_cpu
AGNEWS_small_batches_cuda
AGNEWS_large_batches_cuda

@github-actions
Copy link

github-actions bot commented Jun 28, 2022

Unit Test Results

       6 files  ±  0         6 suites  ±0   2h 11m 29s ⏱️ - 19m 34s
2 886 tests +  6  2 840 ✔️ +  6    46 💤 ±0  0 ±0 
8 658 runs  +18  8 516 ✔️ +18  142 💤 ±0  0 ±0 

Results for commit 76310eb. ± Comparison against base commit 5193e0d.

♻️ This comment has been updated with latest results.

@tgaddair tgaddair merged commit 76055a2 into master Jun 29, 2022
@tgaddair tgaddair deleted the ts-sequence-parallelism branch June 29, 2022 14:50
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

2 participants