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

Rebase with TGI v2.0 #134

Merged
merged 154 commits into from
May 6, 2024
Merged

Conversation

kdamaszk
Copy link
Collaborator

What does this PR do?

Cherry-picks all changes between TGI v1.2.0 and v2.0. Updates the license to Apache 2.0

fxmarty and others added 30 commits April 18, 2024 10:09
@oOraph

---------

Signed-off-by: Raphael Glon <oOraph@users.noreply.github.com>
Co-authored-by: Raphael Glon <oOraph@users.noreply.github.com>
Works by removing adapter_model.safetensors from being detected as the
core model file (which skips the real peft detection).

# What does this PR do?

<!--
Congratulations! You've made it this far! You're not quite done yet
though.

Once merged, your PR is going to appear in the release notes with the
title you set, so make sure it's a great title that fully reflects the
extent of your awesome contribution.

Then, please replace this with a description of the change and which
issue is fixed (if applicable). Please also include relevant motivation
and context. List any dependencies (if any) that are required for this
change.

Once you're done, someone will review your PR shortly (see the section
"Who can review?" below to tag some potential reviewers). They may
suggest changes to make the code even better. If no one reviewed your PR
after a week has passed, don't hesitate to post a new comment
@-mentioning the same persons---sometimes notifications get lost.
-->

<!-- Remove if not applicable -->

Fixes # (issue)


## 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](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md#start-contributing-pull-requests),
      Pull Request section?
