Language Models2022advanced13 min read

PaLM: Scaling Language Modeling with Pathways

PaLM: توسيع نمذجة اللغة عبر نظام Pathways

Chowdhery, A. · Narang, S. · Devlin, J. · Bosma, M. · Mishra, G. · Roberts, A. · Barham, P. · Chung, H.W. · Sutton, C. · Gehrmann, S. — JMLR

The problem

By early 2022, scaling language models to hundreds of billions of parameters had shown promising results (GPT-3 at 175B, Gopher at 280B, Megatron-Turing NLG at 530B), but several open questions remained. Did performance improvements from scaling plateau, or would they continue? Could a single model match or beat fine-tuned specialist models using only ? And critically, existing infrastructure required and complex engineering that limited efficiency — no system had trained a model this large across multiple TPU Pods simultaneously.

The contribution

PaLM: a 540-billion , dense, -only trained on 780 billion tokens using Pathways — the first system to scale training across 6144 TPU v4 chips spanning two Pods, achieving a record 57.8% hardware FLOPs utilization. PaLM achieved state-of-the-art few-shot results across hundreds of benchmarks, outperformed fine-tuned models on multi-step reasoning tasks, and surpassed average human performance on the . The paper introduced architectural modifications including activations, parallel / layers (15% speedup), , and embeddings.

The impact

PaLM demonstrated that scaling had not plateaued — larger models with more data continued to unlock new capabilities, including discontinuous "emergent" improvements on reasoning tasks. It established the Pathways infrastructure that later powered Gemini. PaLM's architectural choices (SwiGLU, parallel layers, MQA, RoPE) became standard in subsequent large models. Its few-shot reasoning results accelerated research, and its instruction- tuned variant (Flan-PaLM) showed the power of combining scale with task diversity.

Imagine building a skyscraper so tall it can't stand on one foundation. Previous builders either used a single foundation and hit a height limit, or bolted separate buildings together with shaky connectors (pipeline parallelism). Google's Pathways is like pouring two massive foundations side by side and connecting them with an underground tunnel — each foundation supports half the building, they share loads through the tunnel, and the whole structure rises as one. The skyscraper is PaLM: 540 billion parameters tall, and the first building to use this dual-foundation system.

The challenge: training beyond a single Pod

By 2022, the largest language models had hit a training infrastructure wall. A single TPU v3 Pod contained up to 2048 chips — enough for models like LaMDA and GLaM. But 540 billion dense parameters needed more. Megatron-Turing NLG (530B) used 2240 GPUs with pipeline parallelism, where the model is split into sequential stages across machines. This creates "pipeline bubbles" — idle time when earlier stages wait for later stages — limiting efficiency.

PaLM took a fundamentally different approach: instead of splitting the model into a pipeline, it used the Pathways system to coordinate training across 6144 TPU v4 chips in two full Pods, using only at the Pod level and standard data+ within each Pod. No pipeline parallelism at all.

Open in Lab
See how Pathways orchestrates training across two TPU Pods — forward/backward computation happens within each Pod, then gradients transfer through the datacenter network.
The demo wakes as you arrive…

The architecture: a modified decoder-only Transformer

PaLM is a dense, decoder-only Transformer — the same family as GPT-3 — but with six engineering modifications that collectively boosted both quality and speed:

1. SwiGLU activations: Replace the standard ReLU/GELU in the feed-forward network with SwiGLU, which uses a : Swish(xW₁) ⊙ (xW₃). This requires three matrix multiplications instead of two, but the quality gains outweigh the compute cost.

2. Parallel layers: Instead of running attention and the feed-forward network sequentially (x + Attention(LayerNorm(x)) then + FFN(LayerNorm(...))), PaLM runs them in parallel: x + Attention(LayerNorm(x)) + FFN(LayerNorm(x)). This gives a ~15% training speedup at scale with no quality loss.

3. Multi-query attention: Standard projects separate key and value vectors for each head. Multi-query attention shares one key and one value projection across all heads, dramatically reducing memory and compute during autoregressive decoding.

