Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

faster ranking at prediction time #1498

Merged
merged 5 commits into from
Mar 5, 2019
Merged

faster ranking at prediction time #1498

merged 5 commits into from
Mar 5, 2019

Conversation

samhumeau
Copy link
Contributor

@samhumeau samhumeau commented Mar 5, 2019

In the case of doing predictions with 100k candidates, this part was a bit slow. This modification makes a single prediction with 100k candidates going from 2.6 sec to < 0.1 sec.

  • the main part is making sure "ranks" is on CPU. If on GPU, then what follows causes a lot of transfers between GPU mem and RAM.
  • I also thought we could cap the number of prediction by default, we probably don't need a ranked list of 100k candidates as output of each observation.

@samhumeau
Copy link
Contributor Author

Not sure why the tests aren't starting (and fail)

# No configuration was found in your project. Please refer to https://circleci.com/docs/2.0/ to get started with your configuration.

Copy link
Contributor

@emilydinan emilydinan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome 🚀

@@ -190,6 +194,8 @@ def eval_step(self, batch):
rank = (ranks[b] == label_inds[b]).nonzero().item()
self.metrics['rank'] += 1 + rank

ranks = ranks.cpu()
max_preds = self.opt["cap_num_predictions"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: single quotes

@samhumeau samhumeau merged commit 6235edd into master Mar 5, 2019
@samhumeau samhumeau deleted the tra_faster_prediction branch March 5, 2019 20:14
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants