import{s as ue,o as he,n as ge}from"../chunks/scheduler.25b97de1.js";import{S as ve,i as Te,g as r,s as i,r as L,A as $e,h as s,f as a,c as o,j as fe,u as x,x as p,k as de,y as we,a as n,v as k,d as H,t as J,w as A}from"../chunks/index.d9030fc9.js";import{T as _e}from"../chunks/Tip.baa67368.js";import{C as ce}from"../chunks/CodeBlock.e6cd0d95.js";import{H as ee,E as be}from"../chunks/EditOnGithub.91d95064.js";function ye(R){let l,d=`MegatronGPT2 architecture is the same as OpenAI GPT-2 . Refer to <a href="gpt2">GPT-2 documentation</a> for information on
configuration classes and their parameters.`;return{c(){l=r("p"),l.innerHTML=d},l(m){l=s(m,"P",{"data-svelte-h":!0}),p(l)!=="svelte-mosgum"&&(l.innerHTML=d)},m(m,B){n(m,l,B)},p:ge,d(m){m&&a(l)}}}function Me(R){let l,d,m,B,c,N,u,W,h,te=`The MegatronGPT2 model was proposed in <a href="https://arxiv.org/abs/1909.08053" rel="nofollow">Megatron-LM: Training Multi-Billion Parameter Language Models Using Model
Parallelism</a> by Mohammad Shoeybi, Mostofa Patwary, Raul Puri, Patrick LeGresley,
Jared Casper and Bryan Catanzaro.`,E,g,ae="The abstract from the paper is the following:",U,v,ne=`<em>Recent work in language modeling demonstrates that training large transformer models advances the state of the art in
Natural Language Processing applications. However, very large models can be quite difficult to train due to memory
constraints. In this work, we present our techniques for training very large transformer models and implement a simple,
efficient intra-layer model parallel approach that enables training transformer models with billions of parameters. Our
approach does not require a new compiler or library changes, is orthogonal and complimentary to pipeline model
parallelism, and can be fully implemented with the insertion of a few communication operations in native PyTorch. We
illustrate this approach by converging transformer based models up to 8.3 billion parameters using 512 GPUs. We sustain
15.1 PetaFLOPs across the entire application with 76% scaling efficiency when compared to a strong single GPU baseline
that sustains 39 TeraFLOPs, which is 30% of peak FLOPs. To demonstrate that large language models can further advance
the state of the art (SOTA), we train an 8.3 billion parameter transformer language model similar to GPT-2 and a 3.9
billion parameter model similar to BERT. We show that careful attention to the placement of layer normalization in
BERT-like models is critical to achieving increased performance as the model size grows. Using the GPT-2 model we
achieve SOTA results on the WikiText103 (10.8 compared to SOTA perplexity of 15.8) and LAMBADA (66.5% compared to SOTA
accuracy of 63.2%) datasets. Our BERT model achieves SOTA results on the RACE dataset (90.9% compared to SOTA accuracy
of 89.4%).</em>`,V,T,ie=`This model was contributed by <a href="https://huggingface.co/jdemouth" rel="nofollow">jdemouth</a>. The original code can be found <a href="https://github.com/NVIDIA/Megatron-LM" rel="nofollow">here</a>.
That repository contains a multi-GPU and multi-node implementation of the Megatron Language models. In particular, it
contains a hybrid model parallel approach using “tensor parallel” and “pipeline parallel” techniques.`,z,$,I,w,oe=`We have provided pretrained <a href="https://ngc.nvidia.com/catalog/models/nvidia:megatron_lm_345m" rel="nofollow">GPT2-345M</a> checkpoints
for use to evaluate or finetuning downstream tasks.`,S,_,le=`To access these checkpoints, first <a href="https://ngc.nvidia.com/signup" rel="nofollow">sign up</a> for and setup the NVIDIA GPU Cloud (NGC)
Registry CLI. Further documentation for downloading models can be found in the <a href="https://docs.nvidia.com/dgx/ngc-registry-cli-user-guide/index.html#topic_6_4_1" rel="nofollow">NGC documentation</a>.`,j,b,re="Alternatively, you can directly download the checkpoints using:",Z,y,F,M,se=`Once you have obtained the checkpoint from NVIDIA GPU Cloud (NGC), you have to convert it to a format that will easily
be loaded by Hugging Face Transformers GPT2 implementation.`,X,P,me=`The following command allows you to do the conversion. We assume that the folder <code>models/megatron_gpt2</code> contains
<code>megatron_gpt2_345m_v0_0.zip</code> and that the command is run from that folder:`,Y,C,q,f,D,G,Q,O,K;return c=new ee({props:{title:"MegatronGPT2",local:"megatrongpt2",headingTag:"h1"}}),u=new ee({props:{title:"Overview",local:"overview",headingTag:"h2"}}),$=new ee({props:{title:"Usage tips",local:"usage-tips",headingTag:"h2"}}),y=new ce({props:{code:"d2dldCUyMC0tY29udGVudC1kaXNwb3NpdGlvbiUyMGh0dHBzJTNBJTJGJTJGYXBpLm5nYy5udmlkaWEuY29tJTJGdjIlMkZtb2RlbHMlMkZudmlkaWElMkZtZWdhdHJvbl9sbV8zNDVtJTJGdmVyc2lvbnMlMkZ2MC4wJTJGemlwJTIwLU8lMEFtZWdhdHJvbl9ncHQyXzM0NW1fdjBfMC56aXA=",highlighted:`wget --content-disposition https://api.ngc.nvidia.com/v2/models/nvidia/megatron_lm_345m/versions/v0.0/zip -O
megatron_gpt2_345m_v0_0.zip`,wrap:!1}}),C=new ce({props:{code:"cHl0aG9uMyUyMCUyNFBBVEhfVE9fVFJBTlNGT1JNRVJTJTJGbW9kZWxzJTJGbWVnYXRyb25fZ3B0MiUyRmNvbnZlcnRfbWVnYXRyb25fZ3B0Ml9jaGVja3BvaW50LnB5JTIwbWVnYXRyb25fZ3B0Ml8zNDVtX3YwXzAuemlw",highlighted:'python3 <span class="hljs-variable">$PATH_TO_TRANSFORMERS</span>/models/megatron_gpt2/convert_megatron_gpt2_checkpoint.py megatron_gpt2_345m_v0_0.zip',wrap:!1}}),f=new _e({props:{$$slots:{default:[ye]},$$scope:{ctx:R}}}),G=new be({props:{source:"https://github.com/huggingface/transformers/blob/main/docs/source/en/model_doc/megatron_gpt2.md"}}),{c(){l=r("meta"),d=i(),m=r("p"),B=i(),L(c.$$.fragment),N=i(),L(u.$$.fragment),W=i(),h=r("p"),h.innerHTML=te,E=i(),g=r("p"),g.textContent=ae,U=i(),v=r("p"),v.innerHTML=ne,V=i(),T=r("p"),T.innerHTML=ie,z=i(),L($.$$.fragment),I=i(),w=r("p"),w.innerHTML=oe,S=i(),_=r("p"),_.innerHTML=le,j=i(),b=r("p"),b.textContent=re,Z=i(),L(y.$$.fragment),F=i(),M=r("p"),M.textContent=se,X=i(),P=r("p"),P.innerHTML=me,Y=i(),L(C.$$.fragment),q=i(),L(f.$$.fragment),D=i(),L(G.$$.fragment),Q=i(),O=r("p"),this.h()},l(e){const t=$e("svelte-u9bgzb",document.head);l=s(t,"META",{name:!0,content:!0}),t.forEach(a),d=o(e),m=s(e,"P",{}),fe(m).forEach(a),B=o(e),x(c.$$.fragment,e),N=o(e),x(u.$$.fragment,e),W=o(e),h=s(e,"P",{"data-svelte-h":!0}),p(h)!=="svelte-110uk60"&&(h.innerHTML=te),E=o(e),g=s(e,"P",{"data-svelte-h":!0}),p(g)!=="svelte-vfdo9a"&&(g.textContent=ae),U=o(e),v=s(e,"P",{"data-svelte-h":!0}),p(v)!=="svelte-o6jluj"&&(v.innerHTML=ne),V=o(e),T=s(e,"P",{"data-svelte-h":!0}),p(T)!=="svelte-1lqeluo"&&(T.innerHTML=ie),z=o(e),x($.$$.fragment,e),I=o(e),w=s(e,"P",{"data-svelte-h":!0}),p(w)!=="svelte-9l8t5v"&&(w.innerHTML=oe),S=o(e),_=s(e,"P",{"data-svelte-h":!0}),p(_)!=="svelte-1xz4v1w"&&(_.innerHTML=le),j=o(e),b=s(e,"P",{"data-svelte-h":!0}),p(b)!=="svelte-115r3rj"&&(b.textContent=re),Z=o(e),x(y.$$.fragment,e),F=o(e),M=s(e,"P",{"data-svelte-h":!0}),p(M)!=="svelte-wb75fn"&&(M.textContent=se),X=o(e),P=s(e,"P",{"data-svelte-h":!0}),p(P)!=="svelte-siywy0"&&(P.innerHTML=me),Y=o(e),x(C.$$.fragment,e),q=o(e),x(f.$$.fragment,e),D=o(e),x(G.$$.fragment,e),Q=o(e),O=s(e,"P",{}),fe(O).forEach(a),this.h()},h(){de(l,"name","hf:doc:metadata"),de(l,"content",Pe)},m(e,t){we(document.head,l),n(e,d,t),n(e,m,t),n(e,B,t),k(c,e,t),n(e,N,t),k(u,e,t),n(e,W,t),n(e,h,t),n(e,E,t),n(e,g,t),n(e,U,t),n(e,v,t),n(e,V,t),n(e,T,t),n(e,z,t),k($,e,t),n(e,I,t),n(e,w,t),n(e,S,t),n(e,_,t),n(e,j,t),n(e,b,t),n(e,Z,t),k(y,e,t),n(e,F,t),n(e,M,t),n(e,X,t),n(e,P,t),n(e,Y,t),k(C,e,t),n(e,q,t),k(f,e,t),n(e,D,t),k(G,e,t),n(e,Q,t),n(e,O,t),K=!0},p(e,[t]){const pe={};t&2&&(pe.$$scope={dirty:t,ctx:e}),f.$set(pe)},i(e){K||(H(c.$$.fragment,e),H(u.$$.fragment,e),H($.$$.fragment,e),H(y.$$.fragment,e),H(C.$$.fragment,e),H(f.$$.fragment,e),H(G.$$.fragment,e),K=!0)},o(e){J(c.$$.fragment,e),J(u.$$.fragment,e),J($.$$.fragment,e),J(y.$$.fragment,e),J(C.$$.fragment,e),J(f.$$.fragment,e),J(G.$$.fragment,e),K=!1},d(e){e&&(a(d),a(m),a(B),a(N),a(W),a(h),a(E),a(g),a(U),a(v),a(V),a(T),a(z),a(I),a(w),a(S),a(_),a(j),a(b),a(Z),a(F),a(M),a(X),a(P),a(Y),a(q),a(D),a(Q),a(O)),a(l),A(c,e),A(u,e),A($,e),A(y,e),A(C,e),A(f,e),A(G,e)}}}const Pe='{"title":"MegatronGPT2","local":"megatrongpt2","sections":[{"title":"Overview","local":"overview","sections":[],"depth":2},{"title":"Usage tips","local":"usage-tips","sections":[],"depth":2}],"depth":1}';function Ce(R){return he(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Je extends ve{constructor(l){super(),Te(this,l,Ce,Me,ue,{})}}export{Je as component};
