import{s as pe,n as de,o as ce}from"../chunks/scheduler.9bc65507.js";import{S as fe,i as he,g as i,s as l,r as I,A as ue,h as r,f as a,c as o,j as ie,u as S,x as s,k as re,y as ge,a as n,v as j,d as Z,t as F,w as X}from"../chunks/index.707bf1b6.js";import{C as se}from"../chunks/CodeBlock.54a9f38d.js";import{H as me}from"../chunks/Heading.342b1fa6.js";function ve(Y){let m,$,P,x,p,G,d,L,c,D=`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.`,k,f,q="The abstract from the paper is the following:",H,h,Q=`<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>`,J,u,K="Tips:",A,g,ee=`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.`,B,v,te=`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>.`,N,T,ae="Alternatively, you can directly download the checkpoints using:",R,w,O,y,ne=`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.`,W,_,le=`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:`,V,M,z,b,oe=`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.`,E,C,U;return p=new me({props:{title:"MegatronGPT2",local:"megatrongpt2",headingTag:"h1"}}),d=new me({props:{title:"Overview",local:"overview",headingTag:"h2"}}),w=new se({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}}),M=new se({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}}),{c(){m=i("meta"),$=l(),P=i("p"),x=l(),I(p.$$.fragment),G=l(),I(d.$$.fragment),L=l(),c=i("p"),c.innerHTML=D,k=l(),f=i("p"),f.textContent=q,H=l(),h=i("p"),h.innerHTML=Q,J=l(),u=i("p"),u.textContent=K,A=l(),g=i("p"),g.innerHTML=ee,B=l(),v=i("p"),v.innerHTML=te,N=l(),T=i("p"),T.textContent=ae,R=l(),I(w.$$.fragment),O=l(),y=i("p"),y.textContent=ne,W=l(),_=i("p"),_.innerHTML=le,V=l(),I(M.$$.fragment),z=l(),b=i("p"),b.innerHTML=oe,E=l(),C=i("p"),this.h()},l(e){const t=ue("svelte-u9bgzb",document.head);m=r(t,"META",{name:!0,content:!0}),t.forEach(a),$=o(e),P=r(e,"P",{}),ie(P).forEach(a),x=o(e),S(p.$$.fragment,e),G=o(e),S(d.$$.fragment,e),L=o(e),c=r(e,"P",{"data-svelte-h":!0}),s(c)!=="svelte-110uk60"&&(c.innerHTML=D),k=o(e),f=r(e,"P",{"data-svelte-h":!0}),s(f)!=="svelte-vfdo9a"&&(f.textContent=q),H=o(e),h=r(e,"P",{"data-svelte-h":!0}),s(h)!=="svelte-o6jluj"&&(h.innerHTML=Q),J=o(e),u=r(e,"P",{"data-svelte-h":!0}),s(u)!=="svelte-axv494"&&(u.textContent=K),A=o(e),g=r(e,"P",{"data-svelte-h":!0}),s(g)!=="svelte-9l8t5v"&&(g.innerHTML=ee),B=o(e),v=r(e,"P",{"data-svelte-h":!0}),s(v)!=="svelte-1xz4v1w"&&(v.innerHTML=te),N=o(e),T=r(e,"P",{"data-svelte-h":!0}),s(T)!=="svelte-115r3rj"&&(T.textContent=ae),R=o(e),S(w.$$.fragment,e),O=o(e),y=r(e,"P",{"data-svelte-h":!0}),s(y)!=="svelte-wb75fn"&&(y.textContent=ne),W=o(e),_=r(e,"P",{"data-svelte-h":!0}),s(_)!=="svelte-siywy0"&&(_.innerHTML=le),V=o(e),S(M.$$.fragment,e),z=o(e),b=r(e,"P",{"data-svelte-h":!0}),s(b)!=="svelte-1rpr24"&&(b.innerHTML=oe),E=o(e),C=r(e,"P",{}),ie(C).forEach(a),this.h()},h(){re(m,"name","hf:doc:metadata"),re(m,"content",Te)},m(e,t){ge(document.head,m),n(e,$,t),n(e,P,t),n(e,x,t),j(p,e,t),n(e,G,t),j(d,e,t),n(e,L,t),n(e,c,t),n(e,k,t),n(e,f,t),n(e,H,t),n(e,h,t),n(e,J,t),n(e,u,t),n(e,A,t),n(e,g,t),n(e,B,t),n(e,v,t),n(e,N,t),n(e,T,t),n(e,R,t),j(w,e,t),n(e,O,t),n(e,y,t),n(e,W,t),n(e,_,t),n(e,V,t),j(M,e,t),n(e,z,t),n(e,b,t),n(e,E,t),n(e,C,t),U=!0},p:de,i(e){U||(Z(p.$$.fragment,e),Z(d.$$.fragment,e),Z(w.$$.fragment,e),Z(M.$$.fragment,e),U=!0)},o(e){F(p.$$.fragment,e),F(d.$$.fragment,e),F(w.$$.fragment,e),F(M.$$.fragment,e),U=!1},d(e){e&&(a($),a(P),a(x),a(G),a(L),a(c),a(k),a(f),a(H),a(h),a(J),a(u),a(A),a(g),a(B),a(v),a(N),a(T),a(R),a(O),a(y),a(W),a(_),a(V),a(z),a(b),a(E),a(C)),a(m),X(p,e),X(d,e),X(w,e),X(M,e)}}}const Te='{"title":"MegatronGPT2","local":"megatrongpt2","sections":[{"title":"Overview","local":"overview","sections":[],"depth":2}],"depth":1}';function we(Y){return ce(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Pe extends fe{constructor(m){super(),he(this,m,we,ve,pe,{})}}export{Pe as component};