4. RoPE embeddings: Rotary Position Embeddings encode position through rotation matrices applied to query and key vectors, enabling better generalization to longer sequences than absolute or learned position embeddings.

5. Shared input-output embeddings: The same matrix is used for both the input lookup and the output projection, reducing parameter count.

6. No biases: All dense kernels and layer norms omit terms, improving training stability at large scale.

Open in Lab
Click each architectural modification to see how it changes the standard Transformer.
The demo wakes as you arrive…

PaLM was trained at three scales to study scaling behavior:

  • PaLM 8B: 32 layers, 16 heads, 4096 hidden dim — the baseline for ablation studies.
  • PaLM 62B: 64 layers, 32 heads, 8192 hidden dim — competitive with Chinchilla (70B).
  • PaLM 540B: 118 layers, 48 heads, 18432 hidden dim — the flagship model. Each head has dimension 256. The feed-forward intermediate size is 73728 (4× hidden dim).

All three were trained on 780 billion tokens from a mixture of filtered web pages, books, Wikipedia, news articles, source code (from GitHub), and social media conversations across 124 languages. The vocabulary uses a SentencePiece tokenizer with 256,000 tokens.

Key insight: parallel layers

In a standard Transformer block, attention and the feed-forward network run sequentially: the output of attention feeds into the FFN, which feeds into the residual. This creates a dependency chain — the FFN must wait for attention to finish.

PaLM flips this into a parallel formulation. Both attention and FFN receive the same layer-normalized input, compute independently, and their outputs are summed into the residual stream together. Mathematically:

  • Standard: y = x + FFN(LayerNorm(x + Attention(LayerNorm(x))))
  • Parallel: y = x + Attention(LayerNorm(x)) + FFN(LayerNorm(x))

The parallel version allows the GPU/TPU to fuse the attention and FFN computations into fewer operations and better saturate the hardware. At PaLM's scale (540B), this yields a ~15% wall- clock training speedup. At smaller scales (8B), it causes a slight quality degradation — but at 62B and above, the quality matches the sequential version exactly.

y=x+Attention ⁣(LN(x))+FFN ⁣(LN(x))y = x + \text{Attention}\!\big(\text{LN}(x)\big) + \text{FFN}\!\big(\text{LN}(x)\big)
PaLM parallel layer formulation — Both attention and FFN take the same LayerNorm'd input and their outputs are summed into the residual stream simultaneously. This enables hardware-level fusion that accelerates training.
Open in Lab
Compare the data flow in standard sequential vs PaLM's parallel Transformer blocks.
The demo wakes as you arrive…

SwiGLU: a better activation function

The standard Transformer FFN applies a single : FFN(x) = ReLU(xW₁)W₂. SwiGLU replaces this with a gated activation that learns which information to let through:

FFN(x) = (Swish(xW₁) ⊙ xW₃) · W₂

where Swish(u) = u · σ(u) is the Swish function. The key idea is that xW₃ acts as a gate: it modulates the output of Swish(xW₁) element-wise. This gating mechanism lets the network be more selective about which features to amplify or suppress. Think of it as a valve system — one pipe carries the signal, another pipe controls how much of each element flows through.

Despite requiring a third weight matrix (and thus ~33% more parameters in the FFN), SwiGLU consistently outperformed standard activations in quality across all model sizes, making it a net win when paired with the training speedup from parallel layers.

FFNSwiGLU(x)=(Swish(xW1)⊙xW3) W2\text{FFN}_{\text{SwiGLU}}(x) = \big(\text{Swish}(xW_1) \odot xW_3\big)\,W_2
SwiGLU activation — The Swish-gated linear unit. W₁ and W₃ produce two signals from the same input; W₃ gates the Swish output element-wise. W₂ projects back to the model dimension.

Training data: 780 billion tokens across 124 languages

