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

optimize lookahead init time #11769

Merged
merged 1 commit into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions python/llm/example/GPU/HuggingFace/LLM/qwen2/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import argparse

from transformers import AutoTokenizer
from ipex_llm import optimize_model
import numpy as np


Expand All @@ -36,7 +35,7 @@
args = parser.parse_args()
model_path = args.repo_id_or_model_path


from ipex_llm.transformers import AutoModelForCausalLM
# Load model in 4 bit,
# which convert the relevant layers in the model into INT4 format
Expand All @@ -45,7 +44,7 @@
optimize_model=True,
trust_remote_code=True,
use_cache=True)
model = model.to("xpu")
model = model.half().to("xpu")

# Load tokenizer
tokenizer = AutoTokenizer.from_pretrained(model_path,
Expand Down
2 changes: 1 addition & 1 deletion python/llm/src/ipex_llm/transformers/lookup.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def init_look_up_table(self,
input_ids: torch.LongTensor):
for ngram_size in range(self.max_matching_ngram_size, 0, -1):
# Create sliding windows of size ngram_size
windows = input_ids.unfold(dimension=1, size=ngram_size, step=1)
windows = input_ids.cpu().unfold(dimension=1, size=ngram_size, step=1)
for idx in range(windows.size(1)):
window = tensor2key(windows[0, idx])
if window not in self.lookup_table:
Expand Down
Loading