| 1 |
<!--Copyright 2021 The HuggingFace Team. All rights reserved. |
| 2 |
|
| 3 |
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with |
| 4 |
the License. You may obtain a copy of the License at |
| 5 |
|
| 6 |
http://www.apache.org/licenses/LICENSE-2.0 |
| 7 |
|
| 8 |
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on |
| 9 |
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the |
| 10 |
specific language governing permissions and limitations under the License. |
| 11 |
|
| 12 |
⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be |
| 13 |
rendered properly in your Markdown viewer. |
| 14 |
--> |
| 15 |
|
| 16 |
# Working with large models |
| 17 |
|
| 18 |
## Dispatch and offload |
| 19 |
|
| 20 |
### init_empty_weights |
| 21 |
|
| 22 |
[[autodoc]] big_modeling.init_empty_weights |
| 23 |
|
| 24 |
### cpu_offload |
| 25 |
|
| 26 |
[[autodoc]] big_modeling.cpu_offload |
| 27 |
|
| 28 |
### cpu_offload_with_hook |
| 29 |
|
| 30 |
[[autodoc]] big_modeling.cpu_offload_with_hook |
| 31 |
|
| 32 |
### disk_offload |
| 33 |
|
| 34 |
[[autodoc]] big_modeling.disk_offload |
| 35 |
|
| 36 |
### dispatch_model |
| 37 |
|
| 38 |
[[autodoc]] big_modeling.dispatch_model |
| 39 |
|
| 40 |
### load_checkpoint_and_dispatch |
| 41 |
|
| 42 |
[[autodoc]] big_modeling.load_checkpoint_and_dispatch |
| 43 |
|
| 44 |
### load_checkpoint_in_model |
| 45 |
|
| 46 |
[[autodoc]] big_modeling.load_checkpoint_in_model |
| 47 |
|
| 48 |
### infer_auto_device_map |
| 49 |
|
| 50 |
[[autodoc]] utils.infer_auto_device_map |
| 51 |
|
| 52 |
## Hooks |
| 53 |
|
| 54 |
### ModelHook |
| 55 |
|
| 56 |
[[autodoc]] hooks.ModelHook |
| 57 |
|
| 58 |
### AlignDevicesHook |
| 59 |
|
| 60 |
[[autodoc]] hooks.AlignDevicesHook |
| 61 |
|
| 62 |
### SequentialHook |
| 63 |
|
| 64 |
[[autodoc]] hooks.SequentialHook |
| 65 |
|
| 66 |
### LayerwiseCastingHook |
| 67 |
|
| 68 |
[[autodoc]] hooks.LayerwiseCastingHook |
| 69 |
|
| 70 |
## Adding Hooks |
| 71 |
|
| 72 |
### add_hook_to_module |
| 73 |
|
| 74 |
[[autodoc]] hooks.add_hook_to_module |
| 75 |
|
| 76 |
### attach_execution_device_hook |
| 77 |
|
| 78 |
[[autodoc]] hooks.attach_execution_device_hook |
| 79 |
|
| 80 |
### attach_align_device_hook |
| 81 |
|
| 82 |
[[autodoc]] hooks.attach_align_device_hook |
| 83 |
|
| 84 |
### attach_align_device_hook_on_blocks |
| 85 |
|
| 86 |
[[autodoc]] hooks.attach_align_device_hook_on_blocks |
| 87 |
|
| 88 |
### attach_layerwise_casting_hooks |
| 89 |
|
| 90 |
[[autodoc]] big_modeling.attach_layerwise_casting_hooks |
| 91 |
|
| 92 |
## Removing Hooks |
| 93 |
|
| 94 |
### remove_hook_from_module |
| 95 |
|
| 96 |
[[autodoc]] hooks.remove_hook_from_module |
| 97 |
|
| 98 |
### remove_hook_from_submodules |
| 99 |
|
| 100 |
[[autodoc]] hooks.remove_hook_from_submodules |
| 101 |
|
| 102 |
## Utilities |
| 103 |
|
| 104 |
### has_offloaded_params |
| 105 |
|
| 106 |
[[autodoc]] utils.has_offloaded_params |
| 107 |
|
| 108 |
### align_module_device |
| 109 |
|
| 110 |
[[autodoc]] utils.align_module_device |