Skip to content

Commit

Permalink
Add logs offloading (#2075)
Browse files Browse the repository at this point in the history
* add logs

* fix comm

* rework comment
  • Loading branch information
SunMarc committed Oct 24, 2023
1 parent d853592 commit c3ec7ff
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/accelerate/big_modeling.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,9 +402,23 @@ def dispatch_model(
skip_keys=skip_keys,
preload_module_classes=preload_module_classes,
)

# 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")]
)
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 c3ec7ff

Please sign in to comment.