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

Warn then the model.dtype is different from it's config.dtype #2312

Merged
merged 1 commit into from
May 30, 2024
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
8 changes: 8 additions & 0 deletions src/sparseml/transformers/sparsification/sparse_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,14 @@ def skip(*args, **kwargs):
model = super(AutoModelForCausalLM, cls).from_pretrained(
pretrained_model_name_or_path, *model_args, **kwargs
)
if model.dtype != model.config.torch_dtype:
_LOGGER.warning(
f"The dtype of the loaded model: {model.dtype} is different "
"from from the dtype specified in the model config: "
f"{model.config.torch_dtype}."
"To load the model in the format that it was previously saved in, "
"set torch_dtype=`auto` in the SparseAutoModel creation call."
)
logger.setLevel(level=restore_log_level)
# override the PreTrainedModel instance with compression save function
modify_save_pretrained(model)
Expand Down
Loading