-
Notifications
You must be signed in to change notification settings - Fork 24
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
Small optimizations #5
Merged
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
9056959
feat(test): add tqdm to get feedback when running locally
tengomucho 1ec9adb
fix(test): remove generation config warnings
tengomucho c3549ab
feat: compilation can be enabled only for decoding
tengomucho 3a4d10b
feat: logits post-processing happens on CPU
tengomucho 401eea6
fix: comparison to False should be `cond is False`
tengomucho File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import pytest | ||
import os | ||
from tqdm import tqdm | ||
from text_generation_server.generator import TpuGenerator | ||
from text_generation_server.model import fetch_model | ||
from text_generation_server.pb.generate_pb2 import ( | ||
|
@@ -44,13 +45,19 @@ def create_request( | |
seed: int = 0, | ||
repetition_penalty: float = 1.0, | ||
): | ||
# For these tests we can safely set typical_p to 1.0 (default) | ||
typical_p = 1.0 | ||
if do_sample == False: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
# Drop top_p parameter to avoid warnings | ||
top_p = 1.0 | ||
parameters = NextTokenChooserParameters( | ||
temperature=temperature, | ||
top_k=top_k, | ||
top_p=top_p, | ||
do_sample=do_sample, | ||
seed=seed, | ||
repetition_penalty=repetition_penalty, | ||
typical_p=typical_p, | ||
) | ||
stopping_parameters = StoppingCriteriaParameters(max_new_tokens=max_new_tokens) | ||
return Request(id=id, inputs=inputs, parameters=parameters, stopping_parameters=stopping_parameters) | ||
|
@@ -121,7 +128,7 @@ def test_decode_single(input_text, max_new_tokens, generated_text, do_sample, mo | |
batch = Batch(id=0, requests=[request], size=1, max_tokens=SEQUENCE_LENGTH) | ||
generations, next_batch = generator.prefill(batch) | ||
# We already generated one token: call decode max_new_tokens - 1 times | ||
for i in range(max_new_tokens - 1): | ||
for _ in tqdm(range(max_new_tokens - 1), "Decoding tokens"): | ||
assert next_batch.size == 1 | ||
assert next_batch.max_tokens == 1024 | ||
assert len(generations) == 1 | ||
|
@@ -152,7 +159,7 @@ def test_decode_multiple(model_path): | |
assert len(tokens[0]) == 1 | ||
# Decode a few tokens | ||
gen_tokens = 4 | ||
for _ in range(gen_tokens - 1): | ||
for _ in tqdm(range(gen_tokens - 1), "Decoding tokens"): | ||
generations, next_batch = generator.decode([next_batch]) | ||
assert len(generations) == 1 | ||
g = generations[0] | ||
|
@@ -172,7 +179,7 @@ def test_decode_multiple(model_path): | |
assert len(tokens[1]) == 1 | ||
# Decode more tokens until we reach the maximum for the first request | ||
batches = [next_batch, next_batch_1] | ||
for _ in range(max_new_tokens - gen_tokens): | ||
for _ in tqdm(range(max_new_tokens - gen_tokens), "Decoding tokens (2nd batch)"): | ||
generations, next_batch = generator.decode(batches) | ||
for g in generations: | ||
tokens[g.request_id].append(g.tokens.ids[0]) | ||
|
@@ -189,7 +196,7 @@ def test_decode_multiple(model_path): | |
assert output.generated_tokens == max_new_tokens | ||
generated_text = output.text | ||
# Continue decoding until the end of the second request | ||
for _ in range(gen_tokens - 1): | ||
for _ in tqdm(range(gen_tokens - 1), "Decoding tokens (finishing)"): | ||
generations, next_batch = generator.decode([next_batch]) | ||
assert len(generations) == 1 | ||
g = generations[0] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import pytest | ||
import os | ||
from tqdm import tqdm | ||
from text_generation_server.generator import TpuGenerator | ||
from text_generation_server.model import fetch_model | ||
from text_generation_server.pb.generate_pb2 import ( | ||
|
@@ -35,13 +36,19 @@ def create_request( | |
seed: int = 0, | ||
repetition_penalty: float = 1.0, | ||
): | ||
# For these tests we can safely set typical_p to 1.0 (default) | ||
typical_p = 1.0 | ||
if do_sample == False: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
# Drop top_p parameter to avoid warnings | ||
top_p = 1.0 | ||
parameters = NextTokenChooserParameters( | ||
temperature=temperature, | ||
top_k=top_k, | ||
top_p=top_p, | ||
do_sample=do_sample, | ||
seed=seed, | ||
repetition_penalty=repetition_penalty, | ||
typical_p=typical_p, | ||
) | ||
stopping_parameters = StoppingCriteriaParameters(max_new_tokens=max_new_tokens) | ||
return Request(id=id, inputs=inputs, parameters=parameters, stopping_parameters=stopping_parameters) | ||
|
@@ -57,7 +64,7 @@ def test_decode_single(model_path): | |
batch = Batch(id=0, requests=[request], size=1, max_tokens=SEQUENCE_LENGTH) | ||
generations, next_batch = generator.prefill(batch) | ||
# We already generated one token: call decode max_new_tokens - 1 times | ||
for _ in range(max_new_tokens - 1): | ||
for _ in tqdm(range(max_new_tokens - 1)): | ||
assert next_batch.size == 1 | ||
assert next_batch.max_tokens == 1024 | ||
assert len(generations) == 1 | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For my knowledge: We were not waiting before, why this has changed here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the default is
wait=False
, and I did not want to give the false impression I am changing the default behaviour, so I just removed the default parameter.