Skip to content

[BE] Delay imports #377

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 22, 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 build/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@
from config.model_config import resolve_model_config
from quantize import quantize_model

from sentencepiece import SentencePieceProcessor
from tokenizer.tiktoken import Tokenizer as TiktokenTokenizer

from build.model import Transformer
from build.utils import device_sync, name_to_dtype

Expand Down Expand Up @@ -201,8 +198,10 @@ def from_args(cls, args): # -> TokenizerArgs:

def _initialize_tokenizer(tokenizer_args: TokenizerArgs):
if tokenizer_args.is_sentencepiece:
from sentencepiece import SentencePieceProcessor
return SentencePieceProcessor(model_file=str(tokenizer_args.tokenizer_path))
elif tokenizer_args.is_tiktoken:
from tokenizer.tiktoken import Tokenizer as TiktokenTokenizer
return TiktokenTokenizer(model_path=str(tokenizer_args.tokenizer_path))
else:
raise RuntimeError("must specify a valid tokenizer in TokenizerArgs")
Expand Down
2 changes: 1 addition & 1 deletion download.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
resolve_model_config,
)

from requests.exceptions import HTTPError


def _download_hf_snapshot(
model_config: ModelConfig, artifact_dir: Path, hf_token: Optional[str]
):
from huggingface_hub import snapshot_download
from requests.exceptions import HTTPError

# Download and store the HF model artifacts.
print(f"Downloading {model_config.name} from HuggingFace...")
Expand Down