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)