Profile

Settings

Loading…

← Papers

Help

FAQ

Which features require signing in?

You can read the commentary, paper info, Model Structure and related papers of public papers without signing in. Sign in to manage your account or contact us about your inquiries.

Can I upload a PDF file?

Upload papers with an arXiv or DOI link; the commentary is public to everyone. Papers whose source and terms of use can't be verified, so the commentary can't be made public, can't be uploaded. Uploading PDF files and keeping papers private are for subscribers only, and a paper uploaded as a file is saved as private only. Searching for official info by title runs only when you press the button.

Are the figures and AI commentary accurate?

Figures come only from the original paper, and only those whose terms of use are verified are shown. The commentary is written by AI and may be wrong. Check important claims, numbers and figure context against the evidence in the original paper.

I want to report a copyright issue.

Terms of use and the source of the original paper are on the Paper info tab. If there's a problem, choose "Paper content, figures and copyright" under Contact us and send the paper link, the part in question, and evidence that you hold the rights. Receiving your report doesn't confirm any rights or remove anything right away. You can see the result of the review under My inquiries.

I forgot my password.

If you signed up with email, use Forgot password in the sign-in window to reset it with your verified email. If you signed up with Google, Naver or Kakao, change your password with that service.

What should I include in an inquiry?

Tell us which screen you were on and what you were doing when the problem happened, along with the paper link. Don't include personal information such as passwords, API keys, verification codes or phone numbers. Inquiries and replies are stored in Refivu and you can see them under My inquiries.

How do I delete my account?

In Settings, under My account, press Delete account. Review what will be deleted and complete identity verification to delete your account. For other requests, choose "Account" under Contact us.

Paper commentary

GShard: Scaling Giant Models with Conditional Computation and Automatic Sharding

  • Problem Dense Transformer scaling makes training time, graph size and device communication grow quickly once a model no longer fits on one accelerator.
  • Method Adds top-2 gated Mixture-of-Experts layers to the Transformer, and uses GShard's sharding annotations and SPMD compiler to partition the computation across TPU devices.
  • Results The 600B MoE(2048E, 36L) model reached an average ∆BLEU of 13.5 on translation from 100 languages to English, against 6.1 for the dense T(96L) with 2.3B weights.

Why dense scaling gets expensive

Once a model no longer fits on one accelerator, making a dense Transformer deeper or wider makes the training step time grow at least linearly with model size. Splitting layer weights across devices then becomes necessary, which adds network traffic and leaves devices idle partly because of sequential dependencies in the network. Model parallelism support in common frameworks is limited, so teams often move model code into specialized frameworks to scale it.

Every partitioned operator needs its own communication pattern, so a change to the architecture can force changes in the device communication code.

Three requirements behind the design

The design rests on three requirements: computation and communication should stay sublinear in model capacity, the model description should be separate from its partitioning, and the system should scale to thousands of devices. Conditional computation addresses the first requirement by activating only a sub-network for each input. For the second, the user annotates a few critical tensors and the compiler handles the rest, so the model can be written as if one device had huge memory and compute.

For the third, one SPMD program runs on all devices instead of one program per device, which keeps compilation time independent of the number of devices.

Where MoE layers sit in the Transformer

The base model is the standard encoder-decoder Transformer, in which every other feed-forward layer is replaced by a Position-wise MoE layer in both the encoder and the decoder, with top-2 gating. When the encoder is spread over several devices, the MoE layer is sharded while the other layers are replicated.

Each expert is a two-layer fully connected network with ReLU, and the layer output for an input \(x_s\) is a gate-weighted sum of the expert outputs: \(G_{s,E} = \mathrm{GATE}(x_s)\), \(\mathrm{FFN}_e(x_s) = wo_e \cdot \mathrm{ReLU}(wi_e \cdot x_s)\), and \(y_s = \sum_{e=1}^{E} G_{s,e}\,\mathrm{FFN}_e(x_s)\). Most entries of \(G_{s,E}\) are zero, since each token is sent to at most two experts, and the non-zero entries set how much each selected expert contributes.

The gate is a softmax over experts, and routing each token to the top-k experts by probability alone tends to send most tokens to a few experts while others stay undertrained. A sequential gate would cost at least O(NE) for N tokens, and with N in the order of millions and E in the order of thousands, it would keep most hardware idle, so the gate has to run in parallel.

