Buckets:
| import{s as Ga,o as Da,n as Ke}from"../chunks/scheduler.defa9a21.js";import{S as Wa,i as Ha,g as c,s as a,r as i,A as Fa,h as r,f as t,c as n,j as $,u as h,x as b,k as w,y as s,a as l,v as m,d as p,t as f,w as _}from"../chunks/index.fe795e71.js";import{T as xt}from"../chunks/Tip.179eb360.js";import{D as T}from"../chunks/Docstring.170994c1.js";import{C as sa}from"../chunks/CodeBlock.42404125.js";import{E as da}from"../chunks/ExampleCodeBlock.53569e06.js";import{H as x,E as Ba}from"../chunks/EditOnGithub.0f575778.js";function La(C){let d,k="Example:",g,v,y;return v=new sa({props:{code:"aW1wb3J0JTIwdG9yY2gubm4lMjBhcyUyMG5uJTBBZnJvbSUyMGFjY2VsZXJhdGUlMjBpbXBvcnQlMjBpbml0X2VtcHR5X3dlaWdodHMlMEElMEElMjMlMjBJbml0aWFsaXplJTIwYSUyMG1vZGVsJTIwd2l0aCUyMDEwMCUyMGJpbGxpb25zJTIwcGFyYW1ldGVycyUyMGluJTIwbm8lMjB0aW1lJTIwYW5kJTIwd2l0aG91dCUyMHVzaW5nJTIwYW55JTIwUkFNLiUwQXdpdGglMjBpbml0X2VtcHR5X3dlaWdodHMoKSUzQSUwQSUyMCUyMCUyMCUyMHRzdCUyMCUzRCUyMG5uLlNlcXVlbnRpYWwoKiU1Qm5uLkxpbmVhcigxMDAwMCUyQyUyMDEwMDAwKSUyMGZvciUyMF8lMjBpbiUyMHJhbmdlKDEwMDApJTVEKQ==",highlighted:`<span class="hljs-keyword">import</span> torch.nn <span class="hljs-keyword">as</span> nn | |
| <span class="hljs-keyword">from</span> accelerate <span class="hljs-keyword">import</span> init_empty_weights | |
| <span class="hljs-comment"># Initialize a model with 100 billions parameters in no time and without using any RAM.</span> | |
| <span class="hljs-keyword">with</span> init_empty_weights(): | |
| tst = nn.Sequential(*[nn.Linear(<span class="hljs-number">10000</span>, <span class="hljs-number">10000</span>) <span class="hljs-keyword">for</span> _ <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(<span class="hljs-number">1000</span>)])`,wrap:!1}}),{c(){d=c("p"),d.textContent=k,g=a(),i(v.$$.fragment)},l(u){d=r(u,"P",{"data-svelte-h":!0}),b(d)!=="svelte-11lpom8"&&(d.textContent=k),g=n(u),h(v.$$.fragment,u)},m(u,U){l(u,d,U),l(u,g,U),m(v,u,U),y=!0},p:Ke,i(u){y||(p(v.$$.fragment,u),y=!0)},o(u){f(v.$$.fragment,u),y=!1},d(u){u&&(t(d),t(g)),_(v,u)}}}function Aa(C){let d,k=`Any model created under this context manager has no weights. As such you can’t do something like | |
| <code>model.to(some_device)</code> with it. To load weights inside your empty model, see <a href="/docs/accelerate/main/en/package_reference/big_modeling#accelerate.load_checkpoint_and_dispatch">load_checkpoint_and_dispatch()</a>. | |
| Make sure to overwrite the default device_map param for <a href="/docs/accelerate/main/en/package_reference/big_modeling#accelerate.load_checkpoint_and_dispatch">load_checkpoint_and_dispatch()</a>, otherwise dispatch is not | |
| called.`;return{c(){d=c("p"),d.innerHTML=k},l(g){d=r(g,"P",{"data-svelte-h":!0}),b(d)!=="svelte-18rw2wy"&&(d.innerHTML=k)},m(g,v){l(g,d,v)},p:Ke,d(g){g&&t(d)}}}function Za(C){let d,k="Example:",g,v,y;return v=new sa({props:{code:"bW9kZWxfMSUyQyUyMGhvb2tfMSUyMCUzRCUyMGNwdV9vZmZsb2FkX3dpdGhfaG9vayhtb2RlbF8xJTJDJTIwY3VkYV9kZXZpY2UpJTBBbW9kZWxfMiUyQyUyMGhvb2tfMiUyMCUzRCUyMGNwdV9vZmZsb2FkX3dpdGhfaG9vayhtb2RlbF8yJTJDJTIwY3VkYV9kZXZpY2UlMkMlMjBwcmV2X21vZHVsZV9ob29rJTNEaG9va18xKSUwQW1vZGVsXzMlMkMlMjBob29rXzMlMjAlM0QlMjBjcHVfb2ZmbG9hZF93aXRoX2hvb2sobW9kZWxfMyUyQyUyMGN1ZGFfZGV2aWNlJTJDJTIwcHJldl9tb2R1bGVfaG9vayUzRGhvb2tfMiklMEElMEFoaWRfMSUyMCUzRCUyMG1vZGVsXzEoaW5wdXQpJTBBZm9yJTIwaSUyMGluJTIwcmFuZ2UoNTApJTNBJTBBJTIwJTIwJTIwJTIwJTIzJTIwbW9kZWwxJTIwaXMlMjBvZmZsb2FkZWQlMjBvbiUyMHRoZSUyMENQVSUyMGF0JTIwdGhlJTIwZmlyc3QlMjBpdGVyYXRpb24lMkMlMjBtb2RlbCUyMDIlMjBzdGF5cyUyMG9uJTIwdGhlJTIwR1BVJTIwZm9yJTIwdGhpcyUyMHdob2xlJTIwbG9vcC4lMEElMjAlMjAlMjAlMjBoaWRfMiUyMCUzRCUyMG1vZGVsXzIoaGlkXzEpJTBBJTIzJTIwbW9kZWwyJTIwaXMlMjBvZmZsb2FkZWQlMjB0byUyMHRoZSUyMENQVSUyMGp1c3QlMjBiZWZvcmUlMjB0aGlzJTIwZm9yd2FyZC4lMEFoaWRfMyUyMCUzRCUyMG1vZGVsXzMoaGlkXzMpJTBBJTBBJTIzJTIwRm9yJTIwbW9kZWwzJTJDJTIweW91JTIwbmVlZCUyMHRvJTIwbWFudWFsbHklMjBjYWxsJTIwdGhlJTIwaG9vayUyMG9mZmxvYWQlMjBtZXRob2QuJTBBaG9va18zLm9mZmxvYWQoKQ==",highlighted:`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(<span class="hljs-built_in">input</span>) | |
| <span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(<span class="hljs-number">50</span>): | |
| <span class="hljs-comment"># model1 is offloaded on the CPU at the first iteration, model 2 stays on the GPU for this whole loop.</span> | |
| hid_2 = model_2(hid_1) | |
| <span class="hljs-comment"># model2 is offloaded to the CPU just before this forward.</span> | |
| hid_3 = model_3(hid_3) | |
| <span class="hljs-comment"># For model3, you need to manually call the hook offload method.</span> | |
| hook_3.offload()`,wrap:!1}}),{c(){d=c("p"),d.textContent=k,g=a(),i(v.$$.fragment)},l(u){d=r(u,"P",{"data-svelte-h":!0}),b(d)!=="svelte-11lpom8"&&(d.textContent=k),g=n(u),h(v.$$.fragment,u)},m(u,U){l(u,d,U),l(u,g,U),m(v,u,U),y=!0},p:Ke,i(u){y||(p(v.$$.fragment,u),y=!0)},o(u){f(v.$$.fragment,u),y=!1},d(u){u&&(t(d),t(g)),_(v,u)}}}function Na(C){let d,k="Example:",g,v,y;return v=new sa({props:{code:"ZnJvbSUyMGFjY2VsZXJhdGUlMjBpbXBvcnQlMjBpbml0X2VtcHR5X3dlaWdodHMlMkMlMjBsb2FkX2NoZWNrcG9pbnRfYW5kX2Rpc3BhdGNoJTBBZnJvbSUyMGh1Z2dpbmdmYWNlX2h1YiUyMGltcG9ydCUyMGhmX2h1Yl9kb3dubG9hZCUwQWZyb20lMjB0cmFuc2Zvcm1lcnMlMjBpbXBvcnQlMjBBdXRvQ29uZmlnJTJDJTIwQXV0b01vZGVsRm9yQ2F1c2FsTE0lMEElMEElMjMlMjBEb3dubG9hZCUyMHRoZSUyMFdlaWdodHMlMEFjaGVja3BvaW50JTIwJTNEJTIwJTIyRWxldXRoZXJBSSUyRmdwdC1qLTZCJTIyJTBBd2VpZ2h0c19sb2NhdGlvbiUyMCUzRCUyMGhmX2h1Yl9kb3dubG9hZChjaGVja3BvaW50JTJDJTIwJTIycHl0b3JjaF9tb2RlbC5iaW4lMjIpJTBBJTBBJTIzJTIwQ3JlYXRlJTIwYSUyMG1vZGVsJTIwYW5kJTIwaW5pdGlhbGl6ZSUyMGl0JTIwd2l0aCUyMGVtcHR5JTIwd2VpZ2h0cyUwQWNvbmZpZyUyMCUzRCUyMEF1dG9Db25maWcuZnJvbV9wcmV0cmFpbmVkKGNoZWNrcG9pbnQpJTBBd2l0aCUyMGluaXRfZW1wdHlfd2VpZ2h0cygpJTNBJTBBJTIwJTIwJTIwJTIwbW9kZWwlMjAlM0QlMjBBdXRvTW9kZWxGb3JDYXVzYWxMTS5mcm9tX2NvbmZpZyhjb25maWcpJTBBJTBBJTIzJTIwTG9hZCUyMHRoZSUyMGNoZWNrcG9pbnQlMjBhbmQlMjBkaXNwYXRjaCUyMGl0JTIwdG8lMjB0aGUlMjByaWdodCUyMGRldmljZXMlMEFtb2RlbCUyMCUzRCUyMGxvYWRfY2hlY2twb2ludF9hbmRfZGlzcGF0Y2goJTBBJTIwJTIwJTIwJTIwbW9kZWwlMkMlMjB3ZWlnaHRzX2xvY2F0aW9uJTJDJTIwZGV2aWNlX21hcCUzRCUyMmF1dG8lMjIlMkMlMjBub19zcGxpdF9tb2R1bGVfY2xhc3NlcyUzRCU1QiUyMkdQVEpCbG9jayUyMiU1RCUwQSk=",highlighted:`<span class="hljs-meta">>>> </span><span class="hljs-keyword">from</span> accelerate <span class="hljs-keyword">import</span> init_empty_weights, load_checkpoint_and_dispatch | |
| <span class="hljs-meta">>>> </span><span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> hf_hub_download | |
| <span class="hljs-meta">>>> </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoConfig, AutoModelForCausalLM | |
| <span class="hljs-meta">>>> </span><span class="hljs-comment"># Download the Weights</span> | |
| <span class="hljs-meta">>>> </span>checkpoint = <span class="hljs-string">"EleutherAI/gpt-j-6B"</span> | |
| <span class="hljs-meta">>>> </span>weights_location = hf_hub_download(checkpoint, <span class="hljs-string">"pytorch_model.bin"</span>) | |
| <span class="hljs-meta">>>> </span><span class="hljs-comment"># Create a model and initialize it with empty weights</span> | |
| <span class="hljs-meta">>>> </span>config = AutoConfig.from_pretrained(checkpoint) | |
| <span class="hljs-meta">>>> </span><span class="hljs-keyword">with</span> init_empty_weights(): | |
| <span class="hljs-meta">... </span> model = AutoModelForCausalLM.from_config(config) | |
| <span class="hljs-meta">>>> </span><span class="hljs-comment"># Load the checkpoint and dispatch it to the right devices</span> | |
| <span class="hljs-meta">>>> </span>model = load_checkpoint_and_dispatch( | |
| <span class="hljs-meta">... </span> model, weights_location, device_map=<span class="hljs-string">"auto"</span>, no_split_module_classes=[<span class="hljs-string">"GPTJBlock"</span>] | |
| <span class="hljs-meta">... </span>)`,wrap:!1}}),{c(){d=c("p"),d.textContent=k,g=a(),i(v.$$.fragment)},l(u){d=r(u,"P",{"data-svelte-h":!0}),b(d)!=="svelte-11lpom8"&&(d.textContent=k),g=n(u),h(v.$$.fragment,u)},m(u,U){l(u,d,U),l(u,g,U),m(v,u,U),y=!0},p:Ke,i(u){y||(p(v.$$.fragment,u),y=!0)},o(u){f(v.$$.fragment,u),y=!1},d(u){u&&(t(d),t(g)),_(v,u)}}}function Pa(C){let d,k=`Once loaded across devices, you still need to call <a href="/docs/accelerate/main/en/package_reference/big_modeling#accelerate.dispatch_model">dispatch_model()</a> on your model to make it able to run. To | |
| group the checkpoint loading and dispatch in one single call, use <a href="/docs/accelerate/main/en/package_reference/big_modeling#accelerate.load_checkpoint_and_dispatch">load_checkpoint_and_dispatch()</a>.`;return{c(){d=c("p"),d.innerHTML=k},l(g){d=r(g,"P",{"data-svelte-h":!0}),b(d)!=="svelte-13sragn"&&(d.innerHTML=k)},m(g,v){l(g,d,v)},p:Ke,d(g){g&&t(d)}}}function Va(C){let d,k=`All computation is done analyzing sizes and dtypes of the model parameters. As a result, the model can be on the | |
| meta device (as it would if initialized within the <code>init_empty_weights</code> context manager).`;return{c(){d=c("p"),d.innerHTML=k},l(g){d=r(g,"P",{"data-svelte-h":!0}),b(d)!=="svelte-1d9m3bn"&&(d.innerHTML=k)},m(g,v){l(g,d,v)},p:Ke,d(g){g&&t(d)}}}function Ra(C){let d,k=`If the module already contains a hook, this will replace it with the new hook passed by default. To chain two hooks | |
| together, pass <code>append=True</code>, so it chains the current and new hook into an instance of the <code>SequentialHook</code> class.`;return{c(){d=c("p"),d.innerHTML=k},l(g){d=r(g,"P",{"data-svelte-h":!0}),b(d)!=="svelte-1dclc89"&&(d.innerHTML=k)},m(g,v){l(g,d,v)},p:Ke,d(g){g&&t(d)}}}function Ea(C){let d,k,g,v,y,u,U,Uo,ce,Co,J,re,Mt,eo,ca=`A context manager under which models are initialized with all parameters on the meta device, therefore creating an | |
| empty model. Useful when just initializing the model would blow the available RAM.`,Tt,Q,Ut,O,jo,ie,Jo,B,he,Ct,oo,ra=`Activates full CPU offload for a model. As a result, all parameters of the model will be offloaded and only one | |
| copy of the state dict of the model will be kept. During the forward pass, parameters will be extracted from that | |
| state dict and put on the execution device passed as they are needed, then offloaded again.`,Io,me,Go,G,pe,jt,to,ia=`Offloads a model on the CPU and puts it back to an execution device when executed. The difference with | |
| <a href="/docs/accelerate/main/en/package_reference/big_modeling#accelerate.cpu_offload">cpu_offload()</a> is that the model stays on the execution device after the forward and is only offloaded again when | |
| the <code>offload</code> method of the returned <code>hook</code> is called. Useful for pipelines running a model in a loop.`,Jt,Y,Do,fe,Wo,L,_e,It,ao,ha=`Activates full disk offload for a model. As a result, all parameters of the model will be offloaded as | |
| memory-mapped array in a given folder. During the forward pass, parameters will be accessed from that folder and | |
| put on the execution device passed as they are needed, then offloaded again.`,Ho,ue,Fo,A,ge,Gt,no,ma=`Dispatches a model according to a given device map. Layers of the model might be spread across GPUs, offloaded on | |
| the CPU or even the disk.`,Bo,ve,Lo,D,be,Dt,lo,pa=`Loads a (potentially sharded) checkpoint inside a model, potentially sending weights to a given device as they are | |
| loaded and adds the various hooks that will make this model run properly (even if split across devices).`,Wt,K,Ao,ke,Zo,W,$e,Ht,so,fa=`Loads a (potentially sharded) checkpoint inside a model, potentially sending weights to a given device as they are | |
| loaded.`,Ft,ee,No,we,Po,I,ye,Bt,co,_a=`Compute a device map for a given model giving priority to GPUs, then offload on CPU and finally offload to disk, | |
| such that:`,Lt,ro,ua=`<li>we don’t exceed the memory available of any of the GPU.</li> <li>if offload to the CPU is needed, there is always room left on GPU 0 to put back the layer offloaded on CPU that | |
| has the largest size.</li> <li>if offload to the CPU is needed,we don’t exceed the RAM available on the CPU.</li> <li>if offload to the disk is needed, there is always room left on the CPU to put back the layer offloaded on disk | |
| that has the largest size.</li>`,At,oe,Vo,xe,Ro,Me,Eo,M,Te,Zt,io,ga=`A hook that contains callbacks to be executed just before and after the forward method of a model. The difference | |
| with PyTorch existing hooks is that they get passed along the kwargs.`,Nt,ho,va="Class attribute:",Pt,mo,ba=`<li><strong>no_grad</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) — Whether or not to execute the actual forward pass under | |
| the <code>torch.no_grad()</code> context manager.</li>`,Vt,te,Ue,Rt,po,ka="To be executed when the hook is detached from a module.",Et,ae,Ce,zt,fo,$a="To be executed when the hook is attached to the module.",Xt,ne,je,qt,_o,wa="To be executed just after the forward method of the model.",St,le,Je,Qt,uo,ya="To be executed just before the forward method of the model.",zo,Ie,Xo,Z,Ge,Ot,go,xa=`A generic <code>ModelHook</code> that ensures inputs and model weights are on the same device for the forward pass of the | |
| associated module, potentially offloading the weights after the forward pass.`,qo,De,So,N,We,Yt,vo,Ma="A hook that can contain several hooks and iterates through them at each event.",Qo,He,Oo,Fe,Yo,H,Be,Kt,bo,Ta=`Adds a hook to a given module. This will rewrite the <code>forward</code> method of the module to include the hook, to remove | |
| this behavior and restore the original <code>forward</code> method, use <code>remove_hook_from_module</code>.`,ea,de,Ko,Le,et,P,Ae,oa,ko,Ua=`Recursively attaches <code>AlignDevicesHook</code> to all submodules of a given model to make sure they have the right | |
| execution device`,ot,Ze,tt,V,Ne,ta,$o,Ca=`Recursively attaches <code>AlignDevicesHook</code> to all submodules of a given model that have direct parameters and/or | |
| buffers.`,at,Pe,nt,R,Ve,aa,wo,ja="Attaches <code>AlignDevicesHook</code> to all blocks of a given model as needed.",lt,Re,dt,Ee,st,E,ze,na,yo,Ja="Removes any hook attached to a module via <code>add_hook_to_module</code>.",ct,Xe,rt,z,qe,la,xo,Ia="Recursively removes all hooks attached on the submodules of a given model.",it,Se,ht,To,mt;return y=new x({props:{title:"Working with large models",local:"working-with-large-models",headingTag:"h1"}}),U=new x({props:{title:"Dispatch and offload",local:"dispatch-and-offload",headingTag:"h2"}}),ce=new x({props:{title:"init_empty_weights",local:"accelerate.init_empty_weights",headingTag:"h3"}}),re=new T({props:{name:"accelerate.init_empty_weights",anchor:"accelerate.init_empty_weights",parameters:[{name:"include_buffers",val:": bool = None"}],parametersDescription:[{anchor:"accelerate.init_empty_weights.include_buffers",description:`<strong>include_buffers</strong> (<code>bool</code>, <em>optional</em>) — | |
| Whether or not to also put all buffers on the meta device while initializing.`,name:"include_buffers"}],source:"https://github.com/huggingface/accelerate/blob/main/src/accelerate/big_modeling.py#L56"}}),Q=new da({props:{anchor:"accelerate.init_empty_weights.example",$$slots:{default:[La]},$$scope:{ctx:C}}}),O=new xt({props:{warning:!0,$$slots:{default:[Aa]},$$scope:{ctx:C}}}),ie=new x({props:{title:"cpu_offload",local:"accelerate.cpu_offload",headingTag:"h3"}}),he=new T({props:{name:"accelerate.cpu_offload",anchor:"accelerate.cpu_offload",parameters:[{name:"model",val:": Module"},{name:"execution_device",val:": Optional = None"},{name:"offload_buffers",val:": bool = False"},{name:"state_dict",val:": Optional = None"},{name:"preload_module_classes",val:": Optional = None"}],parametersDescription:[{anchor:"accelerate.cpu_offload.model",description:`<strong>model</strong> (<code>torch.nn.Module</code>) — | |
| The model to offload.`,name:"model"},{anchor:"accelerate.cpu_offload.execution_device",description:`<strong>execution_device</strong> (<code>torch.device</code>, <em>optional</em>) — | |
| The device on which the forward pass of the model will be executed (should be a GPU). Will default to the | |
| model first parameter device.`,name:"execution_device"},{anchor:"accelerate.cpu_offload.offload_buffers",description:`<strong>offload_buffers</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) — | |
| Whether or not to offload the buffers with the model parameters.`,name:"offload_buffers"},{anchor:"accelerate.cpu_offload.state_dict",description:`<strong>state_dict</strong> (<code>Dict[str, torch.Tensor]</code>, <em>optional</em>) — | |
| The state dict of the model that will be kept on CPU.`,name:"state_dict"},{anchor:"accelerate.cpu_offload.preload_module_classes",description:`<strong>preload_module_classes</strong> (<code>List[str]</code>, <em>optional</em>) — | |
| A list of classes whose instances should load all their weights (even in the submodules) at the beginning | |
| of the forward. This should only be used for classes that have submodules which are registered but not | |
| called directly during the forward, for instance if a <code>dense</code> linear layer is registered, but at forward, | |
| <code>dense.weight</code> and <code>dense.bias</code> are used in some operations instead of calling <code>dense</code> directly.`,name:"preload_module_classes"}],source:"https://github.com/huggingface/accelerate/blob/main/src/accelerate/big_modeling.py#L170"}}),me=new x({props:{title:"cpu_offload_with_hook",local:"accelerate.cpu_offload_with_hook",headingTag:"h3"}}),pe=new T({props:{name:"accelerate.cpu_offload_with_hook",anchor:"accelerate.cpu_offload_with_hook",parameters:[{name:"model",val:": Module"},{name:"execution_device",val:": Union = None"},{name:"prev_module_hook",val:": Optional = None"}],parametersDescription:[{anchor:"accelerate.cpu_offload_with_hook.model",description:`<strong>model</strong> (<code>torch.nn.Module</code>) — | |
| The model to offload.`,name:"model"},{anchor:"accelerate.cpu_offload_with_hook.execution_device(str,",description:`<strong>execution_device(<code>str</code>,</strong> <code>int</code> or <code>torch.device</code>, <em>optional</em>) — | |
| The device on which the model should be executed. Will default to the MPS device if it’s available, then | |
| GPU 0 if there is a GPU, and finally to the CPU.`,name:"execution_device(str,"},{anchor:"accelerate.cpu_offload_with_hook.prev_module_hook",description:`<strong>prev_module_hook</strong> (<code>UserCpuOffloadHook</code>, <em>optional</em>) — | |
| The hook sent back by this function for a previous model in the pipeline you are running. If passed, its | |
| offload method will be called just before the forward of the model to which this hook is attached.`,name:"prev_module_hook"}],source:"https://github.com/huggingface/accelerate/blob/main/src/accelerate/big_modeling.py#L216"}}),Y=new da({props:{anchor:"accelerate.cpu_offload_with_hook.example",$$slots:{default:[Za]},$$scope:{ctx:C}}}),fe=new x({props:{title:"disk_offload",local:"accelerate.disk_offload",headingTag:"h3"}}),_e=new T({props:{name:"accelerate.disk_offload",anchor:"accelerate.disk_offload",parameters:[{name:"model",val:": Module"},{name:"offload_dir",val:": Union"},{name:"execution_device",val:": Optional = None"},{name:"offload_buffers",val:": bool = False"},{name:"preload_module_classes",val:": Optional = None"}],parametersDescription:[{anchor:"accelerate.disk_offload.model",description:"<strong>model</strong> (<code>torch.nn.Module</code>) — The model to offload.",name:"model"},{anchor:"accelerate.disk_offload.offload_dir",description:`<strong>offload_dir</strong> (<code>str</code> or <code>os.PathLike</code>) — | |
| The folder in which to offload the model weights (or where the model weights are already offloaded).`,name:"offload_dir"},{anchor:"accelerate.disk_offload.execution_device",description:`<strong>execution_device</strong> (<code>torch.device</code>, <em>optional</em>) — | |
| The device on which the forward pass of the model will be executed (should be a GPU). Will default to the | |
| model’s first parameter device.`,name:"execution_device"},{anchor:"accelerate.disk_offload.offload_buffers",description:`<strong>offload_buffers</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) — | |
| Whether or not to offload the buffers with the model parameters.`,name:"offload_buffers"},{anchor:"accelerate.disk_offload.preload_module_classes",description:`<strong>preload_module_classes</strong> (<code>List[str]</code>, <em>optional</em>) — | |
| A list of classes whose instances should load all their weights (even in the submodules) at the beginning | |
| of the forward. This should only be used for classes that have submodules which are registered but not | |
| called directly during the forward, for instance if a <code>dense</code> linear layer is registered, but at forward, | |
| <code>dense.weight</code> and <code>dense.bias</code> are used in some operations instead of calling <code>dense</code> directly.`,name:"preload_module_classes"}],source:"https://github.com/huggingface/accelerate/blob/main/src/accelerate/big_modeling.py#L260"}}),ue=new x({props:{title:"dispatch_model",local:"accelerate.dispatch_model",headingTag:"h3"}}),ge=new T({props:{name:"accelerate.dispatch_model",anchor:"accelerate.dispatch_model",parameters:[{name:"model",val:": Module"},{name:"device_map",val:": Dict"},{name:"main_device",val:": Optional = None"},{name:"state_dict",val:": Optional = None"},{name:"offload_dir",val:": Union = None"},{name:"offload_index",val:": Optional = None"},{name:"offload_buffers",val:": bool = False"},{name:"skip_keys",val:": Union = None"},{name:"preload_module_classes",val:": Optional = None"},{name:"force_hooks",val:": bool = False"}],parametersDescription:[{anchor:"accelerate.dispatch_model.model",description:`<strong>model</strong> (<code>torch.nn.Module</code>) — | |
| The model to dispatch.`,name:"model"},{anchor:"accelerate.dispatch_model.device_map",description:`<strong>device_map</strong> (<code>Dict[str, Union[str, int, torch.device]]</code>) — | |
| A dictionary mapping module names in the models <code>state_dict</code> to the device they should go to. Note that | |
| <code>"disk"</code> is accepted even if it’s not a proper value for <code>torch.device</code>.`,name:"device_map"},{anchor:"accelerate.dispatch_model.main_device",description:`<strong>main_device</strong> (<code>str</code>, <code>int</code> or <code>torch.device</code>, <em>optional</em>) — | |
| The main execution device. Will default to the first device in the <code>device_map</code> different from <code>"cpu"</code> or | |
| <code>"disk"</code>.`,name:"main_device"},{anchor:"accelerate.dispatch_model.state_dict",description:`<strong>state_dict</strong> (<code>Dict[str, torch.Tensor]</code>, <em>optional</em>) — | |
| The state dict of the part of the model that will be kept on CPU.`,name:"state_dict"},{anchor:"accelerate.dispatch_model.offload_dir",description:`<strong>offload_dir</strong> (<code>str</code> or <code>os.PathLike</code>) — | |
| The folder in which to offload the model weights (or where the model weights are already offloaded).`,name:"offload_dir"},{anchor:"accelerate.dispatch_model.offload_index",description:`<strong>offload_index</strong> (<code>Dict</code>, <em>optional</em>) — | |
| A dictionary from weight name to their information (<code>dtype</code>/ <code>shape</code> or safetensors filename). Will default | |
| to the index saved in <code>save_folder</code>.`,name:"offload_index"},{anchor:"accelerate.dispatch_model.offload_buffers",description:`<strong>offload_buffers</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) — | |
| Whether or not to offload the buffers with the model parameters.`,name:"offload_buffers"},{anchor:"accelerate.dispatch_model.skip_keys",description:`<strong>skip_keys</strong> (<code>str</code> or <code>List[str]</code>, <em>optional</em>) — | |
| A list of keys to ignore when moving inputs or outputs between devices.`,name:"skip_keys"},{anchor:"accelerate.dispatch_model.preload_module_classes",description:`<strong>preload_module_classes</strong> (<code>List[str]</code>, <em>optional</em>) — | |
| A list of classes whose instances should load all their weights (even in the submodules) at the beginning | |
| of the forward. This should only be used for classes that have submodules which are registered but not | |
| called directly during the forward, for instance if a <code>dense</code> linear layer is registered, but at forward, | |
| <code>dense.weight</code> and <code>dense.bias</code> are used in some operations instead of calling <code>dense</code> directly.`,name:"preload_module_classes"},{anchor:"accelerate.dispatch_model.force_hooks",description:`<strong>force_hooks</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) — | |
| Whether or not to force device hooks to be attached to the model even if all layers are dispatched to a | |
| single device.`,name:"force_hooks"}],source:"https://github.com/huggingface/accelerate/blob/main/src/accelerate/big_modeling.py#L306"}}),ve=new x({props:{title:"load_checkpoint_and_dispatch",local:"accelerate.load_checkpoint_and_dispatch",headingTag:"h3"}}),be=new T({props:{name:"accelerate.load_checkpoint_and_dispatch",anchor:"accelerate.load_checkpoint_and_dispatch",parameters:[{name:"model",val:": Module"},{name:"checkpoint",val:": Union"},{name:"device_map",val:": Union = None"},{name:"max_memory",val:": Optional = None"},{name:"no_split_module_classes",val:": Optional = None"},{name:"offload_folder",val:": Union = None"},{name:"offload_buffers",val:": bool = False"},{name:"dtype",val:": Union = None"},{name:"offload_state_dict",val:": Optional = None"},{name:"skip_keys",val:": Union = None"},{name:"preload_module_classes",val:": Optional = None"},{name:"force_hooks",val:": bool = False"},{name:"strict",val:": bool = False"}],parametersDescription:[{anchor:"accelerate.load_checkpoint_and_dispatch.model",description:"<strong>model</strong> (<code>torch.nn.Module</code>) — The model in which we want to load a checkpoint.",name:"model"},{anchor:"accelerate.load_checkpoint_and_dispatch.checkpoint",description:`<strong>checkpoint</strong> (<code>str</code> or <code>os.PathLike</code>) — | |
| The folder checkpoint to load. It can be:</p> | |
| <ul> | |
| <li>a path to a file containing a whole model state dict</li> | |
| <li>a path to a <code>.json</code> file containing the index to a sharded checkpoint</li> | |
| <li>a path to a folder containing a unique <code>.index.json</code> file and the shards of a checkpoint.</li> | |
| </ul>`,name:"checkpoint"},{anchor:"accelerate.load_checkpoint_and_dispatch.device_map",description:`<strong>device_map</strong> (<code>Dict[str, Union[int, str, torch.device]]</code>, <em>optional</em>) — | |
| A map that specifies where each submodule should go. It doesn’t need to be refined to each parameter/buffer | |
| name, once a given module name is inside, every submodule of it will be sent to the same device.</p> | |
| <p>To have Accelerate compute the most optimized <code>device_map</code> automatically, set <code>device_map="auto"</code>. For more | |
| information about each option see <a href="../concept_guides/big_model_inference#designing-a-device-map">here</a>. | |
| Defaults to None, which means <a href="/docs/accelerate/main/en/package_reference/big_modeling#accelerate.dispatch_model">dispatch_model()</a> will not be called.`,name:"device_map"},{anchor:"accelerate.load_checkpoint_and_dispatch.max_memory",description:`<strong>max_memory</strong> (<code>Dict</code>, <em>optional</em>) — | |
| A dictionary device identifier to maximum memory. Will default to the maximum memory available for each GPU | |
| and the available CPU RAM if unset.`,name:"max_memory"},{anchor:"accelerate.load_checkpoint_and_dispatch.no_split_module_classes",description:`<strong>no_split_module_classes</strong> (<code>List[str]</code>, <em>optional</em>) — | |
| A list of layer class names that should never be split across device (for instance any layer that has a | |
| residual connection).`,name:"no_split_module_classes"},{anchor:"accelerate.load_checkpoint_and_dispatch.offload_folder",description:`<strong>offload_folder</strong> (<code>str</code> or <code>os.PathLike</code>, <em>optional</em>) — | |
| If the <code>device_map</code> contains any value <code>"disk"</code>, the folder where we will offload weights.`,name:"offload_folder"},{anchor:"accelerate.load_checkpoint_and_dispatch.offload_buffers",description:`<strong>offload_buffers</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) — | |
| In the layers that are offloaded on the CPU or the hard drive, whether or not to offload the buffers as | |
| well as the parameters.`,name:"offload_buffers"},{anchor:"accelerate.load_checkpoint_and_dispatch.dtype",description:`<strong>dtype</strong> (<code>str</code> or <code>torch.dtype</code>, <em>optional</em>) — | |
| If provided, the weights will be converted to that type when loaded.`,name:"dtype"},{anchor:"accelerate.load_checkpoint_and_dispatch.offload_state_dict",description:`<strong>offload_state_dict</strong> (<code>bool</code>, <em>optional</em>) — | |
| If <code>True</code>, will temporarily offload the CPU state dict on the hard drive to avoid getting out of CPU RAM if | |
| the weight of the CPU state dict + the biggest shard does not fit. Will default to <code>True</code> if the device map | |
| picked contains <code>"disk"</code> values.`,name:"offload_state_dict"},{anchor:"accelerate.load_checkpoint_and_dispatch.skip_keys",description:`<strong>skip_keys</strong> (<code>str</code> or <code>List[str]</code>, <em>optional</em>) — | |
| A list of keys to ignore when moving inputs or outputs between devices.`,name:"skip_keys"},{anchor:"accelerate.load_checkpoint_and_dispatch.preload_module_classes",description:`<strong>preload_module_classes</strong> (<code>List[str]</code>, <em>optional</em>) — | |
| A list of classes whose instances should load all their weights (even in the submodules) at the beginning | |
| of the forward. This should only be used for classes that have submodules which are registered but not | |
| called directly during the forward, for instance if a <code>dense</code> linear layer is registered, but at forward, | |
| <code>dense.weight</code> and <code>dense.bias</code> are used in some operations instead of calling <code>dense</code> directly.`,name:"preload_module_classes"},{anchor:"accelerate.load_checkpoint_and_dispatch.force_hooks",description:`<strong>force_hooks</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) — | |
| Whether or not to force device hooks to be attached to the model even if all layers are dispatched to a | |
| single device.`,name:"force_hooks"},{anchor:"accelerate.load_checkpoint_and_dispatch.strict",description:`<strong>strict</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) — | |
| Whether to strictly enforce that the keys in the checkpoint state_dict match the keys of the model’s | |
| state_dict.`,name:"strict"}],source:"https://github.com/huggingface/accelerate/blob/main/src/accelerate/big_modeling.py#L504"}}),K=new da({props:{anchor:"accelerate.load_checkpoint_and_dispatch.example",$$slots:{default:[Na]},$$scope:{ctx:C}}}),ke=new x({props:{title:"load_checkpoint_in_model",local:"accelerate.load_checkpoint_in_model",headingTag:"h3"}}),$e=new T({props:{name:"accelerate.load_checkpoint_in_model",anchor:"accelerate.load_checkpoint_in_model",parameters:[{name:"model",val:": Module"},{name:"checkpoint",val:": Union"},{name:"device_map",val:": Optional = None"},{name:"offload_folder",val:": Union = None"},{name:"dtype",val:": Union = None"},{name:"offload_state_dict",val:": bool = False"},{name:"offload_buffers",val:": bool = False"},{name:"keep_in_fp32_modules",val:": List = None"},{name:"offload_8bit_bnb",val:": bool = False"},{name:"strict",val:": bool = False"}],parametersDescription:[{anchor:"accelerate.load_checkpoint_in_model.model",description:`<strong>model</strong> (<code>torch.nn.Module</code>) — | |
| The model in which we want to load a checkpoint.`,name:"model"},{anchor:"accelerate.load_checkpoint_in_model.checkpoint",description:`<strong>checkpoint</strong> (<code>str</code> or <code>os.PathLike</code>) — | |
| The folder checkpoint to load. It can be:<ul> | |
| <li>a path to a file containing a whole model state dict</li> | |
| <li>a path to a <code>.json</code> file containing the index to a sharded checkpoint</li> | |
| <li>a path to a folder containing a unique <code>.index.json</code> file and the shards of a checkpoint.</li> | |
| <li>a path to a folder containing a unique pytorch_model.bin or a model.safetensors file.</li> | |
| </ul>`,name:"checkpoint"},{anchor:"accelerate.load_checkpoint_in_model.device_map",description:`<strong>device_map</strong> (<code>Dict[str, Union[int, str, torch.device]]</code>, <em>optional</em>) — | |
| A map that specifies where each submodule should go. It doesn’t need to be refined to each parameter/buffer | |
| name, once a given module name is inside, every submodule of it will be sent to the same device.`,name:"device_map"},{anchor:"accelerate.load_checkpoint_in_model.offload_folder",description:`<strong>offload_folder</strong> (<code>str</code> or <code>os.PathLike</code>, <em>optional</em>) — | |
| If the <code>device_map</code> contains any value <code>"disk"</code>, the folder where we will offload weights.`,name:"offload_folder"},{anchor:"accelerate.load_checkpoint_in_model.dtype",description:`<strong>dtype</strong> (<code>str</code> or <code>torch.dtype</code>, <em>optional</em>) — | |
| If provided, the weights will be converted to that type when loaded.`,name:"dtype"},{anchor:"accelerate.load_checkpoint_in_model.offload_state_dict",description:`<strong>offload_state_dict</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) — | |
| If <code>True</code>, will temporarily offload the CPU state dict on the hard drive to avoid getting out of CPU RAM if | |
| the weight of the CPU state dict + the biggest shard does not fit.`,name:"offload_state_dict"},{anchor:"accelerate.load_checkpoint_in_model.offload_buffers",description:`<strong>offload_buffers</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) — | |
| Whether or not to include the buffers in the weights offloaded to disk.`,name:"offload_buffers"},{anchor:"accelerate.load_checkpoint_in_model.keep_in_fp32_modules(List[str],",description:`<strong>keep_in_fp32_modules(<code>List[str]</code>,</strong> <em>optional</em>) — | |
| A list of the modules that we keep in <code>torch.float32</code> dtype.`,name:"keep_in_fp32_modules(List[str],"},{anchor:"accelerate.load_checkpoint_in_model.offload_8bit_bnb",description:`<strong>offload_8bit_bnb</strong> (<code>bool</code>, <em>optional</em>) — | |
| Whether or not to enable offload of 8-bit modules on cpu/disk.`,name:"offload_8bit_bnb"},{anchor:"accelerate.load_checkpoint_in_model.strict",description:`<strong>strict</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) — | |
| Whether to strictly enforce that the keys in the checkpoint state_dict match the keys of the model’s | |
| state_dict.`,name:"strict"}],source:"https://github.com/huggingface/accelerate/blob/main/src/accelerate/utils/modeling.py#L1695"}}),ee=new xt({props:{warning:!0,$$slots:{default:[Pa]},$$scope:{ctx:C}}}),we=new x({props:{title:"infer_auto_device_map",local:"accelerate.infer_auto_device_map",headingTag:"h3"}}),ye=new T({props:{name:"accelerate.infer_auto_device_map",anchor:"accelerate.infer_auto_device_map",parameters:[{name:"model",val:": Module"},{name:"max_memory",val:": Optional = None"},{name:"no_split_module_classes",val:": Optional = None"},{name:"dtype",val:": Union = None"},{name:"special_dtypes",val:": Optional = None"},{name:"verbose",val:": bool = False"},{name:"clean_result",val:": bool = True"},{name:"offload_buffers",val:": bool = False"}],parametersDescription:[{anchor:"accelerate.infer_auto_device_map.model",description:`<strong>model</strong> (<code>torch.nn.Module</code>) — | |
| The model to analyze.`,name:"model"},{anchor:"accelerate.infer_auto_device_map.max_memory",description:`<strong>max_memory</strong> (<code>Dict</code>, <em>optional</em>) — | |
| A dictionary device identifier to maximum memory. Will default to the maximum memory available if unset. | |
| Example: <code>max_memory={0: "1GB"}</code>.`,name:"max_memory"},{anchor:"accelerate.infer_auto_device_map.no_split_module_classes",description:`<strong>no_split_module_classes</strong> (<code>List[str]</code>, <em>optional</em>) — | |
| A list of layer class names that should never be split across device (for instance any layer that has a | |
| residual connection).`,name:"no_split_module_classes"},{anchor:"accelerate.infer_auto_device_map.dtype",description:`<strong>dtype</strong> (<code>str</code> or <code>torch.dtype</code>, <em>optional</em>) — | |
| If provided, the weights will be converted to that type when loaded.`,name:"dtype"},{anchor:"accelerate.infer_auto_device_map.special_dtypes",description:`<strong>special_dtypes</strong> (<code>Dict[str, Union[str, torch.device]]</code>, <em>optional</em>) — | |
| If provided, special dtypes to consider for some specific weights (will override dtype used as default for | |
| all weights).`,name:"special_dtypes"},{anchor:"accelerate.infer_auto_device_map.verbose",description:`<strong>verbose</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) — | |
| Whether or not to provide debugging statements as the function builds the device_map.`,name:"verbose"},{anchor:"accelerate.infer_auto_device_map.clean_result",description:`<strong>clean_result</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) — | |
| Clean the resulting device_map by grouping all submodules that go on the same device together.`,name:"clean_result"},{anchor:"accelerate.infer_auto_device_map.offload_buffers",description:`<strong>offload_buffers</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) — | |
| In the layers that are offloaded on the CPU or the hard drive, whether or not to offload the buffers as | |
| well as the parameters.`,name:"offload_buffers"}],source:"https://github.com/huggingface/accelerate/blob/main/src/accelerate/utils/modeling.py#L1180"}}),oe=new xt({props:{$$slots:{default:[Va]},$$scope:{ctx:C}}}),xe=new x({props:{title:"Hooks",local:"hooks",headingTag:"h2"}}),Me=new x({props:{title:"ModelHook",local:"accelerate.hooks.ModelHook",headingTag:"h3"}}),Te=new T({props:{name:"class accelerate.hooks.ModelHook",anchor:"accelerate.hooks.ModelHook",parameters:[],source:"https://github.com/huggingface/accelerate/blob/main/src/accelerate/hooks.py#L37"}}),Ue=new T({props:{name:"detach_hook",anchor:"accelerate.hooks.ModelHook.detach_hook",parameters:[{name:"module",val:""}],parametersDescription:[{anchor:"accelerate.hooks.ModelHook.detach_hook.module",description:"<strong>module</strong> (<code>torch.nn.Module</code>) — The module detached from this hook.",name:"module"}],source:"https://github.com/huggingface/accelerate/blob/main/src/accelerate/hooks.py#L85"}}),Ce=new T({props:{name:"init_hook",anchor:"accelerate.hooks.ModelHook.init_hook",parameters:[{name:"module",val:""}],parametersDescription:[{anchor:"accelerate.hooks.ModelHook.init_hook.module",description:"<strong>module</strong> (<code>torch.nn.Module</code>) — The module attached to this hook.",name:"module"}],source:"https://github.com/huggingface/accelerate/blob/main/src/accelerate/hooks.py#L49"}}),je=new T({props:{name:"post_forward",anchor:"accelerate.hooks.ModelHook.post_forward",parameters:[{name:"module",val:""},{name:"output",val:""}],parametersDescription:[{anchor:"accelerate.hooks.ModelHook.post_forward.module",description:"<strong>module</strong> (<code>torch.nn.Module</code>) — The module whose forward pass been executed just before this event.",name:"module"},{anchor:"accelerate.hooks.ModelHook.post_forward.output",description:"<strong>output</strong> (<code>Any</code>) — The output of the module.",name:"output"}],source:"https://github.com/huggingface/accelerate/blob/main/src/accelerate/hooks.py#L72",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>The processed <code>output</code>.</p> | |
| `,returnType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><code>Any</code></p> | |
| `}}),Je=new T({props:{name:"pre_forward",anchor:"accelerate.hooks.ModelHook.pre_forward",parameters:[{name:"module",val:""},{name:"*args",val:""},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"accelerate.hooks.ModelHook.pre_forward.module",description:"<strong>module</strong> (<code>torch.nn.Module</code>) — The module whose forward pass will be executed just after this event.",name:"module"},{anchor:"accelerate.hooks.ModelHook.pre_forward.args",description:"<strong>args</strong> (<code>Tuple[Any]</code>) — The positional arguments passed to the module.",name:"args"},{anchor:"accelerate.hooks.ModelHook.pre_forward.kwargs",description:"<strong>kwargs</strong> (<code>Dict[Str, Any]</code>) — The keyword arguments passed to the module.",name:"kwargs"}],source:"https://github.com/huggingface/accelerate/blob/main/src/accelerate/hooks.py#L58",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>A tuple with the treated <code>args</code> and <code>kwargs</code>.</p> | |
| `,returnType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><code>Tuple[Tuple[Any], Dict[Str, Any]]</code></p> | |
| `}}),Ie=new x({props:{title:"AlignDevicesHook",local:"accelerate.hooks.AlignDevicesHook",headingTag:"h3"}}),Ge=new T({props:{name:"class accelerate.hooks.AlignDevicesHook",anchor:"accelerate.hooks.AlignDevicesHook",parameters:[{name:"execution_device",val:": Union = None"},{name:"offload",val:": bool = False"},{name:"io_same_device",val:": bool = False"},{name:"weights_map",val:": Optional = None"},{name:"offload_buffers",val:": bool = False"},{name:"place_submodules",val:": bool = False"},{name:"skip_keys",val:": Union = None"},{name:"tied_params_map",val:": Optional = None"}],parametersDescription:[{anchor:"accelerate.hooks.AlignDevicesHook.execution_device",description:`<strong>execution_device</strong> (<code>torch.device</code>, <em>optional</em>) — | |
| The device on which inputs and model weights should be placed before the forward pass.`,name:"execution_device"},{anchor:"accelerate.hooks.AlignDevicesHook.offload",description:`<strong>offload</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) — | |
| Whether or not the weights should be offloaded after the forward pass.`,name:"offload"},{anchor:"accelerate.hooks.AlignDevicesHook.io_same_device",description:`<strong>io_same_device</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) — | |
| Whether or not the output should be placed on the same device as the input was.`,name:"io_same_device"},{anchor:"accelerate.hooks.AlignDevicesHook.weights_map",description:`<strong>weights_map</strong> (<code>Mapping[str, torch.Tensor]</code>, <em>optional</em>) — | |
| When the model weights are offloaded, a (potentially lazy) map from param names to the tensor values.`,name:"weights_map"},{anchor:"accelerate.hooks.AlignDevicesHook.offload_buffers",description:`<strong>offload_buffers</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) — | |
| Whether or not to include the associated module’s buffers when offloading.`,name:"offload_buffers"},{anchor:"accelerate.hooks.AlignDevicesHook.place_submodules",description:`<strong>place_submodules</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) — | |
| Whether to place the submodules on <code>execution_device</code> during the <code>init_hook</code> event.`,name:"place_submodules"}],source:"https://github.com/huggingface/accelerate/blob/main/src/accelerate/hooks.py#L220"}}),De=new x({props:{title:"SequentialHook",local:"accelerate.hooks.SequentialHook",headingTag:"h3"}}),We=new T({props:{name:"class accelerate.hooks.SequentialHook",anchor:"accelerate.hooks.SequentialHook",parameters:[{name:"*hooks",val:""}],source:"https://github.com/huggingface/accelerate/blob/main/src/accelerate/hooks.py#L95"}}),He=new x({props:{title:"Adding Hooks",local:"adding-hooks",headingTag:"h2"}}),Fe=new x({props:{title:"add_hook_to_module",local:"accelerate.hooks.add_hook_to_module",headingTag:"h3"}}),Be=new T({props:{name:"accelerate.hooks.add_hook_to_module",anchor:"accelerate.hooks.add_hook_to_module",parameters:[{name:"module",val:": Module"},{name:"hook",val:": ModelHook"},{name:"append",val:": bool = False"}],parametersDescription:[{anchor:"accelerate.hooks.add_hook_to_module.module",description:`<strong>module</strong> (<code>torch.nn.Module</code>) — | |
| The module to attach a hook to.`,name:"module"},{anchor:"accelerate.hooks.add_hook_to_module.hook",description:`<strong>hook</strong> (<code>ModelHook</code>) — | |
| The hook to attach.`,name:"hook"},{anchor:"accelerate.hooks.add_hook_to_module.append",description:`<strong>append</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) — | |
| Whether the hook should be chained with an existing one (if module already contains a hook) or not.`,name:"append"}],source:"https://github.com/huggingface/accelerate/blob/main/src/accelerate/hooks.py#L124",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>The same module, with the hook attached (the module is modified in place, so the result can | |
| be discarded).</p> | |
| `,returnType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><code>torch.nn.Module</code></p> | |
| `}}),de=new xt({props:{warning:!0,$$slots:{default:[Ra]},$$scope:{ctx:C}}}),Le=new x({props:{title:"attach_execution_device_hook",local:"accelerate.hooks.attach_execution_device_hook",headingTag:"h3"}}),Ae=new T({props:{name:"accelerate.hooks.attach_execution_device_hook",anchor:"accelerate.hooks.attach_execution_device_hook",parameters:[{name:"module",val:": Module"},{name:"execution_device",val:": Union"},{name:"skip_keys",val:": Union = None"},{name:"preload_module_classes",val:": Optional = None"},{name:"tied_params_map",val:": Optional = None"}],parametersDescription:[{anchor:"accelerate.hooks.attach_execution_device_hook.module",description:`<strong>module</strong> (<code>torch.nn.Module</code>) — | |
| The module where we want to attach the hooks.`,name:"module"},{anchor:"accelerate.hooks.attach_execution_device_hook.execution_device",description:`<strong>execution_device</strong> (<code>int</code>, <code>str</code> or <code>torch.device</code>) — | |
| The device on which inputs and model weights should be placed before the forward pass.`,name:"execution_device"},{anchor:"accelerate.hooks.attach_execution_device_hook.skip_keys",description:`<strong>skip_keys</strong> (<code>str</code> or <code>List[str]</code>, <em>optional</em>) — | |
| A list of keys to ignore when moving inputs or outputs between devices.`,name:"skip_keys"},{anchor:"accelerate.hooks.attach_execution_device_hook.preload_module_classes",description:`<strong>preload_module_classes</strong> (<code>List[str]</code>, <em>optional</em>) — | |
| A list of classes whose instances should load all their weights (even in the submodules) at the beginning | |
| of the forward. This should only be used for classes that have submodules which are registered but not | |
| called directly during the forward, for instance if a <code>dense</code> linear layer is registered, but at forward, | |
| <code>dense.weight</code> and <code>dense.bias</code> are used in some operations instead of calling <code>dense</code> directly.`,name:"preload_module_classes"},{anchor:"accelerate.hooks.attach_execution_device_hook.tied_params_map",description:`<strong>tied_params_map</strong> (Optional[Dict[int, Dict[torch.device, torch.Tensor]]], <em>optional</em>, defaults to <code>None</code>) — | |
| A map of data pointers to dictionaries of devices to already dispatched tied weights. For a given execution | |
| device, this parameter is useful to reuse the first available pointer of a shared weight for all others, | |
| instead of duplicating memory.`,name:"tied_params_map"}],source:"https://github.com/huggingface/accelerate/blob/main/src/accelerate/hooks.py#L400"}}),Ze=new x({props:{title:"attach_align_device_hook",local:"accelerate.hooks.attach_align_device_hook",headingTag:"h3"}}),Ne=new T({props:{name:"accelerate.hooks.attach_align_device_hook",anchor:"accelerate.hooks.attach_align_device_hook",parameters:[{name:"module",val:": Module"},{name:"execution_device",val:": Optional = None"},{name:"offload",val:": bool = False"},{name:"weights_map",val:": Optional = None"},{name:"offload_buffers",val:": bool = False"},{name:"module_name",val:": str = ''"},{name:"skip_keys",val:": Union = None"},{name:"preload_module_classes",val:": Optional = None"},{name:"tied_params_map",val:": Optional = None"}],parametersDescription:[{anchor:"accelerate.hooks.attach_align_device_hook.module",description:`<strong>module</strong> (<code>torch.nn.Module</code>) — | |
| The module where we want to attach the hooks.`,name:"module"},{anchor:"accelerate.hooks.attach_align_device_hook.execution_device",description:`<strong>execution_device</strong> (<code>torch.device</code>, <em>optional</em>) — | |
| The device on which inputs and model weights should be placed before the forward pass.`,name:"execution_device"},{anchor:"accelerate.hooks.attach_align_device_hook.offload",description:`<strong>offload</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) — | |
| Whether or not the weights should be offloaded after the forward pass.`,name:"offload"},{anchor:"accelerate.hooks.attach_align_device_hook.weights_map",description:`<strong>weights_map</strong> (<code>Mapping[str, torch.Tensor]</code>, <em>optional</em>) — | |
| When the model weights are offloaded, a (potentially lazy) map from param names to the tensor values.`,name:"weights_map"},{anchor:"accelerate.hooks.attach_align_device_hook.offload_buffers",description:`<strong>offload_buffers</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) — | |
| Whether or not to include the associated module’s buffers when offloading.`,name:"offload_buffers"},{anchor:"accelerate.hooks.attach_align_device_hook.module_name",description:`<strong>module_name</strong> (<code>str</code>, <em>optional</em>, defaults to <code>""</code>) — | |
| The name of the module.`,name:"module_name"},{anchor:"accelerate.hooks.attach_align_device_hook.skip_keys",description:`<strong>skip_keys</strong> (<code>str</code> or <code>List[str]</code>, <em>optional</em>) — | |
| A list of keys to ignore when moving inputs or outputs between devices.`,name:"skip_keys"},{anchor:"accelerate.hooks.attach_align_device_hook.preload_module_classes",description:`<strong>preload_module_classes</strong> (<code>List[str]</code>, <em>optional</em>) — | |
| A list of classes whose instances should load all their weights (even in the submodules) at the beginning | |
| of the forward. This should only be used for classes that have submodules which are registered but not | |
| called directly during the forward, for instance if a <code>dense</code> linear layer is registered, but at forward, | |
| <code>dense.weight</code> and <code>dense.bias</code> are used in some operations instead of calling <code>dense</code> directly.`,name:"preload_module_classes"},{anchor:"accelerate.hooks.attach_align_device_hook.tied_params_map",description:`<strong>tied_params_map</strong> (Optional[Dict[int, Dict[torch.device, torch.Tensor]]], <em>optional</em>, defaults to <code>None</code>) — | |
| A map of data pointers to dictionaries of devices to already dispatched tied weights. For a given execution | |
| device, this parameter is useful to reuse the first available pointer of a shared weight for all others, | |
| instead of duplicating memory.`,name:"tied_params_map"}],source:"https://github.com/huggingface/accelerate/blob/main/src/accelerate/hooks.py#L442"}}),Pe=new x({props:{title:"attach_align_device_hook_on_blocks",local:"accelerate.hooks.attach_align_device_hook_on_blocks",headingTag:"h3"}}),Ve=new T({props:{name:"accelerate.hooks.attach_align_device_hook_on_blocks",anchor:"accelerate.hooks.attach_align_device_hook_on_blocks",parameters:[{name:"module",val:": Module"},{name:"execution_device",val:": Union = None"},{name:"offload",val:": Union = False"},{name:"weights_map",val:": Mapping = None"},{name:"offload_buffers",val:": bool = False"},{name:"module_name",val:": str = ''"},{name:"skip_keys",val:": Union = None"},{name:"preload_module_classes",val:": Optional = None"},{name:"tied_params_map",val:": Optional = None"}],parametersDescription:[{anchor:"accelerate.hooks.attach_align_device_hook_on_blocks.module",description:`<strong>module</strong> (<code>torch.nn.Module</code>) — | |
| The module where we want to attach the hooks.`,name:"module"},{anchor:"accelerate.hooks.attach_align_device_hook_on_blocks.execution_device",description:`<strong>execution_device</strong> (<code>torch.device</code> or <code>Dict[str, torch.device]</code>, <em>optional</em>) — | |
| The device on which inputs and model weights should be placed before the forward pass. It can be one device | |
| for the whole module, or a dictionary mapping module name to device.`,name:"execution_device"},{anchor:"accelerate.hooks.attach_align_device_hook_on_blocks.offload",description:`<strong>offload</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) — | |
| Whether or not the weights should be offloaded after the forward pass. It can be one boolean for the whole | |
| module, or a dictionary mapping module name to boolean.`,name:"offload"},{anchor:"accelerate.hooks.attach_align_device_hook_on_blocks.weights_map",description:`<strong>weights_map</strong> (<code>Mapping[str, torch.Tensor]</code>, <em>optional</em>) — | |
| When the model weights are offloaded, a (potentially lazy) map from param names to the tensor values.`,name:"weights_map"},{anchor:"accelerate.hooks.attach_align_device_hook_on_blocks.offload_buffers",description:`<strong>offload_buffers</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) — | |
| Whether or not to include the associated module’s buffers when offloading.`,name:"offload_buffers"},{anchor:"accelerate.hooks.attach_align_device_hook_on_blocks.module_name",description:`<strong>module_name</strong> (<code>str</code>, <em>optional</em>, defaults to <code>""</code>) — | |
| The name of the module.`,name:"module_name"},{anchor:"accelerate.hooks.attach_align_device_hook_on_blocks.skip_keys",description:`<strong>skip_keys</strong> (<code>str</code> or <code>List[str]</code>, <em>optional</em>) — | |
| A list of keys to ignore when moving inputs or outputs between devices.`,name:"skip_keys"},{anchor:"accelerate.hooks.attach_align_device_hook_on_blocks.preload_module_classes",description:`<strong>preload_module_classes</strong> (<code>List[str]</code>, <em>optional</em>) — | |
| A list of classes whose instances should load all their weights (even in the submodules) at the beginning | |
| of the forward. This should only be used for classes that have submodules which are registered but not | |
| called directly during the forward, for instance if a <code>dense</code> linear layer is registered, but at forward, | |
| <code>dense.weight</code> and <code>dense.bias</code> are used in some operations instead of calling <code>dense</code> directly.`,name:"preload_module_classes"},{anchor:"accelerate.hooks.attach_align_device_hook_on_blocks.tied_params_map",description:`<strong>tied_params_map</strong> (Optional[Dict[int, Dict[torch.device, torch.Tensor]]], <em>optional</em>, defaults to <code>None</code>) — | |
| A map of data pointers to dictionaries of devices to already dispatched tied weights. For a given execution | |
| device, this parameter is useful to reuse the first available pointer of a shared weight for all others, | |
| instead of duplicating memory.`,name:"tied_params_map"}],source:"https://github.com/huggingface/accelerate/blob/main/src/accelerate/hooks.py#L537"}}),Re=new x({props:{title:"Removing Hooks",local:"removing-hooks",headingTag:"h2"}}),Ee=new x({props:{title:"remove_hook_from_module",local:"accelerate.hooks.remove_hook_from_module",headingTag:"h3"}}),ze=new T({props:{name:"accelerate.hooks.remove_hook_from_module",anchor:"accelerate.hooks.remove_hook_from_module",parameters:[{name:"module",val:": Module"},{name:"recurse",val:" = False"}],parametersDescription:[{anchor:"accelerate.hooks.remove_hook_from_module.module",description:"<strong>module</strong> (<code>torch.nn.Module</code>) — The module to attach a hook to.",name:"module"},{anchor:"accelerate.hooks.remove_hook_from_module.recurse",description:"<strong>recurse</strong> (<code>bool</code>, <strong>optional</strong>) — Whether to remove the hooks recursively",name:"recurse"}],source:"https://github.com/huggingface/accelerate/blob/main/src/accelerate/hooks.py#L183",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>The same module, with the hook detached (the module is modified in place, so the result can | |
| be discarded).</p> | |
| `,returnType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><code>torch.nn.Module</code></p> | |
| `}}),Xe=new x({props:{title:"remove_hook_from_submodules",local:"accelerate.hooks.remove_hook_from_submodules",headingTag:"h3"}}),qe=new T({props:{name:"accelerate.hooks.remove_hook_from_submodules",anchor:"accelerate.hooks.remove_hook_from_submodules",parameters:[{name:"module",val:": Module"}],parametersDescription:[{anchor:"accelerate.hooks.remove_hook_from_submodules.module",description:"<strong>module</strong> (<code>torch.nn.Module</code>) — The module on which to remove all hooks.",name:"module"}],source:"https://github.com/huggingface/accelerate/blob/main/src/accelerate/hooks.py#L525"}}),Se=new Ba({props:{source:"https://github.com/huggingface/accelerate/blob/main/docs/source/package_reference/big_modeling.md"}}),{c(){d=c("meta"),k=a(),g=c("p"),v=a(),i(y.$$.fragment),u=a(),i(U.$$.fragment),Uo=a(),i(ce.$$.fragment),Co=a(),J=c("div"),i(re.$$.fragment),Mt=a(),eo=c("p"),eo.textContent=ca,Tt=a(),i(Q.$$.fragment),Ut=a(),i(O.$$.fragment),jo=a(),i(ie.$$.fragment),Jo=a(),B=c("div"),i(he.$$.fragment),Ct=a(),oo=c("p"),oo.textContent=ra,Io=a(),i(me.$$.fragment),Go=a(),G=c("div"),i(pe.$$.fragment),jt=a(),to=c("p"),to.innerHTML=ia,Jt=a(),i(Y.$$.fragment),Do=a(),i(fe.$$.fragment),Wo=a(),L=c("div"),i(_e.$$.fragment),It=a(),ao=c("p"),ao.textContent=ha,Ho=a(),i(ue.$$.fragment),Fo=a(),A=c("div"),i(ge.$$.fragment),Gt=a(),no=c("p"),no.textContent=ma,Bo=a(),i(ve.$$.fragment),Lo=a(),D=c("div"),i(be.$$.fragment),Dt=a(),lo=c("p"),lo.textContent=pa,Wt=a(),i(K.$$.fragment),Ao=a(),i(ke.$$.fragment),Zo=a(),W=c("div"),i($e.$$.fragment),Ht=a(),so=c("p"),so.textContent=fa,Ft=a(),i(ee.$$.fragment),No=a(),i(we.$$.fragment),Po=a(),I=c("div"),i(ye.$$.fragment),Bt=a(),co=c("p"),co.textContent=_a,Lt=a(),ro=c("ul"),ro.innerHTML=ua,At=a(),i(oe.$$.fragment),Vo=a(),i(xe.$$.fragment),Ro=a(),i(Me.$$.fragment),Eo=a(),M=c("div"),i(Te.$$.fragment),Zt=a(),io=c("p"),io.textContent=ga,Nt=a(),ho=c("p"),ho.textContent=va,Pt=a(),mo=c("ul"),mo.innerHTML=ba,Vt=a(),te=c("div"),i(Ue.$$.fragment),Rt=a(),po=c("p"),po.textContent=ka,Et=a(),ae=c("div"),i(Ce.$$.fragment),zt=a(),fo=c("p"),fo.textContent=$a,Xt=a(),ne=c("div"),i(je.$$.fragment),qt=a(),_o=c("p"),_o.textContent=wa,St=a(),le=c("div"),i(Je.$$.fragment),Qt=a(),uo=c("p"),uo.textContent=ya,zo=a(),i(Ie.$$.fragment),Xo=a(),Z=c("div"),i(Ge.$$.fragment),Ot=a(),go=c("p"),go.innerHTML=xa,qo=a(),i(De.$$.fragment),So=a(),N=c("div"),i(We.$$.fragment),Yt=a(),vo=c("p"),vo.textContent=Ma,Qo=a(),i(He.$$.fragment),Oo=a(),i(Fe.$$.fragment),Yo=a(),H=c("div"),i(Be.$$.fragment),Kt=a(),bo=c("p"),bo.innerHTML=Ta,ea=a(),i(de.$$.fragment),Ko=a(),i(Le.$$.fragment),et=a(),P=c("div"),i(Ae.$$.fragment),oa=a(),ko=c("p"),ko.innerHTML=Ua,ot=a(),i(Ze.$$.fragment),tt=a(),V=c("div"),i(Ne.$$.fragment),ta=a(),$o=c("p"),$o.innerHTML=Ca,at=a(),i(Pe.$$.fragment),nt=a(),R=c("div"),i(Ve.$$.fragment),aa=a(),wo=c("p"),wo.innerHTML=ja,lt=a(),i(Re.$$.fragment),dt=a(),i(Ee.$$.fragment),st=a(),E=c("div"),i(ze.$$.fragment),na=a(),yo=c("p"),yo.innerHTML=Ja,ct=a(),i(Xe.$$.fragment),rt=a(),z=c("div"),i(qe.$$.fragment),la=a(),xo=c("p"),xo.textContent=Ia,it=a(),i(Se.$$.fragment),ht=a(),To=c("p"),this.h()},l(e){const o=Fa("svelte-u9bgzb",document.head);d=r(o,"META",{name:!0,content:!0}),o.forEach(t),k=n(e),g=r(e,"P",{}),$(g).forEach(t),v=n(e),h(y.$$.fragment,e),u=n(e),h(U.$$.fragment,e),Uo=n(e),h(ce.$$.fragment,e),Co=n(e),J=r(e,"DIV",{class:!0});var F=$(J);h(re.$$.fragment,F),Mt=n(F),eo=r(F,"P",{"data-svelte-h":!0}),b(eo)!=="svelte-1u5mepw"&&(eo.textContent=ca),Tt=n(F),h(Q.$$.fragment,F),Ut=n(F),h(O.$$.fragment,F),F.forEach(t),jo=n(e),h(ie.$$.fragment,e),Jo=n(e),B=r(e,"DIV",{class:!0});var Qe=$(B);h(he.$$.fragment,Qe),Ct=n(Qe),oo=r(Qe,"P",{"data-svelte-h":!0}),b(oo)!=="svelte-1gp9ghs"&&(oo.textContent=ra),Qe.forEach(t),Io=n(e),h(me.$$.fragment,e),Go=n(e),G=r(e,"DIV",{class:!0});var X=$(G);h(pe.$$.fragment,X),jt=n(X),to=r(X,"P",{"data-svelte-h":!0}),b(to)!=="svelte-6j2oun"&&(to.innerHTML=ia),Jt=n(X),h(Y.$$.fragment,X),X.forEach(t),Do=n(e),h(fe.$$.fragment,e),Wo=n(e),L=r(e,"DIV",{class:!0});var Oe=$(L);h(_e.$$.fragment,Oe),It=n(Oe),ao=r(Oe,"P",{"data-svelte-h":!0}),b(ao)!=="svelte-js7ro5"&&(ao.textContent=ha),Oe.forEach(t),Ho=n(e),h(ue.$$.fragment,e),Fo=n(e),A=r(e,"DIV",{class:!0});var Ye=$(A);h(ge.$$.fragment,Ye),Gt=n(Ye),no=r(Ye,"P",{"data-svelte-h":!0}),b(no)!=="svelte-1p13mzc"&&(no.textContent=ma),Ye.forEach(t),Bo=n(e),h(ve.$$.fragment,e),Lo=n(e),D=r(e,"DIV",{class:!0});var q=$(D);h(be.$$.fragment,q),Dt=n(q),lo=r(q,"P",{"data-svelte-h":!0}),b(lo)!=="svelte-1ikrez4"&&(lo.textContent=pa),Wt=n(q),h(K.$$.fragment,q),q.forEach(t),Ao=n(e),h(ke.$$.fragment,e),Zo=n(e),W=r(e,"DIV",{class:!0});var S=$(W);h($e.$$.fragment,S),Ht=n(S),so=r(S,"P",{"data-svelte-h":!0}),b(so)!=="svelte-qft9nv"&&(so.textContent=fa),Ft=n(S),h(ee.$$.fragment,S),S.forEach(t),No=n(e),h(we.$$.fragment,e),Po=n(e),I=r(e,"DIV",{class:!0});var se=$(I);h(ye.$$.fragment,se),Bt=n(se),co=r(se,"P",{"data-svelte-h":!0}),b(co)!=="svelte-ou57jw"&&(co.textContent=_a),Lt=n(se),ro=r(se,"UL",{"data-svelte-h":!0}),b(ro)!=="svelte-17tb5w2"&&(ro.innerHTML=ua),At=n(se),h(oe.$$.fragment,se),se.forEach(t),Vo=n(e),h(xe.$$.fragment,e),Ro=n(e),h(Me.$$.fragment,e),Eo=n(e),M=r(e,"DIV",{class:!0});var j=$(M);h(Te.$$.fragment,j),Zt=n(j),io=r(j,"P",{"data-svelte-h":!0}),b(io)!=="svelte-jjeczj"&&(io.textContent=ga),Nt=n(j),ho=r(j,"P",{"data-svelte-h":!0}),b(ho)!=="svelte-1aqkkwa"&&(ho.textContent=va),Pt=n(j),mo=r(j,"UL",{"data-svelte-h":!0}),b(mo)!=="svelte-1ny2lfh"&&(mo.innerHTML=ba),Vt=n(j),te=r(j,"DIV",{class:!0});var pt=$(te);h(Ue.$$.fragment,pt),Rt=n(pt),po=r(pt,"P",{"data-svelte-h":!0}),b(po)!=="svelte-13obmts"&&(po.textContent=ka),pt.forEach(t),Et=n(j),ae=r(j,"DIV",{class:!0});var ft=$(ae);h(Ce.$$.fragment,ft),zt=n(ft),fo=r(ft,"P",{"data-svelte-h":!0}),b(fo)!=="svelte-2npthr"&&(fo.textContent=$a),ft.forEach(t),Xt=n(j),ne=r(j,"DIV",{class:!0});var _t=$(ne);h(je.$$.fragment,_t),qt=n(_t),_o=r(_t,"P",{"data-svelte-h":!0}),b(_o)!=="svelte-17hlov5"&&(_o.textContent=wa),_t.forEach(t),St=n(j),le=r(j,"DIV",{class:!0});var ut=$(le);h(Je.$$.fragment,ut),Qt=n(ut),uo=r(ut,"P",{"data-svelte-h":!0}),b(uo)!=="svelte-53qfnq"&&(uo.textContent=ya),ut.forEach(t),j.forEach(t),zo=n(e),h(Ie.$$.fragment,e),Xo=n(e),Z=r(e,"DIV",{class:!0});var gt=$(Z);h(Ge.$$.fragment,gt),Ot=n(gt),go=r(gt,"P",{"data-svelte-h":!0}),b(go)!=="svelte-15d0s2c"&&(go.innerHTML=xa),gt.forEach(t),qo=n(e),h(De.$$.fragment,e),So=n(e),N=r(e,"DIV",{class:!0});var vt=$(N);h(We.$$.fragment,vt),Yt=n(vt),vo=r(vt,"P",{"data-svelte-h":!0}),b(vo)!=="svelte-kxjaug"&&(vo.textContent=Ma),vt.forEach(t),Qo=n(e),h(He.$$.fragment,e),Oo=n(e),h(Fe.$$.fragment,e),Yo=n(e),H=r(e,"DIV",{class:!0});var Mo=$(H);h(Be.$$.fragment,Mo),Kt=n(Mo),bo=r(Mo,"P",{"data-svelte-h":!0}),b(bo)!=="svelte-12byttf"&&(bo.innerHTML=Ta),ea=n(Mo),h(de.$$.fragment,Mo),Mo.forEach(t),Ko=n(e),h(Le.$$.fragment,e),et=n(e),P=r(e,"DIV",{class:!0});var bt=$(P);h(Ae.$$.fragment,bt),oa=n(bt),ko=r(bt,"P",{"data-svelte-h":!0}),b(ko)!=="svelte-rf1vym"&&(ko.innerHTML=Ua),bt.forEach(t),ot=n(e),h(Ze.$$.fragment,e),tt=n(e),V=r(e,"DIV",{class:!0});var kt=$(V);h(Ne.$$.fragment,kt),ta=n(kt),$o=r(kt,"P",{"data-svelte-h":!0}),b($o)!=="svelte-5orloz"&&($o.innerHTML=Ca),kt.forEach(t),at=n(e),h(Pe.$$.fragment,e),nt=n(e),R=r(e,"DIV",{class:!0});var $t=$(R);h(Ve.$$.fragment,$t),aa=n($t),wo=r($t,"P",{"data-svelte-h":!0}),b(wo)!=="svelte-1anoa02"&&(wo.innerHTML=ja),$t.forEach(t),lt=n(e),h(Re.$$.fragment,e),dt=n(e),h(Ee.$$.fragment,e),st=n(e),E=r(e,"DIV",{class:!0});var wt=$(E);h(ze.$$.fragment,wt),na=n(wt),yo=r(wt,"P",{"data-svelte-h":!0}),b(yo)!=="svelte-1kj8409"&&(yo.innerHTML=Ja),wt.forEach(t),ct=n(e),h(Xe.$$.fragment,e),rt=n(e),z=r(e,"DIV",{class:!0});var yt=$(z);h(qe.$$.fragment,yt),la=n(yt),xo=r(yt,"P",{"data-svelte-h":!0}),b(xo)!=="svelte-xlirjm"&&(xo.textContent=Ia),yt.forEach(t),it=n(e),h(Se.$$.fragment,e),ht=n(e),To=r(e,"P",{}),$(To).forEach(t),this.h()},h(){w(d,"name","hf:doc:metadata"),w(d,"content",za),w(J,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),w(B,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),w(G,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),w(L,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),w(A,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),w(D,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),w(W,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),w(I,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),w(te,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),w(ae,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),w(ne,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),w(le,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),w(M,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),w(Z,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),w(N,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),w(H,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),w(P,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),w(V,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),w(R,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),w(E,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),w(z,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(e,o){s(document.head,d),l(e,k,o),l(e,g,o),l(e,v,o),m(y,e,o),l(e,u,o),m(U,e,o),l(e,Uo,o),m(ce,e,o),l(e,Co,o),l(e,J,o),m(re,J,null),s(J,Mt),s(J,eo),s(J,Tt),m(Q,J,null),s(J,Ut),m(O,J,null),l(e,jo,o),m(ie,e,o),l(e,Jo,o),l(e,B,o),m(he,B,null),s(B,Ct),s(B,oo),l(e,Io,o),m(me,e,o),l(e,Go,o),l(e,G,o),m(pe,G,null),s(G,jt),s(G,to),s(G,Jt),m(Y,G,null),l(e,Do,o),m(fe,e,o),l(e,Wo,o),l(e,L,o),m(_e,L,null),s(L,It),s(L,ao),l(e,Ho,o),m(ue,e,o),l(e,Fo,o),l(e,A,o),m(ge,A,null),s(A,Gt),s(A,no),l(e,Bo,o),m(ve,e,o),l(e,Lo,o),l(e,D,o),m(be,D,null),s(D,Dt),s(D,lo),s(D,Wt),m(K,D,null),l(e,Ao,o),m(ke,e,o),l(e,Zo,o),l(e,W,o),m($e,W,null),s(W,Ht),s(W,so),s(W,Ft),m(ee,W,null),l(e,No,o),m(we,e,o),l(e,Po,o),l(e,I,o),m(ye,I,null),s(I,Bt),s(I,co),s(I,Lt),s(I,ro),s(I,At),m(oe,I,null),l(e,Vo,o),m(xe,e,o),l(e,Ro,o),m(Me,e,o),l(e,Eo,o),l(e,M,o),m(Te,M,null),s(M,Zt),s(M,io),s(M,Nt),s(M,ho),s(M,Pt),s(M,mo),s(M,Vt),s(M,te),m(Ue,te,null),s(te,Rt),s(te,po),s(M,Et),s(M,ae),m(Ce,ae,null),s(ae,zt),s(ae,fo),s(M,Xt),s(M,ne),m(je,ne,null),s(ne,qt),s(ne,_o),s(M,St),s(M,le),m(Je,le,null),s(le,Qt),s(le,uo),l(e,zo,o),m(Ie,e,o),l(e,Xo,o),l(e,Z,o),m(Ge,Z,null),s(Z,Ot),s(Z,go),l(e,qo,o),m(De,e,o),l(e,So,o),l(e,N,o),m(We,N,null),s(N,Yt),s(N,vo),l(e,Qo,o),m(He,e,o),l(e,Oo,o),m(Fe,e,o),l(e,Yo,o),l(e,H,o),m(Be,H,null),s(H,Kt),s(H,bo),s(H,ea),m(de,H,null),l(e,Ko,o),m(Le,e,o),l(e,et,o),l(e,P,o),m(Ae,P,null),s(P,oa),s(P,ko),l(e,ot,o),m(Ze,e,o),l(e,tt,o),l(e,V,o),m(Ne,V,null),s(V,ta),s(V,$o),l(e,at,o),m(Pe,e,o),l(e,nt,o),l(e,R,o),m(Ve,R,null),s(R,aa),s(R,wo),l(e,lt,o),m(Re,e,o),l(e,dt,o),m(Ee,e,o),l(e,st,o),l(e,E,o),m(ze,E,null),s(E,na),s(E,yo),l(e,ct,o),m(Xe,e,o),l(e,rt,o),l(e,z,o),m(qe,z,null),s(z,la),s(z,xo),l(e,it,o),m(Se,e,o),l(e,ht,o),l(e,To,o),mt=!0},p(e,[o]){const F={};o&2&&(F.$$scope={dirty:o,ctx:e}),Q.$set(F);const Qe={};o&2&&(Qe.$$scope={dirty:o,ctx:e}),O.$set(Qe);const X={};o&2&&(X.$$scope={dirty:o,ctx:e}),Y.$set(X);const Oe={};o&2&&(Oe.$$scope={dirty:o,ctx:e}),K.$set(Oe);const Ye={};o&2&&(Ye.$$scope={dirty:o,ctx:e}),ee.$set(Ye);const q={};o&2&&(q.$$scope={dirty:o,ctx:e}),oe.$set(q);const S={};o&2&&(S.$$scope={dirty:o,ctx:e}),de.$set(S)},i(e){mt||(p(y.$$.fragment,e),p(U.$$.fragment,e),p(ce.$$.fragment,e),p(re.$$.fragment,e),p(Q.$$.fragment,e),p(O.$$.fragment,e),p(ie.$$.fragment,e),p(he.$$.fragment,e),p(me.$$.fragment,e),p(pe.$$.fragment,e),p(Y.$$.fragment,e),p(fe.$$.fragment,e),p(_e.$$.fragment,e),p(ue.$$.fragment,e),p(ge.$$.fragment,e),p(ve.$$.fragment,e),p(be.$$.fragment,e),p(K.$$.fragment,e),p(ke.$$.fragment,e),p($e.$$.fragment,e),p(ee.$$.fragment,e),p(we.$$.fragment,e),p(ye.$$.fragment,e),p(oe.$$.fragment,e),p(xe.$$.fragment,e),p(Me.$$.fragment,e),p(Te.$$.fragment,e),p(Ue.$$.fragment,e),p(Ce.$$.fragment,e),p(je.$$.fragment,e),p(Je.$$.fragment,e),p(Ie.$$.fragment,e),p(Ge.$$.fragment,e),p(De.$$.fragment,e),p(We.$$.fragment,e),p(He.$$.fragment,e),p(Fe.$$.fragment,e),p(Be.$$.fragment,e),p(de.$$.fragment,e),p(Le.$$.fragment,e),p(Ae.$$.fragment,e),p(Ze.$$.fragment,e),p(Ne.$$.fragment,e),p(Pe.$$.fragment,e),p(Ve.$$.fragment,e),p(Re.$$.fragment,e),p(Ee.$$.fragment,e),p(ze.$$.fragment,e),p(Xe.$$.fragment,e),p(qe.$$.fragment,e),p(Se.$$.fragment,e),mt=!0)},o(e){f(y.$$.fragment,e),f(U.$$.fragment,e),f(ce.$$.fragment,e),f(re.$$.fragment,e),f(Q.$$.fragment,e),f(O.$$.fragment,e),f(ie.$$.fragment,e),f(he.$$.fragment,e),f(me.$$.fragment,e),f(pe.$$.fragment,e),f(Y.$$.fragment,e),f(fe.$$.fragment,e),f(_e.$$.fragment,e),f(ue.$$.fragment,e),f(ge.$$.fragment,e),f(ve.$$.fragment,e),f(be.$$.fragment,e),f(K.$$.fragment,e),f(ke.$$.fragment,e),f($e.$$.fragment,e),f(ee.$$.fragment,e),f(we.$$.fragment,e),f(ye.$$.fragment,e),f(oe.$$.fragment,e),f(xe.$$.fragment,e),f(Me.$$.fragment,e),f(Te.$$.fragment,e),f(Ue.$$.fragment,e),f(Ce.$$.fragment,e),f(je.$$.fragment,e),f(Je.$$.fragment,e),f(Ie.$$.fragment,e),f(Ge.$$.fragment,e),f(De.$$.fragment,e),f(We.$$.fragment,e),f(He.$$.fragment,e),f(Fe.$$.fragment,e),f(Be.$$.fragment,e),f(de.$$.fragment,e),f(Le.$$.fragment,e),f(Ae.$$.fragment,e),f(Ze.$$.fragment,e),f(Ne.$$.fragment,e),f(Pe.$$.fragment,e),f(Ve.$$.fragment,e),f(Re.$$.fragment,e),f(Ee.$$.fragment,e),f(ze.$$.fragment,e),f(Xe.$$.fragment,e),f(qe.$$.fragment,e),f(Se.$$.fragment,e),mt=!1},d(e){e&&(t(k),t(g),t(v),t(u),t(Uo),t(Co),t(J),t(jo),t(Jo),t(B),t(Io),t(Go),t(G),t(Do),t(Wo),t(L),t(Ho),t(Fo),t(A),t(Bo),t(Lo),t(D),t(Ao),t(Zo),t(W),t(No),t(Po),t(I),t(Vo),t(Ro),t(Eo),t(M),t(zo),t(Xo),t(Z),t(qo),t(So),t(N),t(Qo),t(Oo),t(Yo),t(H),t(Ko),t(et),t(P),t(ot),t(tt),t(V),t(at),t(nt),t(R),t(lt),t(dt),t(st),t(E),t(ct),t(rt),t(z),t(it),t(ht),t(To)),t(d),_(y,e),_(U,e),_(ce,e),_(re),_(Q),_(O),_(ie,e),_(he),_(me,e),_(pe),_(Y),_(fe,e),_(_e),_(ue,e),_(ge),_(ve,e),_(be),_(K),_(ke,e),_($e),_(ee),_(we,e),_(ye),_(oe),_(xe,e),_(Me,e),_(Te),_(Ue),_(Ce),_(je),_(Je),_(Ie,e),_(Ge),_(De,e),_(We),_(He,e),_(Fe,e),_(Be),_(de),_(Le,e),_(Ae),_(Ze,e),_(Ne),_(Pe,e),_(Ve),_(Re,e),_(Ee,e),_(ze),_(Xe,e),_(qe),_(Se,e)}}}const za='{"title":"Working with large models","local":"working-with-large-models","sections":[{"title":"Dispatch and offload","local":"dispatch-and-offload","sections":[{"title":"init_empty_weights","local":"accelerate.init_empty_weights","sections":[],"depth":3},{"title":"cpu_offload","local":"accelerate.cpu_offload","sections":[],"depth":3},{"title":"cpu_offload_with_hook","local":"accelerate.cpu_offload_with_hook","sections":[],"depth":3},{"title":"disk_offload","local":"accelerate.disk_offload","sections":[],"depth":3},{"title":"dispatch_model","local":"accelerate.dispatch_model","sections":[],"depth":3},{"title":"load_checkpoint_and_dispatch","local":"accelerate.load_checkpoint_and_dispatch","sections":[],"depth":3},{"title":"load_checkpoint_in_model","local":"accelerate.load_checkpoint_in_model","sections":[],"depth":3},{"title":"infer_auto_device_map","local":"accelerate.infer_auto_device_map","sections":[],"depth":3}],"depth":2},{"title":"Hooks","local":"hooks","sections":[{"title":"ModelHook","local":"accelerate.hooks.ModelHook","sections":[],"depth":3},{"title":"AlignDevicesHook","local":"accelerate.hooks.AlignDevicesHook","sections":[],"depth":3},{"title":"SequentialHook","local":"accelerate.hooks.SequentialHook","sections":[],"depth":3}],"depth":2},{"title":"Adding Hooks","local":"adding-hooks","sections":[{"title":"add_hook_to_module","local":"accelerate.hooks.add_hook_to_module","sections":[],"depth":3},{"title":"attach_execution_device_hook","local":"accelerate.hooks.attach_execution_device_hook","sections":[],"depth":3},{"title":"attach_align_device_hook","local":"accelerate.hooks.attach_align_device_hook","sections":[],"depth":3},{"title":"attach_align_device_hook_on_blocks","local":"accelerate.hooks.attach_align_device_hook_on_blocks","sections":[],"depth":3}],"depth":2},{"title":"Removing Hooks","local":"removing-hooks","sections":[{"title":"remove_hook_from_module","local":"accelerate.hooks.remove_hook_from_module","sections":[],"depth":3},{"title":"remove_hook_from_submodules","local":"accelerate.hooks.remove_hook_from_submodules","sections":[],"depth":3}],"depth":2}],"depth":1}';function Xa(C){return Da(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class on extends Wa{constructor(d){super(),Ha(this,d,Xa,Ea,Ga,{})}}export{on as component}; | |
Xet Storage Details
- Size:
- 75.2 kB
- Xet hash:
- b1241162d62a29a4713eb5adcadf893203c6e1b6a177696b706036c437a88cec
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.