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

🔊 Add model and tokenizer time logging #309

Merged
merged 1 commit into from
Jan 27, 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
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ repos:
hooks:
- id: black
exclude: imports
additional_dependencies: ["platformdirs"]
- repo: https://github.com/PyCQA/isort
rev: 5.11.5
hooks:
Expand Down
32 changes: 17 additions & 15 deletions caikit_nlp/resources/pretrained_model/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,25 +201,27 @@ def bootstrap(
else "right"
)

# Load the tokenizer and set up the pad token if needed
tokenizer = AutoTokenizer.from_pretrained(
tokenizer_name,
local_files_only=not get_config().allow_downloads,
padding_side=padding_side,
# We can't disable use_fast otherwise unit test fails
# use_fast=False,
)
with alog.ContextTimer(log.info, "Tokenizer loaded in "):
# Load the tokenizer and set up the pad token if needed
tokenizer = AutoTokenizer.from_pretrained(
tokenizer_name,
local_files_only=not get_config().allow_downloads,
padding_side=padding_side,
# We can't disable use_fast otherwise unit test fails
# use_fast=False,
)

if tokenizer.pad_token_id is None:
tokenizer.pad_token_id = tokenizer.eos_token_id

# Load the model
model = cls.MODEL_TYPE.from_pretrained(
model_name,
local_files_only=not get_config().allow_downloads,
torch_dtype=torch_dtype,
**kwargs,
)
with alog.ContextTimer(log.info, f"Model {model_name} loaded in "):
# Load the model
model = cls.MODEL_TYPE.from_pretrained(
model_name,
local_files_only=not get_config().allow_downloads,
torch_dtype=torch_dtype,
**kwargs,
)
log.debug4("Model Details: %s", model)

# Create the class instance
Expand Down
Loading