Skip to content

fix qnn export #9808

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

Merged
merged 1 commit into from
Apr 2, 2025
Merged
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
9 changes: 4 additions & 5 deletions examples/qualcomm/oss_scripts/llama/llama.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
from executorch.examples.models.llama.source_transformation.quantize import (
get_quant_embedding_transform,
)
from executorch.examples.models.llama.tokenizer.tiktoken import Tokenizer as Tiktoken
from executorch.examples.qualcomm.oss_scripts.llama.model.static_llama import (
LlamaModel,
ModelArgs,
Expand All @@ -75,7 +74,7 @@
from executorch.exir.passes.memory_planning_pass import MemoryPlanningPass
from executorch.extension.llm.custom_ops import model_sharding
from executorch.extension.llm.export.builder import DType
from pytorch_tokenizers import get_tokenizer
from pytorch_tokenizers import get_tokenizer, TiktokenTokenizer
from pytorch_tokenizers.llama2c import Llama2cTokenizer as SentencePieceTokenizer

from torch.ao.quantization.observer import MinMaxObserver
Expand Down Expand Up @@ -141,7 +140,7 @@ def _kv_calibrate(
# Llama2 tokenizer has no special tokens
if isinstance(tokenizer, SentencePieceTokenizer):
token_list = tokenizer.encode(user_prompts, bos=True, eos=False)
elif isinstance(tokenizer, Tiktoken):
elif isinstance(tokenizer, TiktokenTokenizer):
token_list = tokenizer.encode(
user_prompts, bos=True, eos=False, allowed_special="all"
)
Expand Down Expand Up @@ -213,7 +212,7 @@ def _prefill_calibrate(
# Llama2 tokenizer has no special tokens
if isinstance(tokenizer, SentencePieceTokenizer):
token_list = tokenizer.encode(user_prompts, bos=True, eos=False)
elif isinstance(tokenizer, Tiktoken):
elif isinstance(tokenizer, TiktokenTokenizer):
token_list = tokenizer.encode(
user_prompts, bos=True, eos=False, allowed_special="all"
)
Expand Down Expand Up @@ -1111,7 +1110,7 @@ def export_llama(args) -> None:
runtime_tokenizer_path = args.tokenizer_bin
elif args.llama_model == "llama3_2":
assert isinstance(
tokenizer, Tiktoken
tokenizer, TiktokenTokenizer
), f"Wrong tokenizer provided for llama3_2."
runtime_tokenizer_path = args.tokenizer_model
else:
Expand Down
Loading