Buckets:

HuggingFaceDocBuilder's picture
download
raw
5.77 kB
import"../chunks/DsnmJJEf.js";import{i as m,h as J,C as y,H as b,a as p,E as T,s as f}from"../chunks/ClLAY5C0.js";import{p as M,o as v,s as e,f as I,a as l,b as j,c as r,n as x}from"../chunks/BhevU81Y.js";import{T as U}from"../chunks/L24edx8-.js";const G='{"title":"Accelerate","local":"accelerate","sections":[],"depth":1}';var A=r('<meta name="hf:doc:metadata"/>'),Z=r('<p>To get a better idea of this process, make sure to check out the <a href="basic_tutorials/overview">Tutorials</a>!</p>'),B=r(`<p></p> <!> <!> <p>Accelerate is a library that enables the same PyTorch code to be run across any distributed configuration by adding just four lines of code! In short, training and inference at scale made simple, efficient and adaptable.</p> <!> <p>Built on <code>torch_xla</code> and <code>torch.distributed</code>, Accelerate takes care of the heavy lifting, so you don’t have to write any custom code to adapt to these platforms.
Convert existing codebases to utilize <a href="usage_guides/deepspeed">DeepSpeed</a>, perform <a href="usage_guides/fsdp">fully sharded data parallelism</a>, and have automatic support for mixed-precision training!</p> <!> <p>This code can then be launched on any system through Accelerate’s CLI interface:</p> <!> <div class="mt-10"><div class="w-full flex flex-col space-y-4 md:space-y-0 md:grid md:grid-cols-2 md:gap-y-4 md:gap-x-5"><a class="!no-underline border dark:border-gray-700 p-5 rounded-lg shadow hover:shadow-lg" href="./basic_tutorials/overview"><div class="w-full text-center bg-gradient-to-br from-blue-400 to-blue-500 rounded-lg py-1.5 font-semibold mb-5 text-white text-lg leading-relaxed">Tutorials</div> <p class="text-gray-700">Learn the basics and become familiar with using Accelerate. Start here if you are using Accelerate for the first time!</p></a> <a class="!no-underline border dark:border-gray-700 p-5 rounded-lg shadow hover:shadow-lg" href="./usage_guides/explore"><div class="w-full text-center bg-gradient-to-br from-indigo-400 to-indigo-500 rounded-lg py-1.5 font-semibold mb-5 text-white text-lg leading-relaxed">How-to guides</div> <p class="text-gray-700">Practical guides to help you achieve a specific goal. Take a look at these guides to learn how to use Accelerate to solve real-world problems.</p></a> <a class="!no-underline border dark:border-gray-700 p-5 rounded-lg shadow hover:shadow-lg" href="./concept_guides/gradient_synchronization"><div class="w-full text-center bg-gradient-to-br from-pink-400 to-pink-500 rounded-lg py-1.5 font-semibold mb-5 text-white text-lg leading-relaxed">Conceptual guides</div> <p class="text-gray-700">High-level explanations for building a better understanding of important topics such as avoiding subtle nuances and pitfalls in distributed training and DeepSpeed.</p></a> <a class="!no-underline border dark:border-gray-700 p-5 rounded-lg shadow hover:shadow-lg" href="./package_reference/accelerator"><div class="w-full text-center bg-gradient-to-br from-purple-400 to-purple-500 rounded-lg py-1.5 font-semibold mb-5 text-white text-lg leading-relaxed">Reference</div> <p class="text-gray-700">Technical descriptions of how Accelerate classes and methods work.</p></a></div></div> <!> <p></p>`,1);function z(h,g){M(g,!1),v(()=>{new URLSearchParams(window.location.search).get("fw")}),m();var o=B();J("1ldsu9f",a=>{var t=A();f(t,"content",G),l(a,t)});var s=e(I(o),2);y(s,{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"});var d=e(s,2);b(d,{title:"Accelerate",local:"accelerate",headingTag:"h1"});var i=e(d,4);p(i,{code:"JTJCJTIwZnJvbSUyMGFjY2VsZXJhdGUlMjBpbXBvcnQlMjBBY2NlbGVyYXRvciUwQSUyQiUyMGFjY2VsZXJhdG9yJTIwJTNEJTIwQWNjZWxlcmF0b3IoKSUwQSUwQSUyQiUyMG1vZGVsJTJDJTIwb3B0aW1pemVyJTJDJTIwdHJhaW5pbmdfZGF0YWxvYWRlciUyQyUyMHNjaGVkdWxlciUyMCUzRCUyMGFjY2VsZXJhdG9yLnByZXBhcmUoJTBBJTJCJTIwJTIwJTIwJTIwJTIwbW9kZWwlMkMlMjBvcHRpbWl6ZXIlMkMlMjB0cmFpbmluZ19kYXRhbG9hZGVyJTJDJTIwc2NoZWR1bGVyJTBBJTJCJTIwKSUwQSUwQSUyMCUyMGZvciUyMGJhdGNoJTIwaW4lMjB0cmFpbmluZ19kYXRhbG9hZGVyJTNBJTBBJTIwJTIwJTIwJTIwJTIwJTIwb3B0aW1pemVyLnplcm9fZ3JhZCgpJTBBJTIwJTIwJTIwJTIwJTIwJTIwaW5wdXRzJTJDJTIwdGFyZ2V0cyUyMCUzRCUyMGJhdGNoJTBBJTIwJTIwJTIwJTIwJTIwJTIwaW5wdXRzJTIwJTNEJTIwaW5wdXRzLnRvKGRldmljZSklMEElMjAlMjAlMjAlMjAlMjAlMjB0YXJnZXRzJTIwJTNEJTIwdGFyZ2V0cy50byhkZXZpY2UpJTBBJTIwJTIwJTIwJTIwJTIwJTIwb3V0cHV0cyUyMCUzRCUyMG1vZGVsKGlucHV0cyklMEElMjAlMjAlMjAlMjAlMjAlMjBsb3NzJTIwJTNEJTIwbG9zc19mdW5jdGlvbihvdXRwdXRzJTJDJTIwdGFyZ2V0cyklMEElMkIlMjAlMjAlMjAlMjAlMjBhY2NlbGVyYXRvci5iYWNrd2FyZChsb3NzKSUwQSUyMCUyMCUyMCUyMCUyMCUyMG9wdGltaXplci5zdGVwKCklMEElMjAlMjAlMjAlMjAlMjAlMjBzY2hlZHVsZXIuc3RlcCgp",highlighted:`<span class="hljs-addition">+ from accelerate import Accelerator</span>
<span class="hljs-addition">+ accelerator = Accelerator()</span>
<span class="hljs-addition">+ model, optimizer, training_dataloader, scheduler = accelerator.prepare(</span>
<span class="hljs-addition">+ model, optimizer, training_dataloader, scheduler</span>
<span class="hljs-addition">+ )</span>
for batch in training_dataloader:
optimizer.zero_grad()
inputs, targets = batch
inputs = inputs.to(device)
targets = targets.to(device)
outputs = model(inputs)
loss = loss_function(outputs, targets)
<span class="hljs-addition">+ accelerator.backward(loss)</span>
optimizer.step()
scheduler.step()`,lang:"diff",wrap:!1});var n=e(i,4);U(n,{children:(a,t)=>{var w=Z();l(a,w)},$$slots:{default:!0}});var c=e(n,4);p(c,{code:"YWNjZWxlcmF0ZSUyMGxhdW5jaCUyMCU3Qm15X3NjcmlwdC5weSU3RA==",highlighted:"accelerate launch {my_script.py}",lang:"bash",wrap:!1});var u=e(c,4);T(u,{source:"https://github.com/huggingface/accelerate/blob/main/docs/source/index.md"}),x(2),l(h,o),j()}export{z as component};

Xet Storage Details

Size:
5.77 kB
·
Xet hash:
2896976fd3ca8cc6fe8043e263bb0a87c3fd88171cfce0221ce4b234d58b6f13

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.