-
Notifications
You must be signed in to change notification settings - Fork 843
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Llama2 on inf2 example tests, bug fixes and documentation (#2607)
* skip specifying neuron library versions in requirements.txt * add test for text iterator batch streamer * add test for micro batch index API * Add details about supported Neuron SDK version * Add accelerator memory details for inf2 * fix linter error --------- Co-authored-by: Naman Nandan <[email protected]>
- Loading branch information
1 parent
ab69b69
commit c3ca259
Showing
5 changed files
with
73 additions
and
14 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,3 @@ | ||
--extra-index-url https://pip.repos.neuron.amazonaws.com | ||
torch-neuronx==1.13.1.1.9.0 | ||
transformers-neuronx==0.5.58 | ||
transformers==4.31.0 | ||
tokenizers==0.13.3 | ||
sentencepiece==0.1.99 |
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import torch | ||
from transformers import AutoTokenizer | ||
|
||
from ts.handler_utils.hf_batch_streamer import TextIteratorStreamerBatch | ||
|
||
|
||
def test_hf_batch_streamer(): | ||
tokenizer = AutoTokenizer.from_pretrained("bert-base-cased") | ||
streamer = TextIteratorStreamerBatch( | ||
tokenizer=tokenizer, batch_size=2, skip_special_tokens=True | ||
) | ||
|
||
input1 = "hello world" | ||
input2 = "good day" | ||
|
||
for inputs in zip(tokenizer(input1)["input_ids"], tokenizer(input2)["input_ids"]): | ||
streamer.put(torch.tensor(inputs)) | ||
|
||
streamer.end() | ||
|
||
output1 = "" | ||
output2 = "" | ||
|
||
for data in streamer: | ||
assert len(data) == 2 | ||
output1 += data[0] | ||
output2 += data[1] | ||
|
||
assert output1 == input1 | ||
assert output2 == input2 |
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 |
---|---|---|
|
@@ -1095,3 +1095,4 @@ PreprocessCallCount | |
AOT | ||
microbatches | ||
tokenization | ||
tp |