Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cpu_offload_with_hook code snippet #1047

Merged
merged 2 commits into from
Feb 8, 2023
Merged

Conversation

pcuenca
Copy link
Member

@pcuenca pcuenca commented Feb 8, 2023

Minor fix in the code example for cpu_offload_with_hook

hook_3 = cpu_offload_with_hook(model_3, cuda_device, prev_module_hook=hook_2)
_, 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)
Copy link
Member Author

@pcuenca pcuenca Feb 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or we can assign model_1 etc in the left-hand side if that's clearer.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's put the model yes!

@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Feb 8, 2023

The documentation is not available anymore as the PR was closed or merged.

Copy link
Collaborator

@sgugger sgugger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix!

hook_3 = cpu_offload_with_hook(model_3, cuda_device, prev_module_hook=hook_2)
_, 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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's put the model yes!

@sgugger sgugger merged commit 60460ae into main Feb 8, 2023
@sgugger sgugger deleted the offload-with-hook-example branch February 8, 2023 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants