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

Improve parlai cold start #3482

Merged
merged 1 commit into from
Mar 2, 2021
Merged

Improve parlai cold start #3482

merged 1 commit into from
Mar 2, 2021

Conversation

stephenroller
Copy link
Contributor

Patch description
Delay the import of a few very expensive imports.

Testing steps
Before:

$ time parlai -h
** fvcore version of PathManager will be deprecated soon. **
** Please migrate to the version in iopath repo. **
https://github.com/facebookresearch/iopath

usage: parlai [-h] [--helpall] [--version] COMMAND ...

       _
      /")
     //)
  ==//'=== ParlAI
   /

optional arguments:
  -h, --help               show this help message and exit
  --helpall                List all commands, including advanced ones.
  --version                Prints version info and exit.

Commands:

  eval_model (em, eval)    Evaluate a model
  display_data (dd)        Display data from a task
  display_model (dm)       Display model predictions.
  train_model (tm, train)  Train a model
  interactive (i)          Interactive chat with a model on the command line
  safe_interactive         Like interactive, but adds a safety filter
  self_chat                Generate self-chats of a model
parlai -h  7.02s user 4.20s system 36% cpu 30.978 total

After:

$ time parlai -h
usage: parlai [-h] [--helpall] [--version] COMMAND ...

       _
      /")
     //)
  ==//'=== ParlAI
   /

optional arguments:
  -h, --help                  show this help message and exit
  --helpall                   List all commands, including advanced ones.
  --version                   Prints version info and exit.

Commands:

  eval_model (em, eval)       Evaluate a model
  dump_data_to_conversations  Evaluate a model
  display_data (dd)           Display data from a task
  display_model (dm)          Display model predictions.
  train_model (tm, train)     Train a model
  interactive (i)             Interactive chat with a model on the command line
  safe_interactive            Like interactive, but adds a safety filter
  self_chat                   Generate self-chats of a model
parlai -h  0.87s user 0.54s system 11% cpu 12.440 total

Copy link
Contributor

@EricMichaelSmith EricMichaelSmith left a comment

Choose a reason for hiding this comment

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

Cool - yeah, makes sense to not import until/if we need them

import rouge
except ImportError:
# User doesn't have py-rouge installed, so we can't use it.
# We'll just turn off rouge computations
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm should we print a warning here? (Same with the bleu imports)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, future diff

@@ -49,19 +49,6 @@
)


try:
Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, strange that we imported these before

@stephenroller stephenroller merged commit a467bca into master Mar 2, 2021
@stephenroller stephenroller deleted the coldstart branch March 2, 2021 15:29
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