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

Support jit in CompartmentalModel #2526

Merged
merged 2 commits into from
Jun 14, 2020
Merged

Support jit in CompartmentalModel #2526

merged 2 commits into from
Jun 14, 2020

Conversation

fritzo
Copy link
Member

@fritzo fritzo commented Jun 14, 2020

Addresses #2426

This supports jit_compile=True in CompartmentalModel.fit(). Changes include:

  • plumbing arguments through interfaces and scripts
  • replacing Tensor.__iter__() with Tensor.unbind(0) to issue the correct warning type, so it can be ignored by ignore_jit_warnings=True.

Performance

Anecdotally about 1.6x speedup (with identical output):

nojit jit
44 sec 27 sec python examples/contrib/epidemiology/sir.py
89 sec 56 sec python examples/contrib/epidemiology/regional.py -hfm=7

Tested

  • added unit tests
  • added to test_examples.py::test_jit

@@ -149,6 +150,7 @@ def main(args):
parser.add_argument("--single", action="store_false", dest="double")
parser.add_argument("--rng-seed", default=0, type=int)
parser.add_argument("--cuda", action="store_true")
parser.add_argument("--jit", action="store_true")
Copy link
Collaborator

Choose a reason for hiding this comment

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

shouldn't this be on by default?

Copy link
Member Author

@fritzo fritzo Jun 14, 2020

Choose a reason for hiding this comment

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

Good question. How about we enable it on by default in the example files, but off by default in the CompartmentalModel class?

I just worry that jit_compile=True disables validation, and that if we optimize for new users we should enable validation by default. The example scripts use predefined models and don't really need validation, whereas CompartmentalModel will be the base class for new models.

Copy link
Collaborator

Choose a reason for hiding this comment

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

yeah that sounds like a reasonable middle ground

Copy link
Member Author

Choose a reason for hiding this comment

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

done.

@martinjankowiak martinjankowiak merged commit ab4c663 into dev Jun 14, 2020
@fritzo fritzo deleted the sir-jit branch July 14, 2020 01:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants