Buckets:
| import{s as ea,o as oa,n as Fe}from"../chunks/scheduler.defa9a21.js";import{S as ta,i as aa,g as d,s,r as m,A as na,h as r,f as o,c as l,j as w,u as p,x as b,k as y,y as n,a as c,v as f,d as u,t as _,w as g}from"../chunks/index.fe795e71.js";import{T as zo}from"../chunks/Tip.179eb360.js";import{D as M}from"../chunks/Docstring.170994c1.js";import{C as jt}from"../chunks/CodeBlock.42404125.js";import{E as Ct}from"../chunks/ExampleCodeBlock.53569e06.js";import{H as co,E as sa}from"../chunks/EditOnGithub.0f575778.js";function la(U){let a,k="Example:",h,v,$;return v=new jt({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(){a=d("p"),a.textContent=k,h=s(),m(v.$$.fragment)},l(i){a=r(i,"P",{"data-svelte-h":!0}),b(a)!=="svelte-11lpom8"&&(a.textContent=k),h=l(i),p(v.$$.fragment,i)},m(i,T){c(i,a,T),c(i,h,T),f(v,i,T),$=!0},p:Fe,i(i){$||(u(v.$$.fragment,i),$=!0)},o(i){_(v.$$.fragment,i),$=!1},d(i){i&&(o(a),o(h)),g(v,i)}}}function da(U){let a,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(){a=d("p"),a.innerHTML=k},l(h){a=r(h,"P",{"data-svelte-h":!0}),b(a)!=="svelte-18rw2wy"&&(a.innerHTML=k)},m(h,v){c(h,a,v)},p:Fe,d(h){h&&o(a)}}}function ra(U){let a,k="Example:",h,v,$;return v=new jt({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(){a=d("p"),a.textContent=k,h=s(),m(v.$$.fragment)},l(i){a=r(i,"P",{"data-svelte-h":!0}),b(a)!=="svelte-11lpom8"&&(a.textContent=k),h=l(i),p(v.$$.fragment,i)},m(i,T){c(i,a,T),c(i,h,T),f(v,i,T),$=!0},p:Fe,i(i){$||(u(v.$$.fragment,i),$=!0)},o(i){_(v.$$.fragment,i),$=!1},d(i){i&&(o(a),o(h)),g(v,i)}}}function ca(U){let a,k="Example:",h,v,$;return v=new jt({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(){a=d("p"),a.textContent=k,h=s(),m(v.$$.fragment)},l(i){a=r(i,"P",{"data-svelte-h":!0}),b(a)!=="svelte-11lpom8"&&(a.textContent=k),h=l(i),p(v.$$.fragment,i)},m(i,T){c(i,a,T),c(i,h,T),f(v,i,T),$=!0},p:Fe,i(i){$||(u(v.$$.fragment,i),$=!0)},o(i){_(v.$$.fragment,i),$=!1},d(i){i&&(o(a),o(h)),g(v,i)}}}function ia(U){let a,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(){a=d("p"),a.innerHTML=k},l(h){a=r(h,"P",{"data-svelte-h":!0}),b(a)!=="svelte-13sragn"&&(a.innerHTML=k)},m(h,v){c(h,a,v)},p:Fe,d(h){h&&o(a)}}}function ha(U){let a,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(){a=d("p"),a.innerHTML=k},l(h){a=r(h,"P",{"data-svelte-h":!0}),b(a)!=="svelte-1d9m3bn"&&(a.innerHTML=k)},m(h,v){c(h,a,v)},p:Fe,d(h){h&&o(a)}}}function ma(U){let a,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(){a=d("p"),a.innerHTML=k},l(h){a=r(h,"P",{"data-svelte-h":!0}),b(a)!=="svelte-1dclc89"&&(a.innerHTML=k)},m(h,v){c(h,a,v)},p:Fe,d(h){h&&o(a)}}}function pa(U){let a,k,h,v,$,i,T,ho,j,de,Xo,Be,Jt=`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.`,qo,Q,Qo,O,mo,F,re,Oo,Le,It=`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.`,po,I,ce,So,Ze,Gt=`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.`,Yo,S,fo,B,ie,Ko,Ae,Wt=`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.`,uo,L,he,et,Ne,Dt=`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.`,_o,G,me,ot,Pe,Ht=`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).`,tt,Y,go,W,pe,at,Ve,Ft=`Loads a (potentially sharded) checkpoint inside a model, potentially sending weights to a given device as they are | |
| loaded.`,nt,K,vo,J,fe,st,Re,Bt=`Compute a device map for a given model giving priority to GPUs, then offload on CPU and finally offload to disk, | |
| such that:`,lt,Ee,Lt=`<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>`,dt,ee,bo,ue,ko,_e,wo,x,ge,rt,ze,Zt=`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.`,ct,Xe,At="Class attribute:",it,qe,Nt=`<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>`,ht,oe,ve,mt,Qe,Pt="To be executed when the hook is detached from a module.",pt,te,be,ft,Oe,Vt="To be executed when the hook is attached to the module.",ut,ae,ke,_t,Se,Rt="To be executed just after the forward method of the model.",gt,ne,we,vt,Ye,Et="To be executed just before the forward method of the model.",yo,Z,ye,bt,Ke,zt=`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.`,$o,A,$e,kt,eo,Xt="A hook that can contain several hooks and iterates through them at each event.",xo,xe,Mo,D,Me,wt,oo,qt=`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>.`,yt,se,To,N,Te,$t,to,Qt=`Recursively attaches <code>AlignDevicesHook</code> to all submodules of a given model to make sure they have the right | |
| execution device`,Uo,P,Ue,xt,ao,Ot=`Recursively attaches <code>AlignDevicesHook</code> to all submodules of a given model that have direct parameters and/or | |
| buffers.`,Co,V,Ce,Mt,no,St="Attaches <code>AlignDevicesHook</code> to all blocks of a given model as needed.",jo,je,Jo,R,Je,Tt,so,Yt="Removes any hook attached to a module via <code>add_hook_to_module</code>.",Io,E,Ie,Ut,lo,Kt="Recursively removes all hooks attached on the submodules of a given model.",Go,Ge,Wo,io,Do;return $=new co({props:{title:"Working with large models",local:"working-with-large-models",headingTag:"h1"}}),T=new co({props:{title:"Dispatching and Offloading Models",local:"accelerate.init_empty_weights",headingTag:"h2"}}),de=new M({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 Ct({props:{anchor:"accelerate.init_empty_weights.example",$$slots:{default:[la]},$$scope:{ctx:U}}}),O=new zo({props:{warning:!0,$$slots:{default:[da]},$$scope:{ctx:U}}}),re=new M({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"}}),ce=new M({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"}}),S=new Ct({props:{anchor:"accelerate.cpu_offload_with_hook.example",$$slots:{default:[ra]},$$scope:{ctx:U}}}),ie=new M({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"}}),he=new M({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"}}),me=new M({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"}}),Y=new Ct({props:{anchor:"accelerate.load_checkpoint_and_dispatch.example",$$slots:{default:[ca]},$$scope:{ctx:U}}}),pe=new M({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#L1608"}}),K=new zo({props:{warning:!0,$$slots:{default:[ia]},$$scope:{ctx:U}}}),fe=new M({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#L1093"}}),ee=new zo({props:{$$slots:{default:[ha]},$$scope:{ctx:U}}}),ue=new co({props:{title:"Model Hooks",local:"model-hooks",headingTag:"h2"}}),_e=new co({props:{title:"Hook Classes",local:"accelerate.hooks.ModelHook",headingTag:"h3"}}),ge=new M({props:{name:"class accelerate.hooks.ModelHook",anchor:"accelerate.hooks.ModelHook",parameters:[],source:"https://github.com/huggingface/accelerate/blob/main/src/accelerate/hooks.py#L37"}}),ve=new M({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"}}),be=new M({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"}}),ke=new M({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> | |
| `}}),we=new M({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> | |
| `}}),ye=new M({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"}}),$e=new M({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"}}),xe=new co({props:{title:"Adding Hooks",local:"accelerate.hooks.add_hook_to_module",headingTag:"h3"}}),Me=new M({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> | |
| `}}),se=new zo({props:{warning:!0,$$slots:{default:[ma]},$$scope:{ctx:U}}}),Te=new M({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"}}),Ue=new M({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"}}),Ce=new M({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"}}),je=new co({props:{title:"Removing Hooks",local:"accelerate.hooks.remove_hook_from_module",headingTag:"h3"}}),Je=new M({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> | |
| `}}),Ie=new M({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"}}),Ge=new sa({props:{source:"https://github.com/huggingface/accelerate/blob/main/docs/source/package_reference/big_modeling.md"}}),{c(){a=d("meta"),k=s(),h=d("p"),v=s(),m($.$$.fragment),i=s(),m(T.$$.fragment),ho=s(),j=d("div"),m(de.$$.fragment),Xo=s(),Be=d("p"),Be.textContent=Jt,qo=s(),m(Q.$$.fragment),Qo=s(),m(O.$$.fragment),mo=s(),F=d("div"),m(re.$$.fragment),Oo=s(),Le=d("p"),Le.textContent=It,po=s(),I=d("div"),m(ce.$$.fragment),So=s(),Ze=d("p"),Ze.innerHTML=Gt,Yo=s(),m(S.$$.fragment),fo=s(),B=d("div"),m(ie.$$.fragment),Ko=s(),Ae=d("p"),Ae.textContent=Wt,uo=s(),L=d("div"),m(he.$$.fragment),et=s(),Ne=d("p"),Ne.textContent=Dt,_o=s(),G=d("div"),m(me.$$.fragment),ot=s(),Pe=d("p"),Pe.textContent=Ht,tt=s(),m(Y.$$.fragment),go=s(),W=d("div"),m(pe.$$.fragment),at=s(),Ve=d("p"),Ve.textContent=Ft,nt=s(),m(K.$$.fragment),vo=s(),J=d("div"),m(fe.$$.fragment),st=s(),Re=d("p"),Re.textContent=Bt,lt=s(),Ee=d("ul"),Ee.innerHTML=Lt,dt=s(),m(ee.$$.fragment),bo=s(),m(ue.$$.fragment),ko=s(),m(_e.$$.fragment),wo=s(),x=d("div"),m(ge.$$.fragment),rt=s(),ze=d("p"),ze.textContent=Zt,ct=s(),Xe=d("p"),Xe.textContent=At,it=s(),qe=d("ul"),qe.innerHTML=Nt,ht=s(),oe=d("div"),m(ve.$$.fragment),mt=s(),Qe=d("p"),Qe.textContent=Pt,pt=s(),te=d("div"),m(be.$$.fragment),ft=s(),Oe=d("p"),Oe.textContent=Vt,ut=s(),ae=d("div"),m(ke.$$.fragment),_t=s(),Se=d("p"),Se.textContent=Rt,gt=s(),ne=d("div"),m(we.$$.fragment),vt=s(),Ye=d("p"),Ye.textContent=Et,yo=s(),Z=d("div"),m(ye.$$.fragment),bt=s(),Ke=d("p"),Ke.innerHTML=zt,$o=s(),A=d("div"),m($e.$$.fragment),kt=s(),eo=d("p"),eo.textContent=Xt,xo=s(),m(xe.$$.fragment),Mo=s(),D=d("div"),m(Me.$$.fragment),wt=s(),oo=d("p"),oo.innerHTML=qt,yt=s(),m(se.$$.fragment),To=s(),N=d("div"),m(Te.$$.fragment),$t=s(),to=d("p"),to.innerHTML=Qt,Uo=s(),P=d("div"),m(Ue.$$.fragment),xt=s(),ao=d("p"),ao.innerHTML=Ot,Co=s(),V=d("div"),m(Ce.$$.fragment),Mt=s(),no=d("p"),no.innerHTML=St,jo=s(),m(je.$$.fragment),Jo=s(),R=d("div"),m(Je.$$.fragment),Tt=s(),so=d("p"),so.innerHTML=Yt,Io=s(),E=d("div"),m(Ie.$$.fragment),Ut=s(),lo=d("p"),lo.textContent=Kt,Go=s(),m(Ge.$$.fragment),Wo=s(),io=d("p"),this.h()},l(e){const t=na("svelte-u9bgzb",document.head);a=r(t,"META",{name:!0,content:!0}),t.forEach(o),k=l(e),h=r(e,"P",{}),w(h).forEach(o),v=l(e),p($.$$.fragment,e),i=l(e),p(T.$$.fragment,e),ho=l(e),j=r(e,"DIV",{class:!0});var H=w(j);p(de.$$.fragment,H),Xo=l(H),Be=r(H,"P",{"data-svelte-h":!0}),b(Be)!=="svelte-1u5mepw"&&(Be.textContent=Jt),qo=l(H),p(Q.$$.fragment,H),Qo=l(H),p(O.$$.fragment,H),H.forEach(o),mo=l(e),F=r(e,"DIV",{class:!0});var We=w(F);p(re.$$.fragment,We),Oo=l(We),Le=r(We,"P",{"data-svelte-h":!0}),b(Le)!=="svelte-1gp9ghs"&&(Le.textContent=It),We.forEach(o),po=l(e),I=r(e,"DIV",{class:!0});var z=w(I);p(ce.$$.fragment,z),So=l(z),Ze=r(z,"P",{"data-svelte-h":!0}),b(Ze)!=="svelte-6j2oun"&&(Ze.innerHTML=Gt),Yo=l(z),p(S.$$.fragment,z),z.forEach(o),fo=l(e),B=r(e,"DIV",{class:!0});var De=w(B);p(ie.$$.fragment,De),Ko=l(De),Ae=r(De,"P",{"data-svelte-h":!0}),b(Ae)!=="svelte-js7ro5"&&(Ae.textContent=Wt),De.forEach(o),uo=l(e),L=r(e,"DIV",{class:!0});var He=w(L);p(he.$$.fragment,He),et=l(He),Ne=r(He,"P",{"data-svelte-h":!0}),b(Ne)!=="svelte-1p13mzc"&&(Ne.textContent=Dt),He.forEach(o),_o=l(e),G=r(e,"DIV",{class:!0});var X=w(G);p(me.$$.fragment,X),ot=l(X),Pe=r(X,"P",{"data-svelte-h":!0}),b(Pe)!=="svelte-1ikrez4"&&(Pe.textContent=Ht),tt=l(X),p(Y.$$.fragment,X),X.forEach(o),go=l(e),W=r(e,"DIV",{class:!0});var q=w(W);p(pe.$$.fragment,q),at=l(q),Ve=r(q,"P",{"data-svelte-h":!0}),b(Ve)!=="svelte-qft9nv"&&(Ve.textContent=Ft),nt=l(q),p(K.$$.fragment,q),q.forEach(o),vo=l(e),J=r(e,"DIV",{class:!0});var le=w(J);p(fe.$$.fragment,le),st=l(le),Re=r(le,"P",{"data-svelte-h":!0}),b(Re)!=="svelte-ou57jw"&&(Re.textContent=Bt),lt=l(le),Ee=r(le,"UL",{"data-svelte-h":!0}),b(Ee)!=="svelte-17tb5w2"&&(Ee.innerHTML=Lt),dt=l(le),p(ee.$$.fragment,le),le.forEach(o),bo=l(e),p(ue.$$.fragment,e),ko=l(e),p(_e.$$.fragment,e),wo=l(e),x=r(e,"DIV",{class:!0});var C=w(x);p(ge.$$.fragment,C),rt=l(C),ze=r(C,"P",{"data-svelte-h":!0}),b(ze)!=="svelte-jjeczj"&&(ze.textContent=Zt),ct=l(C),Xe=r(C,"P",{"data-svelte-h":!0}),b(Xe)!=="svelte-1aqkkwa"&&(Xe.textContent=At),it=l(C),qe=r(C,"UL",{"data-svelte-h":!0}),b(qe)!=="svelte-1ny2lfh"&&(qe.innerHTML=Nt),ht=l(C),oe=r(C,"DIV",{class:!0});var Ho=w(oe);p(ve.$$.fragment,Ho),mt=l(Ho),Qe=r(Ho,"P",{"data-svelte-h":!0}),b(Qe)!=="svelte-13obmts"&&(Qe.textContent=Pt),Ho.forEach(o),pt=l(C),te=r(C,"DIV",{class:!0});var Fo=w(te);p(be.$$.fragment,Fo),ft=l(Fo),Oe=r(Fo,"P",{"data-svelte-h":!0}),b(Oe)!=="svelte-2npthr"&&(Oe.textContent=Vt),Fo.forEach(o),ut=l(C),ae=r(C,"DIV",{class:!0});var Bo=w(ae);p(ke.$$.fragment,Bo),_t=l(Bo),Se=r(Bo,"P",{"data-svelte-h":!0}),b(Se)!=="svelte-17hlov5"&&(Se.textContent=Rt),Bo.forEach(o),gt=l(C),ne=r(C,"DIV",{class:!0});var Lo=w(ne);p(we.$$.fragment,Lo),vt=l(Lo),Ye=r(Lo,"P",{"data-svelte-h":!0}),b(Ye)!=="svelte-53qfnq"&&(Ye.textContent=Et),Lo.forEach(o),C.forEach(o),yo=l(e),Z=r(e,"DIV",{class:!0});var Zo=w(Z);p(ye.$$.fragment,Zo),bt=l(Zo),Ke=r(Zo,"P",{"data-svelte-h":!0}),b(Ke)!=="svelte-15d0s2c"&&(Ke.innerHTML=zt),Zo.forEach(o),$o=l(e),A=r(e,"DIV",{class:!0});var Ao=w(A);p($e.$$.fragment,Ao),kt=l(Ao),eo=r(Ao,"P",{"data-svelte-h":!0}),b(eo)!=="svelte-kxjaug"&&(eo.textContent=Xt),Ao.forEach(o),xo=l(e),p(xe.$$.fragment,e),Mo=l(e),D=r(e,"DIV",{class:!0});var ro=w(D);p(Me.$$.fragment,ro),wt=l(ro),oo=r(ro,"P",{"data-svelte-h":!0}),b(oo)!=="svelte-12byttf"&&(oo.innerHTML=qt),yt=l(ro),p(se.$$.fragment,ro),ro.forEach(o),To=l(e),N=r(e,"DIV",{class:!0});var No=w(N);p(Te.$$.fragment,No),$t=l(No),to=r(No,"P",{"data-svelte-h":!0}),b(to)!=="svelte-rf1vym"&&(to.innerHTML=Qt),No.forEach(o),Uo=l(e),P=r(e,"DIV",{class:!0});var Po=w(P);p(Ue.$$.fragment,Po),xt=l(Po),ao=r(Po,"P",{"data-svelte-h":!0}),b(ao)!=="svelte-5orloz"&&(ao.innerHTML=Ot),Po.forEach(o),Co=l(e),V=r(e,"DIV",{class:!0});var Vo=w(V);p(Ce.$$.fragment,Vo),Mt=l(Vo),no=r(Vo,"P",{"data-svelte-h":!0}),b(no)!=="svelte-1anoa02"&&(no.innerHTML=St),Vo.forEach(o),jo=l(e),p(je.$$.fragment,e),Jo=l(e),R=r(e,"DIV",{class:!0});var Ro=w(R);p(Je.$$.fragment,Ro),Tt=l(Ro),so=r(Ro,"P",{"data-svelte-h":!0}),b(so)!=="svelte-1kj8409"&&(so.innerHTML=Yt),Ro.forEach(o),Io=l(e),E=r(e,"DIV",{class:!0});var Eo=w(E);p(Ie.$$.fragment,Eo),Ut=l(Eo),lo=r(Eo,"P",{"data-svelte-h":!0}),b(lo)!=="svelte-xlirjm"&&(lo.textContent=Kt),Eo.forEach(o),Go=l(e),p(Ge.$$.fragment,e),Wo=l(e),io=r(e,"P",{}),w(io).forEach(o),this.h()},h(){y(a,"name","hf:doc:metadata"),y(a,"content",fa),y(j,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),y(F,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),y(I,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),y(B,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),y(L,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),y(G,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),y(W,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),y(J,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),y(oe,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),y(te,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),y(ae,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),y(ne,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),y(x,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),y(Z,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),y(A,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),y(D,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),y(N,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),y(P,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),y(V,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),y(R,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),y(E,"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,t){n(document.head,a),c(e,k,t),c(e,h,t),c(e,v,t),f($,e,t),c(e,i,t),f(T,e,t),c(e,ho,t),c(e,j,t),f(de,j,null),n(j,Xo),n(j,Be),n(j,qo),f(Q,j,null),n(j,Qo),f(O,j,null),c(e,mo,t),c(e,F,t),f(re,F,null),n(F,Oo),n(F,Le),c(e,po,t),c(e,I,t),f(ce,I,null),n(I,So),n(I,Ze),n(I,Yo),f(S,I,null),c(e,fo,t),c(e,B,t),f(ie,B,null),n(B,Ko),n(B,Ae),c(e,uo,t),c(e,L,t),f(he,L,null),n(L,et),n(L,Ne),c(e,_o,t),c(e,G,t),f(me,G,null),n(G,ot),n(G,Pe),n(G,tt),f(Y,G,null),c(e,go,t),c(e,W,t),f(pe,W,null),n(W,at),n(W,Ve),n(W,nt),f(K,W,null),c(e,vo,t),c(e,J,t),f(fe,J,null),n(J,st),n(J,Re),n(J,lt),n(J,Ee),n(J,dt),f(ee,J,null),c(e,bo,t),f(ue,e,t),c(e,ko,t),f(_e,e,t),c(e,wo,t),c(e,x,t),f(ge,x,null),n(x,rt),n(x,ze),n(x,ct),n(x,Xe),n(x,it),n(x,qe),n(x,ht),n(x,oe),f(ve,oe,null),n(oe,mt),n(oe,Qe),n(x,pt),n(x,te),f(be,te,null),n(te,ft),n(te,Oe),n(x,ut),n(x,ae),f(ke,ae,null),n(ae,_t),n(ae,Se),n(x,gt),n(x,ne),f(we,ne,null),n(ne,vt),n(ne,Ye),c(e,yo,t),c(e,Z,t),f(ye,Z,null),n(Z,bt),n(Z,Ke),c(e,$o,t),c(e,A,t),f($e,A,null),n(A,kt),n(A,eo),c(e,xo,t),f(xe,e,t),c(e,Mo,t),c(e,D,t),f(Me,D,null),n(D,wt),n(D,oo),n(D,yt),f(se,D,null),c(e,To,t),c(e,N,t),f(Te,N,null),n(N,$t),n(N,to),c(e,Uo,t),c(e,P,t),f(Ue,P,null),n(P,xt),n(P,ao),c(e,Co,t),c(e,V,t),f(Ce,V,null),n(V,Mt),n(V,no),c(e,jo,t),f(je,e,t),c(e,Jo,t),c(e,R,t),f(Je,R,null),n(R,Tt),n(R,so),c(e,Io,t),c(e,E,t),f(Ie,E,null),n(E,Ut),n(E,lo),c(e,Go,t),f(Ge,e,t),c(e,Wo,t),c(e,io,t),Do=!0},p(e,[t]){const H={};t&2&&(H.$$scope={dirty:t,ctx:e}),Q.$set(H);const We={};t&2&&(We.$$scope={dirty:t,ctx:e}),O.$set(We);const z={};t&2&&(z.$$scope={dirty:t,ctx:e}),S.$set(z);const De={};t&2&&(De.$$scope={dirty:t,ctx:e}),Y.$set(De);const He={};t&2&&(He.$$scope={dirty:t,ctx:e}),K.$set(He);const X={};t&2&&(X.$$scope={dirty:t,ctx:e}),ee.$set(X);const q={};t&2&&(q.$$scope={dirty:t,ctx:e}),se.$set(q)},i(e){Do||(u($.$$.fragment,e),u(T.$$.fragment,e),u(de.$$.fragment,e),u(Q.$$.fragment,e),u(O.$$.fragment,e),u(re.$$.fragment,e),u(ce.$$.fragment,e),u(S.$$.fragment,e),u(ie.$$.fragment,e),u(he.$$.fragment,e),u(me.$$.fragment,e),u(Y.$$.fragment,e),u(pe.$$.fragment,e),u(K.$$.fragment,e),u(fe.$$.fragment,e),u(ee.$$.fragment,e),u(ue.$$.fragment,e),u(_e.$$.fragment,e),u(ge.$$.fragment,e),u(ve.$$.fragment,e),u(be.$$.fragment,e),u(ke.$$.fragment,e),u(we.$$.fragment,e),u(ye.$$.fragment,e),u($e.$$.fragment,e),u(xe.$$.fragment,e),u(Me.$$.fragment,e),u(se.$$.fragment,e),u(Te.$$.fragment,e),u(Ue.$$.fragment,e),u(Ce.$$.fragment,e),u(je.$$.fragment,e),u(Je.$$.fragment,e),u(Ie.$$.fragment,e),u(Ge.$$.fragment,e),Do=!0)},o(e){_($.$$.fragment,e),_(T.$$.fragment,e),_(de.$$.fragment,e),_(Q.$$.fragment,e),_(O.$$.fragment,e),_(re.$$.fragment,e),_(ce.$$.fragment,e),_(S.$$.fragment,e),_(ie.$$.fragment,e),_(he.$$.fragment,e),_(me.$$.fragment,e),_(Y.$$.fragment,e),_(pe.$$.fragment,e),_(K.$$.fragment,e),_(fe.$$.fragment,e),_(ee.$$.fragment,e),_(ue.$$.fragment,e),_(_e.$$.fragment,e),_(ge.$$.fragment,e),_(ve.$$.fragment,e),_(be.$$.fragment,e),_(ke.$$.fragment,e),_(we.$$.fragment,e),_(ye.$$.fragment,e),_($e.$$.fragment,e),_(xe.$$.fragment,e),_(Me.$$.fragment,e),_(se.$$.fragment,e),_(Te.$$.fragment,e),_(Ue.$$.fragment,e),_(Ce.$$.fragment,e),_(je.$$.fragment,e),_(Je.$$.fragment,e),_(Ie.$$.fragment,e),_(Ge.$$.fragment,e),Do=!1},d(e){e&&(o(k),o(h),o(v),o(i),o(ho),o(j),o(mo),o(F),o(po),o(I),o(fo),o(B),o(uo),o(L),o(_o),o(G),o(go),o(W),o(vo),o(J),o(bo),o(ko),o(wo),o(x),o(yo),o(Z),o($o),o(A),o(xo),o(Mo),o(D),o(To),o(N),o(Uo),o(P),o(Co),o(V),o(jo),o(Jo),o(R),o(Io),o(E),o(Go),o(Wo),o(io)),o(a),g($,e),g(T,e),g(de),g(Q),g(O),g(re),g(ce),g(S),g(ie),g(he),g(me),g(Y),g(pe),g(K),g(fe),g(ee),g(ue,e),g(_e,e),g(ge),g(ve),g(be),g(ke),g(we),g(ye),g($e),g(xe,e),g(Me),g(se),g(Te),g(Ue),g(Ce),g(je,e),g(Je),g(Ie),g(Ge,e)}}}const fa='{"title":"Working with large models","local":"working-with-large-models","sections":[{"title":"Dispatching and Offloading Models","local":"accelerate.init_empty_weights","sections":[],"depth":2},{"title":"Model Hooks","local":"model-hooks","sections":[{"title":"Hook Classes","local":"accelerate.hooks.ModelHook","sections":[],"depth":3},{"title":"Adding Hooks","local":"accelerate.hooks.add_hook_to_module","sections":[],"depth":3},{"title":"Removing Hooks","local":"accelerate.hooks.remove_hook_from_module","sections":[],"depth":3}],"depth":2}],"depth":1}';function ua(U){return oa(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class $a extends ta{constructor(a){super(),aa(this,a,ua,pa,ea,{})}}export{$a as component}; | |
Xet Storage Details
- Size:
- 69.8 kB
- Xet hash:
- 129c905c1a4f09ef8086c91cf65f42192f90dad7acf9b770863ccd690788d098
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.