PaLM's training dataset was a carefully curated mixture designed to cover diverse use cases:

  • Filtered web pages — the bulk of the data, filtered for quality.
  • Books — long-form, structured text for coherent generation.
  • Wikipedia — factual knowledge across languages.
  • News articles — current events and journalistic style.
  • Source code — from GitHub, enabling and understanding.
  • Social media conversations — dialogue-style text for conversational ability.

The multilingual aspect is notable: while English dominated (the majority of tokens), the dataset included text in 124 languages. This, combined with a large SentencePiece vocabulary of 256,000 tokens, gave PaLM surprisingly strong multilingual capabilities — especially for a model not specifically designed for multilingual use.

An important design choice: PaLM was trained for a single (no data repetition). The 780B tokens were seen exactly once. This stands in contrast to Chinchilla's finding that smaller models trained on more data can match larger ones — PaLM showed that raw scale still matters when the data is large enough.

Scaling behavior: continuous gains and sudden jumps

One of PaLM's most striking findings was about how performance scales. For most tasks, scaling from 8B → 62B → 540B followed a smooth, log-linear improvement curve — consistent with the scaling laws described by Chinchilla. More parameters, more performance, predictably.

But for certain tasks — particularly those requiring multi-step reasoning, logical deduction, or understanding jokes — the improvement was discontinuous. Performance barely budged from 8B to 62B, then jumped dramatically from 62B to 540B. These are what researchers call emergent abilities: capabilities that appear to "switch on" only at sufficient scale, as though the model needs to reach a critical mass of knowledge before a new skill clicks into place.

This discovery was crucial: it showed that log-linear scaling laws underestimate the benefits of large models on hard reasoning tasks. If you only looked at 8B → 62B performance, you'd predict modest gains at 540B. The actual gains blew past those predictions.

Open in Lab
Compare smooth (log-linear) scaling vs discontinuous (emergent) scaling. Toggle between task types to see the difference.
The demo wakes as you arrive…

Reasoning breakthroughs and chain-of-thought

Perhaps PaLM's most impressive result was on multi-step reasoning. Previous large models struggled with tasks requiring logical chains: arithmetic word problems, , multi-hop question answering. PaLM 540B didn't just improve on these tasks — it outperformed fine-tuned specialist models using only few-shot prompting.

The key enabler was chain-of-thought prompting: instead of asking for a direct answer, the prompt includes examples that show step-by-step reasoning. For instance:

Q: Roger has 5 tennis balls. He buys 2 more cans of 3. How many does he have? A: Roger started with 5. He bought 2 cans × 3 = 6. Total: 5 + 6 = 11. The answer is 11.

With chain-of-thought prompting, PaLM 540B achieved 58.1% on GSM8K (grade-school math) with just 8-shot prompting — surpassing the fine-tuned state-of-the-art. It achieved 75.6% on StrategyQA (commonsense reasoning), also beating the fine-tuned SOTA.

This was a paradigm shift: it showed that at sufficient scale, a general-purpose model with the right prompting strategy can match or beat task-specific fine-tuned models — without any updates.

Results: surpassing humans and fine-tuned models

PaLM 540B was evaluated across hundreds of benchmarks. Here are the highlights:

BIG-bench (150+ tasks): PaLM 540B with 5-shot prompting outperformed the average human rater on a majority of BIG-bench tasks. This was the first time a language model achieved this. On tasks like logical deduction, causal reasoning, and English proverbs, PaLM showed dramatic improvements over prior models.

Reasoning tasks: With chain-of-thought prompting, PaLM 540B achieved 58.1% on GSM8K and 75.6% on StrategyQA — both surpassing the fine-tuned state-of-the-art at the time.

NLP benchmarks (29 tasks): PaLM achieved state-of-the-art few-shot results on tasks including TriviaQA, Natural Questions, LAMBADA, and HellaSwag. On SuperGLUE (after ), it scored 92.6%.

Code generation: PaLM showed strong code generation abilities, competitive with specialized code models, thanks to the GitHub source code in its training data.

Multilingual: Despite being primarily English-focused, PaLM set new records on multilingual question answering and generation tasks, outperforming even models trained on more non-English data.