How the gate keeps experts evenly loaded

Expert capacity caps each expert at a uniform threshold set to O(N/E) tokens per batch. When both experts chosen for a token are already full, the token overflows and passes to the next layer through its residual connection. To run in parallel, the batch is split into G groups of S = N/G tokens, and each group gets a fractional capacity of 2N/(G·E) per expert.

The auxiliary loss is added to the training loss as \(\mathcal{L} = \ell_{nll} + k\,\ell_{aux}\) with a constant multiplier k, and it discourages the gate from always picking the same few experts. Counts of top-2 decisions are not differentiable, so the mean gate per expert \(m_e\) replaces the routed fraction, giving \(\ell_{aux} = \frac{1}{E}\sum_{e=1}^{E}\frac{c_e}{S}\,m_e\).

The second expert is used with probability proportional to its gate weight, compared against a uniform draw, so low-weight second experts can be skipped to save capacity.

Writing the layer as tensor operations

The whole MoE layer is written as a few tensor operations: a gate einsum with softmax, a dispatch einsum using a mask, two expert einsums with a ReLU between them, and a combine einsum. The combine_weights tensor has shape [G, S, E, C], and each token has at most two non-zero entries, which the binary dispatch mask records.

Sharding is expressed with replicate and split annotations, which mark a tensor as replicated across partitions or split along a chosen dimension. Attention is split along the batch dimension with its weights replicated, while experts are sharded across devices, and the model alternates between these two modes. The compiler then applies SPMD partitioning, inserts the cross-device communication, handles uneven partitions and emits one program for all devices.

Per-device computation under the assumed scaling

The analysis assumes a constant number of tokens per device, G = O(D), S = O(1), E = O(D), M = O(1), H = O(1) and C = O(1/D). Summing the softmax, top-2 gating, dispatch and combine, and FFN terms gives total cost O(D^2) + O(D) + O(D) + O(D), so per-device cost is O(D) + O(1) + O(1) + O(1). The authors argue that the O(D) softmax term is dominated by other terms in practice, so per-device FLOPS can be treated as O(1), and Section 5 checks this empirically.

Cross-device communication grows at a modest rate of O(\(\sqrt{D}\)) as D increases.

Multilingual translation setup

Multilingual translation is used to test the design because one model must serve many language pairs, which makes it a stress test for scale. Sharing across languages can help low-resource pairs through positive transfer, while high-resource pairs are limited by per-task capacity.

The corpus is web-mined, covers 100 languages to and from English with 25 billion training examples, and is noisy with a heavy imbalance across pairs. The experiments use translation from 100 languages to English, which gives about 13 billion training examples, and Kazakh and Latin to English pairs were excluded from evaluation. Each bilingual baseline is a separate model for one language pair, tuned to the data available for that language, and the comparison places these baselines at zero with results reported as ∆BLEU.

The MoE family varies depth at 12, 36 and 60 layers and experts per MoE layer at 128, 512 and 2048, with the device count set equal to the experts per layer.

Experts use float32 for both weights and activations to keep training stable.

Depth and expert count effects on translation quality

At a fixed number of experts per layer, moving from 12 to 36 layers gives about 2-to-3 BLEU points on average.

At 12 layers, raising the experts per layer from 128 to 512 adds +3.3 average BLEU, while raising it from 512 to 2048 adds +1.3. The authors read the smaller second gain as diminishing returns and place the capacity bottleneck speculatively between 128 and 512 experts for this setup.

Adding experts helps high-resource languages more than low-resource ones at both 12 and 36 layers, where low-resource gains show diminishing returns.

Training cost of the 600B model

Figure 1 plots average ∆BLEU and the TPU v3 core-year cost against model size, and the cost statements below use the same accounting.

Training the 600B MoE Transformer on 2048 TPU v3 cores for 4 days cost 22 TPU v3 core-years, while training all 100 bilingual baseline models would have needed 29 TPU v3 core-years.

Scaling from 37.5B to 600B, a 16x increase in size, raised computation cost from 6 to 22 years, which is a 3.6x increase.

The dense T(96L) with 2.3B weights reached ∆BLEU 6.1 and is reported at 235.5 TPU v3 core-years, a figure drawn from its separately reported budget rather than from the same schedule as the MoE rows.

Memory and step time as experts grow

