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

Create lazy-style import decorator #1961

Closed
wants to merge 7 commits into from
Closed

Create lazy-style import decorator #1961

wants to merge 7 commits into from

Conversation

muellerzr
Copy link
Collaborator

What does this PR do?

This PR creates a lazy-esq style import decorator designed to be used with integrations that can optionally be there and require certain imports globally. This further improves on #1959, with a speed difference shown below (tl;dr 45% speedup):

Before change, with all tracking modules available:

image

After change:

image

How does it work?

This operates by writing a decorator with the exact module to be imported later. In the same function that is decorated, global {mymodule} should be declared and assigned to accelerate.utils.imports.{mymodule}, where it'll be imported from.

The main con here is we lose static checking, however the argument here is immense speedup and flexibility, while reserving this just for integrations.

Fixes # (issue)

Lays foundation to solve #1952

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you read the contributor guideline,
    Pull Request section?
  • Was this discussed/approved via a Github issue or the forum? Please add a link
    to it if that's the case.
  • Did you make sure to update the documentation with your changes? Here are the
    documentation guidelines, and
    here are tips on formatting docstrings.
  • Did you write any new necessary tests?

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

@BenjaminBossan @SunMarc

@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Sep 12, 2023

The documentation is not available anymore as the PR was closed or merged.

@muellerzr muellerzr closed this Sep 12, 2023
@muellerzr muellerzr mentioned this pull request Sep 12, 2023
5 tasks
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.

2 participants