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

Use HF safetensors by default #1046

Closed
wants to merge 8 commits into from
Closed

Conversation

leondz
Copy link
Collaborator

@leondz leondz commented Dec 16, 2024

Support use_safetensors in hugging face models & enable by default

Verification

Little tricky since HF doesn't always go for pickles even if they're present and use_safetensors is disabled:

>>> g_s = pipeline("text-generation", model="gpt2", use_safetensors=False)
config.json: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 665/665 [00:00<00:00, 3.54MB/s]
model.safetensors:  67%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████▊                                                      | 367M/548M [00:31<00:16, 11.2MB/s]

@leondz leondz requested a review from jmartin-tech December 16, 2024 13:26
@leondz leondz marked this pull request as draft December 16, 2024 13:57
Copy link
Collaborator

@jmartin-tech jmartin-tech left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be expanded to set hf_args values? In the huggingface generator classes and in HFDetector?

Based on the current testing results and the finding noted about Callable signatures currently used I suspect this will need more refining to determine a valid approach since it seems unclear what models will have safe tensors.

Comment on lines +88 to +90
if "use_safetensors" not in params:
args["use_safetensors"] = True

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A default not supplied by DEFAULT_PARAMS['hf_args'] should only be injected if the hf_constucutor is expected to support or pass thru the option:

The following methods are currently passed as hf_constructor:

transformers.pipeline
transformers.AutoConfig.from_pretrained
transformers.AutoModelForSeq2SeqLM.from_pretrained
transformers.LlavaNextForConditionalGeneration.from_pretrained

Unfortunately all the above methods mask use_safetensors as part of an optional **kwarg param.

This gathering pattern may not work for this option.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that's exactly where I ended up with this also. Inspection doesn't immediately reveal the parameter, and support it not universal. There are some lists of what supports this but I prefer something that responds to the code at hand. More research needed.

Comment on lines +446 to +447
print(dir(_config.system))

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Errant debugging statement?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extremely

@leondz
Copy link
Collaborator Author

leondz commented Jan 6, 2025

see #990 (comment) - pausing for now

@leondz leondz closed this Jan 6, 2025
@github-actions github-actions bot locked and limited conversation to collaborators Jan 6, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feature: Enable use_safetensors/True for HF models and expose as config var
2 participants