import{s as Ge,n as Le,o as Ae}from"../chunks/scheduler.9bc65507.js";import{S as Je,i as He,g as o,s as i,u as ae,A as Ne,h as l,f as t,c as r,j as v,v as ne,y as s,k as p,o as d,a as n,w as oe,d as le,t as ie,x as re}from"../chunks/index.78c82d43.js";import{I as $e}from"../chunks/IconCopyLink.bedaa44d.js";import{C as ke}from"../chunks/CodeBlock.48618ec2.js";function Ee(me){let m,O,H,R,h,f,N,g,se,A,he="MegatronGPT2",S,c,u,E,w,pe,J,ce="Overview",W,y,de=`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.`,V,_,fe="The abstract from the paper is the following:",z,T,ue=`<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>`,I,b,ve="Tips:",U,M,ge=`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.`,j,P,we=`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>.`,Z,C,ye="Alternatively, you can directly download the checkpoints using:",F,x,X,$,_e=`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.`,Y,k,Te=`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:`,D,G,q,L,be=`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.`,Q,B,K;return g=new $e({}),w=new $e({}),x=new ke({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`}}),G=new ke({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'}}),{c(){m=o("meta"),O=i(),H=o("p"),R=i(),h=o("h1"),f=o("a"),N=o("span"),ae(g.$$.fragment),se=i(),A=o("span"),A.textContent=he,S=i(),c=o("h2"),u=o("a"),E=o("span"),ae(w.$$.fragment),pe=i(),J=o("span"),J.textContent=ce,W=i(),y=o("p"),y.innerHTML=de,V=i(),_=o("p"),_.textContent=fe,z=i(),T=o("p"),T.innerHTML=ue,I=i(),b=o("p"),b.textContent=ve,U=i(),M=o("p"),M.innerHTML=ge,j=i(),P=o("p"),P.innerHTML=we,Z=i(),C=o("p"),C.textContent=ye,F=i(),ae(x.$$.fragment),X=i(),$=o("p"),$.textContent=_e,Y=i(),k=o("p"),k.innerHTML=Te,D=i(),ae(G.$$.fragment),q=i(),L=o("p"),L.innerHTML=be,Q=i(),B=o("p"),this.h()},l(e){const a=Ne("svelte-1phssyn",document.head);m=l(a,"META",{name:!0,content:!0}),a.forEach(t),O=r(e),H=l(e,"P",{}),v(H).forEach(t),R=r(e),h=l(e,"H1",{class:!0});var ee=v(h);f=l(ee,"A",{id:!0,class:!0,href:!0});var Me=v(f);N=l(Me,"SPAN",{});var Pe=v(N);ne(g.$$.fragment,Pe),Pe.forEach(t),Me.forEach(t),se=r(ee),A=l(ee,"SPAN",{"data-svelte-h":!0}),s(A)!=="svelte-w1jdw5"&&(A.textContent=he),ee.forEach(t),S=r(e),c=l(e,"H2",{class:!0});var te=v(c);u=l(te,"A",{id:!0,class:!0,href:!0});var Ce=v(u);E=l(Ce,"SPAN",{});var xe=v(E);ne(w.$$.fragment,xe),xe.forEach(t),Ce.forEach(t),pe=r(te),J=l(te,"SPAN",{"data-svelte-h":!0}),s(J)!=="svelte-1jsw1pg"&&(J.textContent=ce),te.forEach(t),W=r(e),y=l(e,"P",{"data-svelte-h":!0}),s(y)!=="svelte-110uk60"&&(y.innerHTML=de),V=r(e),_=l(e,"P",{"data-svelte-h":!0}),s(_)!=="svelte-vfdo9a"&&(_.textContent=fe),z=r(e),T=l(e,"P",{"data-svelte-h":!0}),s(T)!=="svelte-o6jluj"&&(T.innerHTML=ue),I=r(e),b=l(e,"P",{"data-svelte-h":!0}),s(b)!=="svelte-axv494"&&(b.textContent=ve),U=r(e),M=l(e,"P",{"data-svelte-h":!0}),s(M)!=="svelte-9l8t5v"&&(M.innerHTML=ge),j=r(e),P=l(e,"P",{"data-svelte-h":!0}),s(P)!=="svelte-1xz4v1w"&&(P.innerHTML=we),Z=r(e),C=l(e,"P",{"data-svelte-h":!0}),s(C)!=="svelte-115r3rj"&&(C.textContent=ye),F=r(e),ne(x.$$.fragment,e),X=r(e),$=l(e,"P",{"data-svelte-h":!0}),s($)!=="svelte-wb75fn"&&($.textContent=_e),Y=r(e),k=l(e,"P",{"data-svelte-h":!0}),s(k)!=="svelte-siywy0"&&(k.innerHTML=Te),D=r(e),ne(G.$$.fragment,e),q=r(e),L=l(e,"P",{"data-svelte-h":!0}),s(L)!=="svelte-1rpr24"&&(L.innerHTML=be),Q=r(e),B=l(e,"P",{}),v(B).forEach(t),this.h()},h(){p(m,"name","hf:doc:metadata"),p(m,"content",JSON.stringify(Be)),p(f,"id","megatrongpt2"),p(f,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),p(f,"href","#megatrongpt2"),p(h,"class","relative group"),p(u,"id","overview"),p(u,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),p(u,"href","#overview"),p(c,"class","relative group")},m(e,a){d(document.head,m),n(e,O,a),n(e,H,a),n(e,R,a),n(e,h,a),d(h,f),d(f,N),oe(g,N,null),d(h,se),d(h,A),n(e,S,a),n(e,c,a),d(c,u),d(u,E),oe(w,E,null),d(c,pe),d(c,J),n(e,W,a),n(e,y,a),n(e,V,a),n(e,_,a),n(e,z,a),n(e,T,a),n(e,I,a),n(e,b,a),n(e,U,a),n(e,M,a),n(e,j,a),n(e,P,a),n(e,Z,a),n(e,C,a),n(e,F,a),oe(x,e,a),n(e,X,a),n(e,$,a),n(e,Y,a),n(e,k,a),n(e,D,a),oe(G,e,a),n(e,q,a),n(e,L,a),n(e,Q,a),n(e,B,a),K=!0},p:Le,i(e){K||(le(g.$$.fragment,e),le(w.$$.fragment,e),le(x.$$.fragment,e),le(G.$$.fragment,e),K=!0)},o(e){ie(g.$$.fragment,e),ie(w.$$.fragment,e),ie(x.$$.fragment,e),ie(G.$$.fragment,e),K=!1},d(e){e&&(t(O),t(H),t(R),t(h),t(S),t(c),t(W),t(y),t(V),t(_),t(z),t(T),t(I),t(b),t(U),t(M),t(j),t(P),t(Z),t(C),t(F),t(X),t($),t(Y),t(k),t(D),t(q),t(L),t(Q),t(B)),t(m),re(g),re(w),re(x,e),re(G,e)}}}const Be={local:"megatrongpt2",sections:[{local:"overview",title:"Overview"}],title:"MegatronGPT2"};function Oe(me){return Ae(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class ze extends Je{constructor(m){super(),He(this,m,Oe,Ee,Ge,{})}}export{ze as component};
