Skip to content

Commit

Permalink
fix warning (#2105)
Browse files Browse the repository at this point in the history
  • Loading branch information
SunMarc authored Oct 31, 2023
1 parent 2935057 commit 5b3f3b9
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/accelerate/big_modeling.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,21 +404,17 @@ 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}."
)

# 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)
Expand Down

0 comments on commit 5b3f3b9

Please sign in to comment.