Skip to content

Commit

Permalink
Fix edge case in infer_auto_device_map when dealing with buffers (#2511)
Browse files Browse the repository at this point in the history
* fix buffer

* style
  • Loading branch information
SunMarc authored Mar 1, 2024
1 parent ca37b0e commit 5fce525
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/accelerate/utils/modeling.py
Original file line number Diff line number Diff line change
Expand Up @@ -1153,7 +1153,11 @@ def infer_auto_device_map(
# Case 1 -> We're too big!
if current_max_size is not None and current_memory_used + module_size > current_max_size:
# Split or not split?
modules_children = [] if isinstance(module, nn.Parameter) else list(module.named_children())
modules_children = (
[]
if isinstance(module, nn.Parameter) or isinstance(module, torch.Tensor)
else list(module.named_children())
)
if verbose:
print(
f"Not enough space on {devices[current_device]} to put {name} (space available "
Expand Down

0 comments on commit 5fce525

Please sign in to comment.