Per-device memory has three parts: replicated weights, distributed MoE weights and activations. With a fixed layer count, weight and activation memory stay constant as experts increase, while both grow linearly with the number of layers.

Step time grows 1.7x when the model is scaled 16x from 128 to 2048 devices, and per-device memory consumption stays roughly constant.

Roofline is estimated by assuming compute, memory or interconnect bound operations reach 100% of peak FLOPS, memory bandwidth or interconnect bandwidth, which the authors call a very optimistic estimate.

At 128 experts the model reaches more than 70% of roofline performance, and at 2048 experts it reaches 48% after the 1.7x increase in device time.

Feed-forward layers and Transformer projections exceed 85% of peak FLOPS, while attention operations reach more than 30% because they are bounded by memory bandwidth at short sequence lengths.

The two gate Einsums that dispatch and combine tokens grow about 2x from 128 to 2048 experts, and the cumsum work takes less than 10% of MoE and Transformer time at 2048 experts.

MoE dispatch and combine, implemented as AllToAll, grows about 3.75x when experts grow 16x, and its share of MoE and Transformer time rises from 16% to 36%.

Scaling of collective communication and partitioned operators

AllReduce accumulates partial results and AllToAll reshards data, and AllReduce on TPU has an execution time independent of the number of devices.

AllToAll cost is roughly O(\(\sqrt{D}\)) on the 2D TPU cluster, because the data sent in total grows with D while each piece travels about O(\(\sqrt{D}\)) hops over O(D) links. From 16 to 2048 partitions, D grows 128 times while AllToAll execution time grows about 9 times. Figure 9 measures AllReduce and AllToAll with 8MB and 32MB of data per partition, with each partition dividing its data into D pieces.

Table 4 gives per-partition compute and communication for common partitioned operators, and most of them scale sublinearly.

AllGather output is D times its input, so its cost is O(D) for a fixed input, while CollectivePermute costs O(1) when source and destination are close. Two Matmul operators with unmatched sharding are O(D) per partition because their total compute is O(D^2), which the authors say is not an inefficiency of the partitioning algorithm.

Limits of the evidence

A model with 1 trillion weights and bfloat16 activations ran into trainability and numerical stability issues, so those results were not included for reproducibility.

The location of the capacity bottleneck is speculative and holds for this parametrization, number of languages and amount of training data.

Evaluation uses one web-mined corpus and translation into English only, and the Kazakh and Latin to English pairs were excluded.

What the authors conclude

The authors conclude that conditional computation can improve quality at scale while keeping training practical and sample efficient. They also argue that parameter count alone does not track effective capacity, since the multi-task setting with heavy data imbalance and the capacity bottleneck shape the results. On the system side, they argue that a single SPMD program is what lets compilation scale to thousands of partitions.

Paper info

Authors
Dmitry Lepikhin, HyoukJoong Lee, Yuanzhong Xu, Dehao Chen, Orhan Firat, Yanping Huang, Maxim Krikun, Noam Shazeer, Zhifeng Chen
Venue
arXiv · Preprint
First published
2020-6-30
Added
2026-10-20
Updated
2020-6-30
Version
v1
arXiv
2006.16668
Category
cs.CL · cs.LG · stat.ML
Original paper terms
arXiv non-exclusive 1.0
What we show
Paper info and commentary

AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.

Quote from the paper

Dmitry Lepikhin, HyoukJoong Lee, Yuanzhong Xu, Dehao Chen, Orhan Firat, Yanping Huang, Maxim Krikun, Noam Shazeer, Zhifeng Chen (2020). GShard: Scaling Giant Models with Conditional Computation and Automatic Sharding. arXiv:2006.16668v1. https://arxiv.org/abs/2006.16668v1

BibTeX
@misc{lepikhin2020gshard,
  title = {{GShard: Scaling Giant Models with Conditional Computation and Automatic Sharding}},
  author = {Dmitry Lepikhin and HyoukJoong Lee and Yuanzhong Xu and Dehao Chen and Orhan Firat and Yanping Huang and Maxim Krikun and Noam Shazeer and Zhifeng Chen},
  year = {2020},
  eprint = {2006.16668},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2006.16668v1}
}

See related papersBrowse other papers

Paper preview
Account security

Connect Google account

If you connect a Google account, you can sign in with it too.

Refivu

Delete account

Refivu
Refivu

Sign up