- [ ] Was this discussed/approved via a Github issue or the
[forum](https://discuss.huggingface.co/)? 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](https://github.com/huggingface/transformers/tree/main/docs),
and
[here are tips on formatting
docstrings](https://github.com/huggingface/transformers/tree/main/docs#writing-source-documentation).
- [ ] 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.

<!-- Your PR will be replied to more quickly if you can figure out the
right person to tag with @


@OlivierDehaene OR @Narsil

 -->
Co-authored-by: Nicolas Patry <patry.nicolas@protonmail.com>
local directory overloaded still needs the directory to locate the
weights files correctly.

# What does this PR do?

<!--
Congratulations! You've made it this far! You're not quite done yet
though.

Once merged, your PR is going to appear in the release notes with the
title you set, so make sure it's a great title that fully reflects the
extent of your awesome contribution.

Then, please replace this with a description of the change and which
issue is fixed (if applicable). Please also include relevant motivation
and context. List any dependencies (if any) that are required for this
change.

Once you're done, someone will review your PR shortly (see the section
"Who can review?" below to tag some potential reviewers). They may
suggest changes to make the code even better. If no one reviewed your PR
after a week has passed, don't hesitate to post a new comment
@-mentioning the same persons---sometimes notifications get lost.
-->

<!-- Remove if not applicable -->

Fixes # (issue)


## 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](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md#start-contributing-pull-requests),
      Pull Request section?
- [ ] Was this discussed/approved via a Github issue or the
[forum](https://discuss.huggingface.co/)? 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](https://github.com/huggingface/transformers/tree/main/docs),
and
[here are tips on formatting
docstrings](https://github.com/huggingface/transformers/tree/main/docs#writing-source-documentation).
- [ ] 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.

<!-- Your PR will be replied to more quickly if you can figure out the
right person to tag with @


@OlivierDehaene OR @Narsil

 -->
Narsil and others added 12 commits April 25, 2024 17:53
wrap text-generation-launcher in docker image
mask ldconfig failures to user (no need in most cases anyway)

---------

Signed-off-by: Raphael Glon <oOraph@users.noreply.github.com>
Co-authored-by: Raphael Glon <oOraph@users.noreply.github.com>
<!--
Congratulations! You've made it this far! You're not quite done yet
though.

Once merged, your PR is going to appear in the release notes with the
title you set, so make sure it's a great title that fully reflects the
extent of your awesome contribution.

Then, please replace this with a description of the change and which
issue is fixed (if applicable). Please also include relevant motivation
and context. List any dependencies (if any) that are required for this
change.

Once you're done, someone will review your PR shortly (see the section
"Who can review?" below to tag some potential reviewers). They may
suggest changes to make the code even better. If no one reviewed your PR
after a week has passed, don't hesitate to post a new comment
@-mentioning the same persons---sometimes notifications get lost.
-->

<!-- Remove if not applicable -->

Fixes # (issue)

- [ ] 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](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md#start-contributing-pull-requests),
      Pull Request section?
- [ ] Was this discussed/approved via a Github issue or the
[forum](https://discuss.huggingface.co/)? 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](https://github.com/huggingface/transformers/tree/main/docs),
and
[here are tips on formatting
docstrings](https://github.com/huggingface/transformers/tree/main/docs#writing-source-documentation).
- [ ] Did you write any new necessary tests?

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.

<!-- Your PR will be replied to more quickly if you can figure out the
right person to tag with @

@OlivierDehaene OR @Narsil

 -->

---------

Co-authored-by: Dong Shin <d0104.shin@gmail.com>
# What does this PR do?

<!--
Congratulations! You've made it this far! You're not quite done yet
though.

Once merged, your PR is going to appear in the release notes with the
title you set, so make sure it's a great title that fully reflects the
extent of your awesome contribution.

Then, please replace this with a description of the change and which
issue is fixed (if applicable). Please also include relevant motivation
and context. List any dependencies (if any) that are required for this
change.

Once you're done, someone will review your PR shortly (see the section
"Who can review?" below to tag some potential reviewers). They may
suggest changes to make the code even better. If no one reviewed your PR
after a week has passed, don't hesitate to post a new comment
@-mentioning the same persons---sometimes notifications get lost.
-->

<!-- Remove if not applicable -->

Fixes # (issue)


## 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](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md#start-contributing-pull-requests),
      Pull Request section?
- [ ] Was this discussed/approved via a Github issue or the
[forum](https://discuss.huggingface.co/)? 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](https://github.com/huggingface/transformers/tree/main/docs),
and
[here are tips on formatting
docstrings](https://github.com/huggingface/transformers/tree/main/docs#writing-source-documentation).
- [ ] 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.

<!-- Your PR will be replied to more quickly if you can figure out the
right person to tag with @


@OlivierDehaene OR @Narsil

 -->
…e#1651)

# What does this PR do?

I have suggested similar changes over at
huggingface/text-embeddings-inference#201.

Here being my additional question, why `debug` is enabled during release
building? (hence I didn't add the flag to script things)

Applying the following optimizations:
- `lto` (link time optimizations) over all code (including dependencies)
- Using a single `codegen-unit` to apply optimizations within 1 code
unit at build time


## 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](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md#start-contributing-pull-requests),
      Pull Request section?
- [ ] Was this discussed/approved via a Github issue or the
[forum](https://discuss.huggingface.co/)? 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](https://github.com/huggingface/transformers/tree/main/docs),
and
[here are tips on formatting
docstrings](https://github.com/huggingface/transformers/tree/main/docs#writing-source-documentation).
- [ ] 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.

@OlivierDehaene OR @Narsil
- Renamed `max_input_length` into `max_input_tokens` for consistency
(backward compatible change, will yell if both are set.)
- Will now use the config for `max_input_tokens` `max_total_token` and
`max_batch_total_tokens`.
- Capping the values to 16k in order to save VRAM on behalf of users
(overriddable by simply setting the values).

<!--
Congratulations! You've made it this far! You're not quite done yet
though.

Once merged, your PR is going to appear in the release notes with the
title you set, so make sure it's a great title that fully reflects the
extent of your awesome contribution.

Then, please replace this with a description of the change and which
issue is fixed (if applicable). Please also include relevant motivation
and context. List any dependencies (if any) that are required for this
change.

Once you're done, someone will review your PR shortly (see the section
"Who can review?" below to tag some potential reviewers). They may
suggest changes to make the code even better. If no one reviewed your PR
after a week has passed, don't hesitate to post a new comment
@-mentioning the same persons---sometimes notifications get lost.
-->

<!-- Remove if not applicable -->

Fixes # (issue)

- [ ] 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](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md#start-contributing-pull-requests),
      Pull Request section?
- [ ] Was this discussed/approved via a Github issue or the
[forum](https://discuss.huggingface.co/)? 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](https://github.com/huggingface/transformers/tree/main/docs),
and
[here are tips on formatting
docstrings](https://github.com/huggingface/transformers/tree/main/docs#writing-source-documentation).
- [ ] Did you write any new necessary tests?

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.

<!-- Your PR will be replied to more quickly if you can figure out the
right person to tag with @

@OlivierDehaene OR @Narsil

 -->
# What does this PR do?

compliation -> compilation


## Before submitting
- [x] This PR fixes a typo or improves the docs (you can dismiss the
other checks if that's the case).
- [x] Did you read the [contributor
guideline](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md#start-contributing-pull-requests),
      Pull Request section?
- [ ] Was this discussed/approved via a Github issue or the
[forum](https://discuss.huggingface.co/)? 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](https://github.com/huggingface/transformers/tree/main/docs),
and
[here are tips on formatting
docstrings](https://github.com/huggingface/transformers/tree/main/docs#writing-source-documentation).
- [ ] 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.

<!-- Your PR will be replied to more quickly if you can figure out the
right person to tag with @


@OlivierDehaene OR @Narsil

 -->
@kdamaszk
Copy link
Collaborator Author

@regisss please review

@regisss
Copy link
Collaborator

regisss commented Apr 30, 2024

@kdamaszk LGTM!

However, I get an error when I try to run Llama2-7b. I launch the server and send the same request as the example in the README: https://github.com/kdamaszk/tgi-gaudi/tree/rebase_tgi_2.0?tab=readme-ov-file#running-tgi-on-gaudi
And I get the following error:

ERROR generate{parameters=GenerateParameters { best_of: None, temperature: None, repetition_penalty: None, frequency_penalty: None, top_k: None, top_p: None, typical_p: None, do_sample: false, max_new_tokens: Some(32), return_full_text: None, stop: [], truncate: None, watermark: false, details: false, decoder_input_details: false, seed: None, top_n_tokens: None, grammar: None }}:generate:generate_stream: text_generation_router::infer: router/src/infer.rs:145: `inputs` tokens + `max_new_tokens` must be <= 4096. Given: 4095 `inputs` tokens and 32 `max_new_tokens`

It seems that max_new_tokens is not considered when the input is padded to 4096 tokens. Are you able to reproduce it?

@hsubramony hsubramony mentioned this pull request Apr 30, 2024
5 tasks
@yafshar
Copy link

yafshar commented May 1, 2024

The HPU Graph issue reported in #130 still exists. @regisss @kdamaszk if you give me permission, I can add the patch here. Or you can cherry pick the patch 4963b73 to fix the issue.

@yafshar
Copy link

yafshar commented May 1, 2024

@regisss, for this update 1.15.0 & 1.15.1 the requirement is dill 0.3.8, from 4963b73
Currently the merge from tgi_gaudi:habama-main 600d033, installs the older one 0.3.7

@kdamaszk
Copy link
Collaborator Author

kdamaszk commented May 6, 2024

@kdamaszk LGTM!

However, I get an error when I try to run Llama2-7b. I launch the server and send the same request as the example in the README: https://github.com/kdamaszk/tgi-gaudi/tree/rebase_tgi_2.0?tab=readme-ov-file#running-tgi-on-gaudi And I get the following error:

ERROR generate{parameters=GenerateParameters { best_of: None, temperature: None, repetition_penalty: None, frequency_penalty: None, top_k: None, top_p: None, typical_p: None, do_sample: false, max_new_tokens: Some(32), return_full_text: None, stop: [], truncate: None, watermark: false, details: false, decoder_input_details: false, seed: None, top_n_tokens: None, grammar: None }}:generate:generate_stream: text_generation_router::infer: router/src/infer.rs:145: `inputs` tokens + `max_new_tokens` must be <= 4096. Given: 4095 `inputs` tokens and 32 `max_new_tokens`

It seems that max_new_tokens is not considered when the input is padded to 4096 tokens. Are you able to reproduce it?

@regisss you are right. This issue is caused by new default params for max-input-length and max-total-tokens (before 1024 and 2048, now 4095 and 4096). I will modify README example to set these params properly, WDYT?

@kdamaszk
Copy link
Collaborator Author

kdamaszk commented May 6, 2024

The HPU Graph issue reported in #130 still exists. @regisss @kdamaszk if you give me permission, I can add the patch here. Or you can cherry pick the patch 4963b73 to fix the issue.

thanks @yafshar, I will cherry-pick this commit

@regisss
Copy link
Collaborator

regisss commented May 6, 2024

@kdamaszk LGTM!
However, I get an error when I try to run Llama2-7b. I launch the server and send the same request as the example in the README: https://github.com/kdamaszk/tgi-gaudi/tree/rebase_tgi_2.0?tab=readme-ov-file#running-tgi-on-gaudi And I get the following error:

ERROR generate{parameters=GenerateParameters { best_of: None, temperature: None, repetition_penalty: None, frequency_penalty: None, top_k: None, top_p: None, typical_p: None, do_sample: false, max_new_tokens: Some(32), return_full_text: None, stop: [], truncate: None, watermark: false, details: false, decoder_input_details: false, seed: None, top_n_tokens: None, grammar: None }}:generate:generate_stream: text_generation_router::infer: router/src/infer.rs:145: `inputs` tokens + `max_new_tokens` must be <= 4096. Given: 4095 `inputs` tokens and 32 `max_new_tokens`

It seems that max_new_tokens is not considered when the input is padded to 4096 tokens. Are you able to reproduce it?

@regisss you are right. This issue is caused by new default params for max-input-length and max-total-tokens (before 1024 and 2048, now 4095 and 4096). I will modify README example to set these params properly, WDYT?

Sounds good!

yafshar and others added 2 commits May 6, 2024 09:15
A temp solution to address overriding issue installing dill with habana
torch from gaudi-docker/1.15.0
- Having `import __main__ as _main_module` in the global space of the
  dill module causes some overriding issue on hpu graph destructor
@kdamaszk kdamaszk requested a review from regisss May 6, 2024 06:34
Copy link
Collaborator

@regisss regisss left a comment

Choose a reason for hiding this comment

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

LGTM!

Side note, I cannot stop the Docker container with ctrl+c anymore. Not a big deal, maybe it's not even related to TGI Gaudi.

@regisss regisss merged commit 81182be into huggingface:habana-main May 6, 2024
@kdamaszk
Copy link
Collaborator Author

kdamaszk commented May 6, 2024

LGTM!

Side note, I cannot stop the Docker container with ctrl+c anymore. Not a big deal, maybe it's not even related to TGI Gaudi.

Right, I observed the same behavior. This is caused by this PR: huggingface#1716. Due to that, the tgi_entrypoint.sh is run instead of text-generation-launcher.
I'm not sure what is the purpose of this change. We can come back to the previous solution if you want -- it was more user-friendly.

@regisss
Copy link
Collaborator

regisss commented May 6, 2024

Right, I observed the same behavior. This is caused by this PR: huggingface#1716. Due to that, the tgi_entrypoint.sh is run instead of text-generation-launcher. I'm not sure what is the purpose of this change. We can come back to the previous solution if you want -- it was more user-friendly.

Okay I see. Let me discuss that with TGI maintainers to see if we want to directly modify this there.

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.

update the base image from 1.14 to 1.15