From 5b3f3b99d6aa1d71eaa3380af87a6ca6126505fd Mon Sep 17 00:00:00 2001 From: Marc Sun <57196510+SunMarc@users.noreply.github.com> Date: Tue, 31 Oct 2023 20:10:06 +0100 Subject: [PATCH] fix warning (#2105) --- src/accelerate/big_modeling.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/accelerate/big_modeling.py b/src/accelerate/big_modeling.py index c0bbe07b0d9..fc0dbb32f63 100644 --- a/src/accelerate/big_modeling.py +++ b/src/accelerate/big_modeling.py @@ -404,10 +404,10 @@ def dispatch_model( ) # warn if there is any params on the meta device - if len(offload) > 0: - offloaded_devices_str = " and ".join( - [device for device in set(device_map.values()) if device in ("cpu", "disk")] - ) + offloaded_devices_str = " and ".join( + [device for device in set(device_map.values()) if device in ("cpu", "disk")] + ) + if len(offloaded_devices_str) > 0: logging.warning( f"Some parameters are on the meta device device because they were offloaded to the {offloaded_devices_str}." ) @@ -415,10 +415,6 @@ def dispatch_model( # Attaching the hook may break tied weights, so we retie them retie_parameters(model, tied_params) - # warn if there is any params on the meta device - if len(offload) > 0: - logging.warn("Some parameters are on the meta device device because they were offloaded to the cpu/disk.") - # add warning to cuda and to method def add_warning(fn, model): @wraps(fn)