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

[Inference] Fix inference latency issue when weights/neff are separated #584

Merged
merged 36 commits into from
May 28, 2024

Conversation

JingyaHuang
Copy link
Collaborator

@JingyaHuang JingyaHuang commented Apr 30, 2024

What does this PR do?

As reported in #576, the inference latency is heavily impacted when the weights and neff are not inlined. This is because the weights are not automatically loaded to neuron devices, and if we don't do that we suffer from huge host-device communication overhead.

This PR is supposed to patch this.

Caveat: Current data parallel API doesn't consider the case when weights and neff are not inlined. Here we use the class WeightSeparatedDataParallel as a temporary workaround. This will be included in Neuron SDK 2.20, and by then time this class will be removed from Optimum Neuron. And the current non-inlined models still show 1.5X latency compared to inlined models according to several small quick experiments.

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you make sure to update the documentation with your changes?
  • Did you write any new necessary tests?

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@JingyaHuang JingyaHuang marked this pull request as ready for review May 7, 2024 15:10
@JingyaHuang JingyaHuang reopened this May 20, 2024
optimum/exporters/neuron/convert.py Show resolved Hide resolved
optimum/neuron/modeling_decoder.py Outdated Show resolved Hide resolved
@JingyaHuang JingyaHuang requested a review from dacorvo May 27, 2024 16:29
Copy link
Collaborator

@dacorvo dacorvo left a comment

Choose a reason for hiding this comment

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

LGTM, thanks !

@JingyaHuang JingyaHuang merged commit 7d840f3 into main May 28, 2024
13 checks passed
@JingyaHuang JingyaHuang deleted the fix-non-inlined-perf branch May 28, 2024 07:45
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.

4 participants