Skip to content

Commit 7212f35

Browse files
authored
[single file] enable telemetry for single file loading when using GGUF. (#11284)
* enable telemetry for single file loading when using GGUF. * quality
1 parent 3252d7a commit 7212f35

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/diffusers/loaders/single_file_model.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from huggingface_hub.utils import validate_hf_hub_args
2222
from typing_extensions import Self
2323

24+
from .. import __version__
2425
from ..quantizers import DiffusersAutoQuantizer
2526
from ..utils import deprecate, is_accelerate_available, logging
2627
from .single_file_utils import (
@@ -260,6 +261,11 @@ def from_single_file(cls, pretrained_model_link_or_path_or_dict: Optional[str] =
260261
device = kwargs.pop("device", None)
261262
disable_mmap = kwargs.pop("disable_mmap", False)
262263

264+
user_agent = {"diffusers": __version__, "file_type": "single_file", "framework": "pytorch"}
265+
# In order to ensure popular quantization methods are supported. Can be disable with `disable_telemetry`
266+
if quantization_config is not None:
267+
user_agent["quant"] = quantization_config.quant_method.value
268+
263269
if torch_dtype is not None and not isinstance(torch_dtype, torch.dtype):
264270
torch_dtype = torch.float32
265271
logger.warning(
@@ -278,6 +284,7 @@ def from_single_file(cls, pretrained_model_link_or_path_or_dict: Optional[str] =
278284
local_files_only=local_files_only,
279285
revision=revision,
280286
disable_mmap=disable_mmap,
287+
user_agent=user_agent,
281288
)
282289
if quantization_config is not None:
283290
hf_quantizer = DiffusersAutoQuantizer.from_config(quantization_config)

src/diffusers/loaders/single_file_utils.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,13 +405,16 @@ def load_single_file_checkpoint(
405405
local_files_only=None,
406406
revision=None,
407407
disable_mmap=False,
408+
user_agent=None,
408409
):
410+
if user_agent is None:
411+
user_agent = {"file_type": "single_file", "framework": "pytorch"}
412+
409413
if os.path.isfile(pretrained_model_link_or_path):
410414
pretrained_model_link_or_path = pretrained_model_link_or_path
411415

412416
else:
413417
repo_id, weights_name = _extract_repo_id_and_weights_name(pretrained_model_link_or_path)
414-
user_agent = {"file_type": "single_file", "framework": "pytorch"}
415418
pretrained_model_link_or_path = _get_model_file(
416419
repo_id,
417420
weights_name=weights_name,

0 commit comments

Comments
 (0)