Open in Lab
Compare PaLM 540B against GPT-3, Gopher, and Chinchilla across task categories.
The demo wakes as you arrive…

The idea in code

PaLM parallel layer — attention and FFN run simultaneouslypython

Simplified to show the idea — not the real implementation.

import torch
import torch.nn as nn

class PaLMBlock(nn.Module):
    """One PaLM Transformer block with PARALLEL attention + FFN."""

    def __init__(self, d_model, n_heads, d_ff):
        super().__init__()
        self.norm = nn.LayerNorm(d_model, bias=False)  # no bias!
        self.attn = MultiQueryAttention(d_model, n_heads)
        self.ffn = SwiGLUFFN(d_model, d_ff)

    def forward(self, x):
        # KEY DIFFERENCE: both branches share the SAME normed input
        normed = self.norm(x)

        # Standard: attn_out = attn(normed); x = x + attn_out;
        #           x = x + ffn(norm(x))   <-- sequential
        # PaLM:     both computed in parallel, outputs summed
        attn_out = self.attn(normed)
        ffn_out = self.ffn(normed)

        return x + attn_out + ffn_out  # parallel residual


class SwiGLUFFN(nn.Module):
    """SwiGLU: gated activation that learns what to amplify."""

    def __init__(self, d_model, d_ff):
        super().__init__()
        self.w1 = nn.Linear(d_model, d_ff, bias=False)
        self.w3 = nn.Linear(d_model, d_ff, bias=False)  # gate
        self.w2 = nn.Linear(d_ff, d_model, bias=False)

    def forward(self, x):
        # Swish(xW1) ⊙ (xW3) — the gate modulates the signal
        return self.w2(torch.sigmoid(self.w1(x)) * self.w1(x) * self.w3(x))

# PaLM 540B: 118 of these blocks stacked
# d_model=18432, n_heads=48, d_ff=73728

What PaLM unlocked

  1. 2022

    PaLM

    540B dense decoder-only model. First to use Pathways for multi-Pod training. State-of- the-art few-shot on hundreds of tasks. Emergent reasoning capabilities.

  2. 2022

    Chain-of-Thought (Wei et al.)

    PaLM was a key testbed for chain-of-thought prompting research. CoT + PaLM 540B beat fine-tuned models on reasoning tasks without any gradient updates.

  3. 2022

    Flan-PaLM

    Instruction-tuned PaLM using 1,836 tasks. Achieved 75.2% on MMLU — a huge leap. Showed that scale + instruction tuning + CoT = superior performance.

  4. 2023

    PaLM 2

    Successor applying Chinchilla-optimal training: smaller model, more tokens. Outperformed PaLM 540B on every BIG-Bench Hard task. Powered Bard (later Gemini).

  5. 2023

    Gemini

    Google's multimodal model built on the Pathways infrastructure PaLM pioneered. Natively processes text, images, audio, and video.

  6. 2023

    RT-2 (Robotic Transformer 2)

    Used PaLM as its language backbone for robotic control, showing that a language model's reasoning transfers to physical-world manipulation tasks.

PaLM's legacy extends in three directions. First, its infrastructure: the Pathways system proved that multi-Pod training without pipeline parallelism was viable, paving the road for even larger models. Second, its architecture: SwiGLU, parallel layers, MQA, and RoPE became the default recipe in subsequent models including LLaMA, Mistral, and Gemini. Third, its science: the discovery of emergent abilities and the power of chain-of-thought prompting reshaped how the field thinks about what scale can achieve.

Perhaps most importantly, PaLM showed that the scaling hypothesis was still alive. At a time when Chinchilla suggested that data efficiency matters more than raw size, PaLM demonstrated that both matter — and that beyond a certain scale, qualitatively new capabilities emerge that no amount of data alone can produce.

CitationChowdhery, Narang, Devlin, Bosma, Mishra, Roberts, Barham, et al.. PaLM: Scaling Language Modeling with Pathways. JMLR, 2023.

Terms in this paper