-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #87 from tenstorrent/nvukobrat/llama_placeholder
Placeholder for Llama 3B + minor fix
- Loading branch information
Showing
3 changed files
with
45 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ tt_debug | |
build | ||
net2pipe_output/ | ||
third_party/llvm | ||
venv/ | ||
|
||
/llk_out/ | ||
|
||
|
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# SPDX-FileCopyrightText: © 2024 Tenstorrent AI ULC | ||
|
||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
from transformers import LlamaConfig, LlamaForCausalLM, LlamaTokenizer | ||
|
||
import pybuda | ||
|
||
|
||
def test_llama_inference(): | ||
# Compiler configurations | ||
compiler_cfg = pybuda.config._get_global_compiler_config() | ||
compiler_cfg.enable_tvm_cpu_fallback = False | ||
|
||
# Load Llama 3B model and tokenizer | ||
model_path = "openlm-research/open_llama_3b" | ||
config = LlamaConfig() | ||
config.hidden_size = 3200 | ||
config.intermediate_size = 8640 | ||
config.num_hidden_layers = 26 | ||
config.pad_token_id = 0 | ||
config.return_dict = False | ||
framework_model = LlamaForCausalLM.from_pretrained( | ||
model_path, device_map="auto", config=config | ||
) | ||
framework_model.eval() | ||
tokenizer = LlamaTokenizer.from_pretrained(model_path) | ||
|
||
prompt = "Q: What is the largest animal?\nA:" | ||
input_ids = tokenizer(prompt, return_tensors="pt").input_ids | ||
|
||
# Sanity run | ||
generation_output = framework_model.generate(input_ids=input_ids, max_new_tokens=32) | ||
print(tokenizer.decode(generation_output[0])) | ||
|
||
# Compile the model | ||
compiled_model = pybuda.compile(framework_model, input_ids) |