import{s as It,o as Yt,n as Vt}from"../chunks/scheduler.defa9a21.js";import{S as Qt,i as Ot,g as n,s,r as d,A as qt,h as o,f as l,c as i,j as Nt,u as p,x as r,k as Lt,y as Kt,a,v as c,d as f,t as m,w as h}from"../chunks/index.fe795e71.js";import{T as el}from"../chunks/Tip.179eb360.js";import{C as w}from"../chunks/CodeBlock.204b6c34.js";import{H as ue,E as tl}from"../chunks/getInferenceSnippets.2234a8dd.js";function ll(we){let u,T='For those interested in the similarities and differences between FSDP and DeepSpeed, please check out the <a href="../concept_guides/fsdp_and_deepspeed">concept guide here</a>!';return{c(){u=n("p"),u.innerHTML=T},l(_){u=o(_,"P",{"data-svelte-h":!0}),r(u)!=="svelte-we3qam"&&(u.innerHTML=T)},m(_,he){a(_,u,he)},p:Vt,d(_){_&&l(u)}}}function al(we){let u,T,_,he,y,Me,g,ht=`To accelerate training huge models on larger batch sizes, we can use a fully sharded data parallel model.
This type of data parallel paradigm enables fitting more data and larger models by sharding the optimizer states, gradients and parameters.
To read more about it and the benefits, check out the <a href="https://pytorch.org/blog/introducing-pytorch-fully-sharded-data-parallel-api/" rel="nofollow">Fully Sharded Data Parallel blog</a>.
We have integrated the latest PyTorch’s Fully Sharded Data Parallel (FSDP) training feature.
All you need to do is enable it through the config.`,Te,b,ye,$,ut="On your machine(s) just run:",ge,v,be,Z,_t=`and answer the questions asked. This will generate a config file that will be used automatically to properly set the
default options when doing`,$e,B,ve,j,wt="For instance, here is how you would run <code>examples/nlp_example.py</code> (from the root of the repo) with FSDP enabled:",Ze,J,Be,F,je,H,Mt="Currently, <code>Accelerate</code> supports the following config through the CLI:",Je,R,Tt='<code>fsdp_sharding_strategy</code>: [1] FULL_SHARD (shards optimizer states, gradients and parameters), [2] SHARD_GRAD_OP (shards optimizer states and gradients), [3] NO_SHARD (DDP), [4] HYBRID_SHARD (shards optimizer states, gradients and parameters within each node while each node has full copy), [5] HYBRID_SHARD_ZERO2 (shards optimizer states and gradients within each node while each node has full copy). For more information, please refer the official <a href="https://pytorch.org/docs/stable/fsdp.html#torch.distributed.fsdp.ShardingStrategy" rel="nofollow">PyTorch docs</a>.',Fe,S,yt="<code>fsdp_offload_params</code> : Decides Whether to offload parameters and gradients to CPU",He,W,gt="<code>fsdp_auto_wrap_policy</code>: [1] TRANSFORMER_BASED_WRAP, [2] SIZE_BASED_WRAP, [3] NO_WRAP",Re,x,bt="<code>fsdp_transformer_layer_cls_to_wrap</code>: Only applicable for Transformers. When using <code>fsdp_auto_wrap_policy=TRANSFORMER_BASED_WRAP</code>, a user may provide a comma-separated string of transformer layer class names (case-sensitive) to wrap, e.g., <code>BertLayer</code>, <code>GPTJBlock</code>, <code>T5Block</code>, <code>BertLayer,BertEmbeddings,BertSelfOutput</code>. This is important because submodules that share weights (e.g., embedding layers) should not end up in different FSDP wrapped units. Using this policy, wrapping happens for each block containing Multi-Head Attention followed by a couple of MLP layers. Remaining layers including the shared embeddings are conveniently wrapped in same outermost FSDP unit. Therefore, use this for transformer-based models. You can use the <code>model._no_split_modules</code> for Transformer models by answering <code>yes</code> to <code>Do you want to use the model&#39;s </code>_no_split_modules<code>to wrap. It will try to use</code>model._no_split_modules` when possible.",Se,U,$t="<code>fsdp_min_num_params</code>: minimum number of parameters when using <code>fsdp_auto_wrap_policy=SIZE_BASED_WRAP</code>.",We,X,vt="<code>fsdp_backward_prefetch_policy</code>: [1] BACKWARD_PRE, [2] BACKWARD_POST, [3] NO_PREFETCH",xe,G,Zt="<code>fsdp_forward_prefetch</code>: if True, then FSDP explicitly prefetches the next upcoming all-gather while executing in the forward pass. Should only be used for static-graph models since the prefetching follows the first iteration’s execution order. i.e., if the sub-modules’ order changes dynamically during the model’s execution do not enable this feature.",Ue,C,Bt="<code>fsdp_state_dict_type</code>: [1] FULL_STATE_DICT, [2] LOCAL_STATE_DICT, [3] SHARDED_STATE_DICT",Xe,k,jt='<code>fsdp_use_orig_params</code>: If True, allows non-uniform <code>requires_grad</code> during init, which means support for interspersed frozen and trainable parameters. This setting is useful in cases such as parameter-efficient fine-tuning as discussed in <a href="https://dev-discuss.pytorch.org/t/rethinking-pytorch-fully-sharded-data-parallel-fsdp-from-first-principles/1019" rel="nofollow">this post</a>. This option also allows one to have multiple optimizer param groups. This should be <code>True</code> when creating an optimizer before preparing/wrapping the model with FSDP.',Ge,A,Jt="<code>fsdp_cpu_ram_efficient_loading</code>: Only applicable for Transformers models. If True, only the first process loads the pretrained model checkpoint while all other processes have empty weights. This should be set to False if you experience errors when loading the pretrained Transformers model via <code>from_pretrained</code> method. When this setting is True <code>fsdp_sync_module_states</code> also must to be True, otherwise all the processes except the main process would have random weights leading to unexpected behaviour during training. For this to work, make sure the distributed process group is initialized before calling Transformers <code>from_pretrained</code> method. When using Trainer API, the distributed process group is initialized when you create an instance of <code>TrainingArguments</code> class.",Ce,E,Ft="<code>fsdp_sync_module_states</code>: If True, each individually wrapped FSDP unit will broadcast module parameters from rank 0.",ke,P,Ht=`For additional and more nuanced control, you can specify other FSDP parameters via <code>FullyShardedDataParallelPlugin</code>.
When creating <code>FullyShardedDataParallelPlugin</code> object, pass it the parameters that weren’t part of the accelerate config or if you want to override them.
The FSDP parameters will be picked based on the accelerate config file or launch command arguments and other parameters that you will pass directly through the <code>FullyShardedDataParallelPlugin</code> object will set/override that.`,Ae,z,Rt="Below is an example:",Ee,D,Pe,N,ze,L,St=`The new recommended way of checkpointing when using FSDP models is to use <code>SHARDED_STATE_DICT</code> as <code>StateDictType</code> when setting up the accelerate config.
Below is the code snippet to save using <code>save_state</code> utility of accelerate.`,De,I,Ne,Y,Wt="Inspect the checkpoint folder to see model and optimizer as shards per process:",Le,V,Ie,Q,xt="To load them back for resuming the training, use the <code>load_state</code> utility of accelerate",Ye,O,Ve,q,Ut=`When using transformers <code>save_pretrained</code>, pass <code>state_dict=accelerator.get_state_dict(model)</code> to save the model state dict.
Below is an example:`,Qe,K,Oe,ee,qe,te,Xt="<code>accelerator.get_state_dict</code> will call the underlying <code>model.state_dict</code> implementation using <code>FullStateDictConfig(offload_to_cpu=True, rank0_only=True)</code> context manager to get the state dict only for rank 0 and it will be offloaded to CPU.",Ke,le,Gt='You can then pass <code>state</code> into the <code>save_pretrained</code> method.  There are several modes for <code>StateDictType</code> and <code>FullStateDictConfig</code> that you can use to control the behavior of <code>state_dict</code>.  For more information, see the <a href="https://pytorch.org/docs/stable/fsdp.html" rel="nofollow">PyTorch documentation</a>.',et,ae,Ct=`If you choose to use <code>StateDictType.SHARDED_STATE_DICT</code>, the weights of the model during <code>Accelerator.save_state</code> will be split into <code>n</code> files for each sub-split on the model. To merge them back into
a single dictionary to load back into the model later after training you can use the <code>merge_weights</code> utility:`,tt,se,lt,ie,kt="The final output will then either be saved to <code>model.safetensors</code> or <code>pytorch_model.bin</code> (if <code>safe_serialization=False</code> is passed).",at,ne,At="This can also be called using the CLI:",st,oe,it,re,nt,de,Et="<li><code>FULL_SHARD</code> maps to the DeepSpeed <code>ZeRO Stage-3</code>. Shards optimizer states, gradients and parameters.</li> <li><code>SHARD_GRAD_OP</code> maps to the DeepSpeed <code>ZeRO Stage-2</code>. Shards optimizer states and gradients.</li> <li><code>NO_SHARD</code> maps to <code>ZeRO Stage-0</code>. No sharding wherein each GPU has full copy of model, optimizer states and gradients.</li> <li><code>HYBRID_SHARD</code> maps to <code>ZeRO++ Stage-3</code> wherein <code>zero_hpz_partition_size=&lt;num_gpus_per_node&gt;</code>. Here, this will shard optimizer states, gradients and parameters within each node while each node has full copy.</li>",ot,pe,rt,ce,Pt="<li>In case of multiple models, pass the optimizers to the prepare call in the same order as corresponding models else <code>accelerator.save_state()</code> and <code>accelerator.load_state()</code> will result in wrong/unexpected behaviour.</li> <li>This feature is incompatible with <code>--predict_with_generate</code> in the <code>run_translation.py</code> script of <code>Transformers</code> library.</li>",dt,fe,zt=`For more control, users can leverage the <code>FullyShardedDataParallelPlugin</code>. After creating an instance of this class, users can pass it to the Accelerator class instantiation.
For more information on these options, please refer to the PyTorch <a href="https://github.com/pytorch/pytorch/blob/0df2e863fbd5993a7b9e652910792bd21a516ff3/torch/distributed/fsdp/fully_sharded_data_parallel.py#L236" rel="nofollow">FullyShardedDataParallel</a> code.`,pt,M,ct,me,ft,_e,mt;return y=new ue({props:{title:"Fully Sharded Data Parallel",local:"fully-sharded-data-parallel",headingTag:"h1"}}),b=new ue({props:{title:"How it works out of the box",local:"how-it-works-out-of-the-box",headingTag:"h2"}}),v=new w({props:{code:"YWNjZWxlcmF0ZSUyMGNvbmZpZw==",highlighted:"accelerate config",wrap:!1}}),B=new w({props:{code:"YWNjZWxlcmF0ZSUyMGxhdW5jaCUyMG15X3NjcmlwdC5weSUyMC0tYXJnc190b19teV9zY3JpcHQ=",highlighted:"accelerate launch my_script.py --args_to_my_script",wrap:!1}}),J=new w({props:{code:"Y29tcHV0ZV9lbnZpcm9ubWVudCUzQSUyMExPQ0FMX01BQ0hJTkUlMEFkZWJ1ZyUzQSUyMGZhbHNlJTBBZGlzdHJpYnV0ZWRfdHlwZSUzQSUyMEZTRFAlMEFkb3duY2FzdF9iZjE2JTNBJTIwJ25vJyUwQWZzZHBfY29uZmlnJTNBJTBBJTIwJTIwZnNkcF9hdXRvX3dyYXBfcG9saWN5JTNBJTIwVFJBTlNGT1JNRVJfQkFTRURfV1JBUCUwQSUyMCUyMGZzZHBfYmFja3dhcmRfcHJlZmV0Y2hfcG9saWN5JTNBJTIwQkFDS1dBUkRfUFJFJTBBJTIwJTIwZnNkcF9mb3J3YXJkX3ByZWZldGNoJTNBJTIwZmFsc2UlMEElMjAlMjBmc2RwX2NwdV9yYW1fZWZmaWNpZW50X2xvYWRpbmclM0ElMjB0cnVlJTBBJTIwJTIwZnNkcF9vZmZsb2FkX3BhcmFtcyUzQSUyMGZhbHNlJTBBJTIwJTIwZnNkcF9zaGFyZGluZ19zdHJhdGVneSUzQSUyMEZVTExfU0hBUkQlMEElMjAlMjBmc2RwX3N0YXRlX2RpY3RfdHlwZSUzQSUyMFNIQVJERURfU1RBVEVfRElDVCUwQSUyMCUyMGZzZHBfc3luY19tb2R1bGVfc3RhdGVzJTNBJTIwdHJ1ZSUwQSUyMCUyMGZzZHBfdHJhbnNmb3JtZXJfbGF5ZXJfY2xzX3RvX3dyYXAlM0ElMjBCZXJ0TGF5ZXIlMEElMjAlMjBmc2RwX3VzZV9vcmlnX3BhcmFtcyUzQSUyMHRydWUlMEFtYWNoaW5lX3JhbmslM0ElMjAwJTBBbWFpbl90cmFpbmluZ19mdW5jdGlvbiUzQSUyMG1haW4lMEFtaXhlZF9wcmVjaXNpb24lM0ElMjBiZjE2JTBBbnVtX21hY2hpbmVzJTNBJTIwMSUwQW51bV9wcm9jZXNzZXMlM0ElMjAyJTBBcmR6dl9iYWNrZW5kJTNBJTIwc3RhdGljJTBBc2FtZV9uZXR3b3JrJTNBJTIwdHJ1ZSUwQXRwdV9lbnYlM0ElMjAlNUIlNUQlMEF0cHVfdXNlX2NsdXN0ZXIlM0ElMjBmYWxzZSUwQXRwdV91c2Vfc3VkbyUzQSUyMGZhbHNlJTBBdXNlX2NwdSUzQSUyMGZhbHNl",highlighted:`compute_environment: LOCAL_MACHINE
debug: <span class="hljs-literal">false</span>
distributed_type: FSDP
downcast_bf16: <span class="hljs-string">&#x27;no&#x27;</span>
fsdp_config:
  fsdp_auto_wrap_policy: TRANSFORMER_BASED_WRAP
  fsdp_backward_prefetch_policy: BACKWARD_PRE
  fsdp_forward_prefetch: <span class="hljs-literal">false</span>
  fsdp_cpu_ram_efficient_loading: <span class="hljs-literal">true</span>
  fsdp_offload_params: <span class="hljs-literal">false</span>
  fsdp_sharding_strategy: FULL_SHARD
  fsdp_state_dict_type: SHARDED_STATE_DICT
  fsdp_sync_module_states: <span class="hljs-literal">true</span>
  fsdp_transformer_layer_cls_to_wrap: BertLayer
  fsdp_use_orig_params: <span class="hljs-literal">true</span>
machine_rank: 0
main_training_function: main
mixed_precision: bf16
num_machines: 1
num_processes: 2
rdzv_backend: static
same_network: <span class="hljs-literal">true</span>
tpu_env: []
tpu_use_cluster: <span class="hljs-literal">false</span>
tpu_use_sudo: <span class="hljs-literal">false</span>
use_cpu: <span class="hljs-literal">false</span>`,wrap:!1}}),F=new w({props:{code:"YWNjZWxlcmF0ZSUyMGxhdW5jaCUyMGV4YW1wbGVzJTJGbmxwX2V4YW1wbGUucHk=",highlighted:"accelerate launch examples/nlp_example.py",wrap:!1}}),D=new w({props:{code:"ZnJvbSUyMGFjY2VsZXJhdGUlMjBpbXBvcnQlMjBGdWxseVNoYXJkZWREYXRhUGFyYWxsZWxQbHVnaW4lMEFmcm9tJTIwdG9yY2guZGlzdHJpYnV0ZWQuZnNkcC5mdWxseV9zaGFyZGVkX2RhdGFfcGFyYWxsZWwlMjBpbXBvcnQlMjBGdWxsT3B0aW1TdGF0ZURpY3RDb25maWclMkMlMjBGdWxsU3RhdGVEaWN0Q29uZmlnJTBBJTBBZnNkcF9wbHVnaW4lMjAlM0QlMjBGdWxseVNoYXJkZWREYXRhUGFyYWxsZWxQbHVnaW4oJTBBJTIwJTIwJTIwJTIwc3RhdGVfZGljdF9jb25maWclM0RGdWxsU3RhdGVEaWN0Q29uZmlnKG9mZmxvYWRfdG9fY3B1JTNERmFsc2UlMkMlMjByYW5rMF9vbmx5JTNERmFsc2UpJTJDJTBBJTIwJTIwJTIwJTIwb3B0aW1fc3RhdGVfZGljdF9jb25maWclM0RGdWxsT3B0aW1TdGF0ZURpY3RDb25maWcob2ZmbG9hZF90b19jcHUlM0RGYWxzZSUyQyUyMHJhbmswX29ubHklM0RGYWxzZSklMkMlMEEpJTBBJTBBYWNjZWxlcmF0b3IlMjAlM0QlMjBBY2NlbGVyYXRvcihmc2RwX3BsdWdpbiUzRGZzZHBfcGx1Z2luKQ==",highlighted:`<span class="hljs-keyword">from</span> accelerate <span class="hljs-keyword">import</span> FullyShardedDataParallelPlugin
<span class="hljs-keyword">from</span> torch.distributed.fsdp.fully_sharded_data_parallel <span class="hljs-keyword">import</span> FullOptimStateDictConfig, FullStateDictConfig

fsdp_plugin = FullyShardedDataParallelPlugin(
    state_dict_config=FullStateDictConfig(offload_to_cpu=<span class="hljs-literal">False</span>, rank0_only=<span class="hljs-literal">False</span>),
    optim_state_dict_config=FullOptimStateDictConfig(offload_to_cpu=<span class="hljs-literal">False</span>, rank0_only=<span class="hljs-literal">False</span>),
)

accelerator = Accelerator(fsdp_plugin=fsdp_plugin)`,wrap:!1}}),N=new ue({props:{title:"Saving and loading",local:"saving-and-loading",headingTag:"h2"}}),I=new w({props:{code:"YWNjZWxlcmF0b3Iuc2F2ZV9zdGF0ZSglMjJja3B0JTIyKQ==",highlighted:'accelerator.save_state(<span class="hljs-string">&quot;ckpt&quot;</span>)',wrap:!1}}),V=new w({props:{code:"bHMlMjBja3B0JTBBJTIzJTIwb3B0aW1pemVyXzAlMjAlMjBweXRvcmNoX21vZGVsXzAlMjAlMjByYW5kb21fc3RhdGVzXzAucGtsJTIwJTIwcmFuZG9tX3N0YXRlc18xLnBrbCUyMCUyMHNjaGVkdWxlci5iaW4lMEElMEFjZCUyMGNrcHQlMEElMEFscyUyMG9wdGltaXplcl8wJTBBJTIzJTIwX18wXzAuZGlzdGNwJTIwJTIwX18xXzAuZGlzdGNwJTBBJTBBbHMlMjBweXRvcmNoX21vZGVsXzAlMEElMjMlMjBfXzBfMC5kaXN0Y3AlMjAlMjBfXzFfMC5kaXN0Y3A=",highlighted:`<span class="hljs-built_in">ls</span> ckpt
<span class="hljs-comment"># optimizer_0  pytorch_model_0  random_states_0.pkl  random_states_1.pkl  scheduler.bin</span>

<span class="hljs-built_in">cd</span> ckpt

<span class="hljs-built_in">ls</span> optimizer_0
<span class="hljs-comment"># __0_0.distcp  __1_0.distcp</span>

<span class="hljs-built_in">ls</span> pytorch_model_0
<span class="hljs-comment"># __0_0.distcp  __1_0.distcp</span>`,wrap:!1}}),O=new w({props:{code:"YWNjZWxlcmF0b3IubG9hZF9zdGF0ZSglMjJja3B0JTIyKQ==",highlighted:'accelerator.load_state(<span class="hljs-string">&quot;ckpt&quot;</span>)',wrap:!1}}),K=new w({props:{code:"JTIwJTIwdW53cmFwcGVkX21vZGVsLnNhdmVfcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjAlMjBhcmdzLm91dHB1dF9kaXIlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjBpc19tYWluX3Byb2Nlc3MlM0RhY2NlbGVyYXRvci5pc19tYWluX3Byb2Nlc3MlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjBzYXZlX2Z1bmN0aW9uJTNEYWNjZWxlcmF0b3Iuc2F2ZSUyQyUwQSUyQiUyMCUyMCUyMCUyMCUyMHN0YXRlX2RpY3QlM0RhY2NlbGVyYXRvci5nZXRfc3RhdGVfZGljdChtb2RlbCklMkMlMEEp",highlighted:`  unwrapped_model.save_pretrained(
      args.output_dir,
      is_main_process=accelerator.is_main_process,
      save_function=accelerator.save,
<span class="hljs-addition">+     state_dict=accelerator.get_state_dict(model),</span>
)`,wrap:!1}}),ee=new ue({props:{title:"State Dict",local:"state-dict",headingTag:"h3"}}),se=new w({props:{code:"ZnJvbSUyMGFjY2VsZXJhdGUudXRpbHMlMjBpbXBvcnQlMjBtZXJnZV9mc2RwX3dlaWdodHMlMEElMEElMjMlMjBPdXIlMjB3ZWlnaHRzJTIwYXJlJTIwc2F2ZWQlMjB1c3VhbGx5JTIwaW4lMjBhJTIwJTYwcHl0b3JjaF9tb2RlbF9mc2RwXyU3Qm1vZGVsX251bWJlciU3RCU2MCUyMGZvbGRlciUwQW1lcmdlX2ZzZHBfd2VpZ2h0cyglMjJweXRvcmNoX21vZGVsX2ZzZHBfMCUyMiUyQyUyMCUyMm91dHB1dF9wYXRoJTIyJTJDJTIwc2FmZV9zZXJpYWxpemF0aW9uJTNEVHJ1ZSk=",highlighted:`<span class="hljs-keyword">from</span> accelerate.utils <span class="hljs-keyword">import</span> merge_fsdp_weights

<span class="hljs-comment"># Our weights are saved usually in a \`pytorch_model_fsdp_{model_number}\` folder</span>
merge_fsdp_weights(<span class="hljs-string">&quot;pytorch_model_fsdp_0&quot;</span>, <span class="hljs-string">&quot;output_path&quot;</span>, safe_serialization=<span class="hljs-literal">True</span>)`,wrap:!1}}),oe=new w({props:{code:"YWNjZWxlcmF0ZSUyMG1lcmdlLXdlaWdodHMlMjBweXRvcmNoX21vZGVsX2ZzZHBfMCUyRiUyMG91dHB1dF9wYXRo",highlighted:"accelerate merge-weights pytorch_model_fsdp_0/ output_path",wrap:!1}}),re=new ue({props:{title:"Mapping between FSDP sharding strategies and DeepSpeed ZeRO Stages",local:"mapping-between-fsdp-sharding-strategies-and-deepspeed-zero-stages",headingTag:"h2"}}),pe=new ue({props:{title:"A few caveats to be aware of",local:"a-few-caveats-to-be-aware-of",headingTag:"h2"}}),M=new el({props:{$$slots:{default:[ll]},$$scope:{ctx:we}}}),me=new tl({props:{source:"https://github.com/huggingface/accelerate/blob/main/docs/source/usage_guides/fsdp.md"}}),{c(){u=n("meta"),T=s(),_=n("p"),he=s(),d(y.$$.fragment),Me=s(),g=n("p"),g.innerHTML=ht,Te=s(),d(b.$$.fragment),ye=s(),$=n("p"),$.textContent=ut,ge=s(),d(v.$$.fragment),be=s(),Z=n("p"),Z.textContent=_t,$e=s(),d(B.$$.fragment),ve=s(),j=n("p"),j.innerHTML=wt,Ze=s(),d(J.$$.fragment),Be=s(),d(F.$$.fragment),je=s(),H=n("p"),H.innerHTML=Mt,Je=s(),R=n("p"),R.innerHTML=Tt,Fe=s(),S=n("p"),S.innerHTML=yt,He=s(),W=n("p"),W.innerHTML=gt,Re=s(),x=n("p"),x.innerHTML=bt,Se=s(),U=n("p"),U.innerHTML=$t,We=s(),X=n("p"),X.innerHTML=vt,xe=s(),G=n("p"),G.innerHTML=Zt,Ue=s(),C=n("p"),C.innerHTML=Bt,Xe=s(),k=n("p"),k.innerHTML=jt,Ge=s(),A=n("p"),A.innerHTML=Jt,Ce=s(),E=n("p"),E.innerHTML=Ft,ke=s(),P=n("p"),P.innerHTML=Ht,Ae=s(),z=n("p"),z.textContent=Rt,Ee=s(),d(D.$$.fragment),Pe=s(),d(N.$$.fragment),ze=s(),L=n("p"),L.innerHTML=St,De=s(),d(I.$$.fragment),Ne=s(),Y=n("p"),Y.textContent=Wt,Le=s(),d(V.$$.fragment),Ie=s(),Q=n("p"),Q.innerHTML=xt,Ye=s(),d(O.$$.fragment),Ve=s(),q=n("p"),q.innerHTML=Ut,Qe=s(),d(K.$$.fragment),Oe=s(),d(ee.$$.fragment),qe=s(),te=n("p"),te.innerHTML=Xt,Ke=s(),le=n("p"),le.innerHTML=Gt,et=s(),ae=n("p"),ae.innerHTML=Ct,tt=s(),d(se.$$.fragment),lt=s(),ie=n("p"),ie.innerHTML=kt,at=s(),ne=n("p"),ne.textContent=At,st=s(),d(oe.$$.fragment),it=s(),d(re.$$.fragment),nt=s(),de=n("ul"),de.innerHTML=Et,ot=s(),d(pe.$$.fragment),rt=s(),ce=n("ul"),ce.innerHTML=Pt,dt=s(),fe=n("p"),fe.innerHTML=zt,pt=s(),d(M.$$.fragment),ct=s(),d(me.$$.fragment),ft=s(),_e=n("p"),this.h()},l(e){const t=qt("svelte-u9bgzb",document.head);u=o(t,"META",{name:!0,content:!0}),t.forEach(l),T=i(e),_=o(e,"P",{}),Nt(_).forEach(l),he=i(e),p(y.$$.fragment,e),Me=i(e),g=o(e,"P",{"data-svelte-h":!0}),r(g)!=="svelte-qnvjvw"&&(g.innerHTML=ht),Te=i(e),p(b.$$.fragment,e),ye=i(e),$=o(e,"P",{"data-svelte-h":!0}),r($)!=="svelte-3pof6s"&&($.textContent=ut),ge=i(e),p(v.$$.fragment,e),be=i(e),Z=o(e,"P",{"data-svelte-h":!0}),r(Z)!=="svelte-ovz84c"&&(Z.textContent=_t),$e=i(e),p(B.$$.fragment,e),ve=i(e),j=o(e,"P",{"data-svelte-h":!0}),r(j)!=="svelte-109sebi"&&(j.innerHTML=wt),Ze=i(e),p(J.$$.fragment,e),Be=i(e),p(F.$$.fragment,e),je=i(e),H=o(e,"P",{"data-svelte-h":!0}),r(H)!=="svelte-aporbc"&&(H.innerHTML=Mt),Je=i(e),R=o(e,"P",{"data-svelte-h":!0}),r(R)!=="svelte-mtvmo1"&&(R.innerHTML=Tt),Fe=i(e),S=o(e,"P",{"data-svelte-h":!0}),r(S)!=="svelte-173mpds"&&(S.innerHTML=yt),He=i(e),W=o(e,"P",{"data-svelte-h":!0}),r(W)!=="svelte-56dvve"&&(W.innerHTML=gt),Re=i(e),x=o(e,"P",{"data-svelte-h":!0}),r(x)!=="svelte-1tuw09a"&&(x.innerHTML=bt),Se=i(e),U=o(e,"P",{"data-svelte-h":!0}),r(U)!=="svelte-fbrtfo"&&(U.innerHTML=$t),We=i(e),X=o(e,"P",{"data-svelte-h":!0}),r(X)!=="svelte-gnni23"&&(X.innerHTML=vt),xe=i(e),G=o(e,"P",{"data-svelte-h":!0}),r(G)!=="svelte-1b8s7mr"&&(G.innerHTML=Zt),Ue=i(e),C=o(e,"P",{"data-svelte-h":!0}),r(C)!=="svelte-1bw4fgg"&&(C.innerHTML=Bt),Xe=i(e),k=o(e,"P",{"data-svelte-h":!0}),r(k)!=="svelte-1hsz8jb"&&(k.innerHTML=jt),Ge=i(e),A=o(e,"P",{"data-svelte-h":!0}),r(A)!=="svelte-w8koju"&&(A.innerHTML=Jt),Ce=i(e),E=o(e,"P",{"data-svelte-h":!0}),r(E)!=="svelte-9z96c5"&&(E.innerHTML=Ft),ke=i(e),P=o(e,"P",{"data-svelte-h":!0}),r(P)!=="svelte-1mlu7qv"&&(P.innerHTML=Ht),Ae=i(e),z=o(e,"P",{"data-svelte-h":!0}),r(z)!=="svelte-ks9e2y"&&(z.textContent=Rt),Ee=i(e),p(D.$$.fragment,e),Pe=i(e),p(N.$$.fragment,e),ze=i(e),L=o(e,"P",{"data-svelte-h":!0}),r(L)!=="svelte-105rpu1"&&(L.innerHTML=St),De=i(e),p(I.$$.fragment,e),Ne=i(e),Y=o(e,"P",{"data-svelte-h":!0}),r(Y)!=="svelte-zz881x"&&(Y.textContent=Wt),Le=i(e),p(V.$$.fragment,e),Ie=i(e),Q=o(e,"P",{"data-svelte-h":!0}),r(Q)!=="svelte-1v7i9ht"&&(Q.innerHTML=xt),Ye=i(e),p(O.$$.fragment,e),Ve=i(e),q=o(e,"P",{"data-svelte-h":!0}),r(q)!=="svelte-1y7f54p"&&(q.innerHTML=Ut),Qe=i(e),p(K.$$.fragment,e),Oe=i(e),p(ee.$$.fragment,e),qe=i(e),te=o(e,"P",{"data-svelte-h":!0}),r(te)!=="svelte-y5myy"&&(te.innerHTML=Xt),Ke=i(e),le=o(e,"P",{"data-svelte-h":!0}),r(le)!=="svelte-57zs50"&&(le.innerHTML=Gt),et=i(e),ae=o(e,"P",{"data-svelte-h":!0}),r(ae)!=="svelte-ik1th2"&&(ae.innerHTML=Ct),tt=i(e),p(se.$$.fragment,e),lt=i(e),ie=o(e,"P",{"data-svelte-h":!0}),r(ie)!=="svelte-1qedos9"&&(ie.innerHTML=kt),at=i(e),ne=o(e,"P",{"data-svelte-h":!0}),r(ne)!=="svelte-1duybas"&&(ne.textContent=At),st=i(e),p(oe.$$.fragment,e),it=i(e),p(re.$$.fragment,e),nt=i(e),de=o(e,"UL",{"data-svelte-h":!0}),r(de)!=="svelte-1mojn5u"&&(de.innerHTML=Et),ot=i(e),p(pe.$$.fragment,e),rt=i(e),ce=o(e,"UL",{"data-svelte-h":!0}),r(ce)!=="svelte-1cyfpa6"&&(ce.innerHTML=Pt),dt=i(e),fe=o(e,"P",{"data-svelte-h":!0}),r(fe)!=="svelte-1dlu8nc"&&(fe.innerHTML=zt),pt=i(e),p(M.$$.fragment,e),ct=i(e),p(me.$$.fragment,e),ft=i(e),_e=o(e,"P",{}),Nt(_e).forEach(l),this.h()},h(){Lt(u,"name","hf:doc:metadata"),Lt(u,"content",sl)},m(e,t){Kt(document.head,u),a(e,T,t),a(e,_,t),a(e,he,t),c(y,e,t),a(e,Me,t),a(e,g,t),a(e,Te,t),c(b,e,t),a(e,ye,t),a(e,$,t),a(e,ge,t),c(v,e,t),a(e,be,t),a(e,Z,t),a(e,$e,t),c(B,e,t),a(e,ve,t),a(e,j,t),a(e,Ze,t),c(J,e,t),a(e,Be,t),c(F,e,t),a(e,je,t),a(e,H,t),a(e,Je,t),a(e,R,t),a(e,Fe,t),a(e,S,t),a(e,He,t),a(e,W,t),a(e,Re,t),a(e,x,t),a(e,Se,t),a(e,U,t),a(e,We,t),a(e,X,t),a(e,xe,t),a(e,G,t),a(e,Ue,t),a(e,C,t),a(e,Xe,t),a(e,k,t),a(e,Ge,t),a(e,A,t),a(e,Ce,t),a(e,E,t),a(e,ke,t),a(e,P,t),a(e,Ae,t),a(e,z,t),a(e,Ee,t),c(D,e,t),a(e,Pe,t),c(N,e,t),a(e,ze,t),a(e,L,t),a(e,De,t),c(I,e,t),a(e,Ne,t),a(e,Y,t),a(e,Le,t),c(V,e,t),a(e,Ie,t),a(e,Q,t),a(e,Ye,t),c(O,e,t),a(e,Ve,t),a(e,q,t),a(e,Qe,t),c(K,e,t),a(e,Oe,t),c(ee,e,t),a(e,qe,t),a(e,te,t),a(e,Ke,t),a(e,le,t),a(e,et,t),a(e,ae,t),a(e,tt,t),c(se,e,t),a(e,lt,t),a(e,ie,t),a(e,at,t),a(e,ne,t),a(e,st,t),c(oe,e,t),a(e,it,t),c(re,e,t),a(e,nt,t),a(e,de,t),a(e,ot,t),c(pe,e,t),a(e,rt,t),a(e,ce,t),a(e,dt,t),a(e,fe,t),a(e,pt,t),c(M,e,t),a(e,ct,t),c(me,e,t),a(e,ft,t),a(e,_e,t),mt=!0},p(e,[t]){const Dt={};t&2&&(Dt.$$scope={dirty:t,ctx:e}),M.$set(Dt)},i(e){mt||(f(y.$$.fragment,e),f(b.$$.fragment,e),f(v.$$.fragment,e),f(B.$$.fragment,e),f(J.$$.fragment,e),f(F.$$.fragment,e),f(D.$$.fragment,e),f(N.$$.fragment,e),f(I.$$.fragment,e),f(V.$$.fragment,e),f(O.$$.fragment,e),f(K.$$.fragment,e),f(ee.$$.fragment,e),f(se.$$.fragment,e),f(oe.$$.fragment,e),f(re.$$.fragment,e),f(pe.$$.fragment,e),f(M.$$.fragment,e),f(me.$$.fragment,e),mt=!0)},o(e){m(y.$$.fragment,e),m(b.$$.fragment,e),m(v.$$.fragment,e),m(B.$$.fragment,e),m(J.$$.fragment,e),m(F.$$.fragment,e),m(D.$$.fragment,e),m(N.$$.fragment,e),m(I.$$.fragment,e),m(V.$$.fragment,e),m(O.$$.fragment,e),m(K.$$.fragment,e),m(ee.$$.fragment,e),m(se.$$.fragment,e),m(oe.$$.fragment,e),m(re.$$.fragment,e),m(pe.$$.fragment,e),m(M.$$.fragment,e),m(me.$$.fragment,e),mt=!1},d(e){e&&(l(T),l(_),l(he),l(Me),l(g),l(Te),l(ye),l($),l(ge),l(be),l(Z),l($e),l(ve),l(j),l(Ze),l(Be),l(je),l(H),l(Je),l(R),l(Fe),l(S),l(He),l(W),l(Re),l(x),l(Se),l(U),l(We),l(X),l(xe),l(G),l(Ue),l(C),l(Xe),l(k),l(Ge),l(A),l(Ce),l(E),l(ke),l(P),l(Ae),l(z),l(Ee),l(Pe),l(ze),l(L),l(De),l(Ne),l(Y),l(Le),l(Ie),l(Q),l(Ye),l(Ve),l(q),l(Qe),l(Oe),l(qe),l(te),l(Ke),l(le),l(et),l(ae),l(tt),l(lt),l(ie),l(at),l(ne),l(st),l(it),l(nt),l(de),l(ot),l(rt),l(ce),l(dt),l(fe),l(pt),l(ct),l(ft),l(_e)),l(u),h(y,e),h(b,e),h(v,e),h(B,e),h(J,e),h(F,e),h(D,e),h(N,e),h(I,e),h(V,e),h(O,e),h(K,e),h(ee,e),h(se,e),h(oe,e),h(re,e),h(pe,e),h(M,e),h(me,e)}}}const sl='{"title":"Fully Sharded Data Parallel","local":"fully-sharded-data-parallel","sections":[{"title":"How it works out of the box","local":"how-it-works-out-of-the-box","sections":[],"depth":2},{"title":"Saving and loading","local":"saving-and-loading","sections":[{"title":"State Dict","local":"state-dict","sections":[],"depth":3}],"depth":2},{"title":"Mapping between FSDP sharding strategies and DeepSpeed ZeRO Stages","local":"mapping-between-fsdp-sharding-strategies-and-deepspeed-zero-stages","sections":[],"depth":2},{"title":"A few caveats to be aware of","local":"a-few-caveats-to-be-aware-of","sections":[],"depth":2}],"depth":1}';function il(we){return Yt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class cl extends Qt{constructor(u){super(),Ot(this,u,il,al,It,{})}}export{cl as component};
