Skip to content

Commit

Permalink
Fix cpu_offload_with_hook code snippet (#1047)
Browse files Browse the repository at this point in the history
* Fix cpu_offload_with_hook code snippet

* Make model explicit for clarity.
  • Loading branch information
pcuenca authored Feb 8, 2023
1 parent 978dfc3 commit 60460ae
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/accelerate/big_modeling.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,9 @@ def cpu_offload_with_hook(
Example:
```py
hook_1 = cpu_offload_with_hook(model_1, cuda_device)
hook_2 = cpu_offload_with_hook(model_2, cuda_device, prev_module_hook=hook_1)
hook_3 = cpu_offload_with_hook(model_3, cuda_device, prev_module_hook=hook_2)
model_1, hook_1 = cpu_offload_with_hook(model_1, cuda_device)
model_2, hook_2 = cpu_offload_with_hook(model_2, cuda_device, prev_module_hook=hook_1)
model_3, hook_3 = cpu_offload_with_hook(model_3, cuda_device, prev_module_hook=hook_2)
hid_1 = model_1(input)
for i in range(50):
Expand Down

0 comments on commit 60460ae

Please sign in to comment.