File: big_modeling.md

package info (click to toggle)
accelerate 1.12.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,900 kB
  • sloc: python: 40,061; sh: 90; makefile: 79
file content (110 lines) | stat: -rw-r--r-- 2,332 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<!--Copyright 2021 The HuggingFace Team. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.

⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
rendered properly in your Markdown viewer.
-->

# Working with large models

## Dispatch and offload

### init_empty_weights

[[autodoc]] big_modeling.init_empty_weights

### cpu_offload

[[autodoc]] big_modeling.cpu_offload

### cpu_offload_with_hook

[[autodoc]] big_modeling.cpu_offload_with_hook

### disk_offload

[[autodoc]] big_modeling.disk_offload

### dispatch_model

[[autodoc]] big_modeling.dispatch_model

### load_checkpoint_and_dispatch

[[autodoc]] big_modeling.load_checkpoint_and_dispatch

### load_checkpoint_in_model

[[autodoc]] big_modeling.load_checkpoint_in_model

### infer_auto_device_map

[[autodoc]] utils.infer_auto_device_map

## Hooks

### ModelHook

[[autodoc]] hooks.ModelHook

### AlignDevicesHook

[[autodoc]] hooks.AlignDevicesHook

### SequentialHook

[[autodoc]] hooks.SequentialHook

### LayerwiseCastingHook

[[autodoc]] hooks.LayerwiseCastingHook

## Adding Hooks

### add_hook_to_module

[[autodoc]] hooks.add_hook_to_module

### attach_execution_device_hook

[[autodoc]] hooks.attach_execution_device_hook

### attach_align_device_hook

[[autodoc]] hooks.attach_align_device_hook

### attach_align_device_hook_on_blocks

[[autodoc]] hooks.attach_align_device_hook_on_blocks

### attach_layerwise_casting_hooks

[[autodoc]] big_modeling.attach_layerwise_casting_hooks

## Removing Hooks

### remove_hook_from_module

[[autodoc]] hooks.remove_hook_from_module

### remove_hook_from_submodules

[[autodoc]] hooks.remove_hook_from_submodules

## Utilities

### has_offloaded_params

[[autodoc]] utils.has_offloaded_params

### align_module_device

[[autodoc]] utils.align_module_device