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

Combine generate() functions #1675

Merged
merged 40 commits into from
Aug 22, 2024
Merged

Combine generate() functions #1675

merged 40 commits into from
Aug 22, 2024

Conversation

apaz-cli
Copy link
Contributor

@apaz-cli apaz-cli commented Aug 14, 2024

Combining the implementations for litgpt.chat.base.generate() and litgpt.chat.base.generate(). Both are used everywhere, and have very different assumptions, so keeping both around, wrapping the original.

WIP, commented out nonsense, tests broken, wanted to get it out there so you could look over it and see if I'm on the right track.

The HF token is a throwaway made specifically for this purpose because I want to see how CI will react, and if it will OOM or not. Will not be in the final version, but I want to make sure it works with llama3 and I can't seem to replicate the test environment.

tests/test_chat.py Outdated Show resolved Hide resolved
tests/test_chat.py Outdated Show resolved Hide resolved
@apaz-cli
Copy link
Contributor Author

I'm calling it a night, but the PR is pretty much done. All that's left is to fix the new test_litgpt_chat_endtoend() and test_litgpt_generate_endtoend() so that they load a model from the checkpoint dir already on the device. And to rewrite test_decode(), to test decode_stream() because I ripped out decode().

The excruciating pain of dealing with stop_tokens in a way that's sane cannot be overstated. I bashed my head into it for hours. But now it works, and all of our models are better supported. We should also see a nice TTFT increase, since we now longer have to hold on to buffer_length tokens before we start yielding them. This is a genuine triumph, I feel.

@Lightning-AI Lightning-AI deleted a comment from gitguardian bot Aug 15, 2024
apaz-cli and others added 10 commits August 15, 2024 05:58
@apaz-cli apaz-cli force-pushed the ap/combine_generage branch from af90a4b to 6bd381a Compare August 15, 2024 06:04
@apaz-cli
Copy link
Contributor Author

I just did an interactive rebase to edit my first commit to take the HF token out of it. Hilariously though, Github retains it anyway. Thanks Github.

thumbs_up

I wonder what people are supposed to do when they leak credentials that are actually important.

@apaz-cli apaz-cli marked this pull request as ready for review August 15, 2024 13:53
Copy link
Collaborator

@rasbt rasbt left a comment

Choose a reason for hiding this comment

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

Looks like a good restructure at first glance. Just some early comments. There'll be more!

tests/test_chat.py Outdated Show resolved Hide resolved
# TODO: Is there a way to not have to do this?
# This may actually affect our tokens per second.

# sentencepiece does not support decoding token-by-token because it adds spaces based on the surrounding tokens
Copy link
Collaborator

Choose a reason for hiding this comment

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

@Andrei-Aksionov reimplemented the tokenizer pipeline and may have ideas here

Copy link
Collaborator

Choose a reason for hiding this comment

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

Interesting. I think I didn't test the hack fix in decode method (with a dummy_token_id) for SentencePiece tokenizer.
So maybe now the logic below is not needed.

@rasbt rasbt marked this pull request as draft August 15, 2024 21:57
@rasbt
Copy link
Collaborator

rasbt commented Aug 21, 2024

@apaz-cli Yes, long story about that. I will describe that to you offline

litgpt/generate/base.py Outdated Show resolved Hide resolved
apaz-cli and others added 2 commits August 21, 2024 13:08
Co-authored-by: Sebastian Raschka <mail@sebastianraschka.com>
tests/test_api.py Outdated Show resolved Hide resolved
litgpt/api.py Outdated Show resolved Hide resolved
litgpt/api.py Outdated Show resolved Hide resolved
litgpt/api.py Outdated Show resolved Hide resolved
litgpt/api.py Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
litgpt/api.py Outdated
)
else:
total_devices = use_devices
num_devices = calculate_number_of_devices(devices)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Any reason why this was changed? Bad rebase maybe?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah. Not sure when it happened.

apaz-cli and others added 10 commits August 22, 2024 12:17
Co-authored-by: Sebastian Raschka <mail@sebastianraschka.com>
Co-authored-by: Sebastian Raschka <mail@sebastianraschka.com>
Co-authored-by: Sebastian Raschka <mail@sebastianraschka.com>
Co-authored-by: Sebastian Raschka <mail@sebastianraschka.com>
Co-authored-by: Sebastian Raschka <mail@sebastianraschka.com>
litgpt/generate/base.py Outdated Show resolved Hide resolved
@rasbt rasbt merged commit 59250d3 into main Aug 22, 2024
8 of 9 checks passed
@rasbt rasbt deleted the ap/combine_generage branch August 22, 2024 19:40
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.

3 participants