Skip to main content
QUICK REVIEW

[Paper Review] Primer: Searching for Efficient Transformers for Language Modeling

David R. So, Wojciech Mańke|arXiv (Cornell University)|Sep 17, 2021
Topic ModelingComputer Science56 references11 citations
TL;DR

This paper introduces Primer, a more efficient Transformer architecture for auto-regressive language modeling, achieved by searching directly over TensorFlow computation graphs. By squaring ReLU activations and adding depthwise convolutions after Q/K/V projections, Primer reduces training compute by up to 4.2× compared to T5 and 3× for GPT-3 XL-level models, while matching or exceeding performance with less compute across diverse setups.

ABSTRACT

Large Transformer models have been central to recent advances in natural language processing. The training and inference costs of these models, however, have grown rapidly and become prohibitively expensive. Here we aim to reduce the costs of Transformers by searching for a more efficient variant. Compared to previous approaches, our search is performed at a lower level, over the primitives that define a Transformer TensorFlow program. We identify an architecture, named Primer, that has a smaller training cost than the original Transformer and other variants for auto-regressive language modeling. Primer's improvements can be mostly attributed to two simple modifications: squaring ReLU activations and adding a depthwise convolution layer after each Q, K, and V projection in self-attention. Experiments show Primer's gains over Transformer increase as compute scale grows and follow a power law with respect to quality at optimal model sizes. We also verify empirically that Primer can be dropped into different codebases to significantly speed up training without additional tuning. For example, at a 500M parameter size, Primer improves the original T5 architecture on C4 auto-regressive language modeling, reducing the training cost by 4X. Furthermore, the reduced training cost means Primer needs much less compute to reach a target one-shot performance. For instance, in a 1.9B parameter configuration similar to GPT-3 XL, Primer uses 1/3 of the training compute to achieve the same one-shot performance as Transformer. We open source our models and several comparisons in T5 to help with reproducibility.

Motivation & Objective

  • To reduce the high training and inference costs of large-scale Transformer language models.
  • To discover more efficient Transformer variants through low-level search over TensorFlow computation graphs.
  • To develop modifications that are simple, practical, and require no hyperparameter tuning.
  • To achieve significant compute savings without sacrificing model quality, especially at scale.
  • To enable drop-in replacement of standard Transformers with minimal code changes.

Proposed method

  • Search is performed over TensorFlow programs that define the decoder block of an auto-regressive language model.
  • The search space includes low-level operations such as activation functions, normalization, and attention components.
  • Evolutionary algorithms are used to explore the space and optimize for low validation loss under fixed compute budgets.
  • Each model is evaluated using a fixed set of hyperparameters from established libraries like T5 and T2T.
  • The search space allows reordering of components and modification of primitives (e.g., changing activation or normalization order), unlike rigid block-based search spaces.
  • Two key modifications are identified: squaring ReLU activations and inserting depthwise convolution layers after Q, K, and V projections.

Experimental results

Research questions

  • RQ1Can low-level architectural modifications to the Transformer computation graph yield significant training cost reductions without performance loss?
  • RQ2How do the proposed modifications (squared ReLU and depthwise convolutions) improve efficiency and quality across different model sizes and compute scales?
  • RQ3Can the discovered architecture be deployed as a drop-in replacement in existing codebases without re-tuning?
  • RQ4Do the efficiency gains of Primer scale with increasing compute, and do they follow a power law with respect to model quality?
  • RQ5Are the improvements generalizable across different datasets, hardware platforms, and model families?

Key findings

  • Primer reduces training compute by 4.2× to achieve the same performance as the original T5 model on C4 at 500M parameters.
  • For a 1.9B parameter model similar to GPT-3 XL, Primer achieves the same one-shot performance as the Transformer using only 1/3 of the training compute.
  • The improvements are robust across model sizes (20M to 1.9B parameters), datasets (LM1B, C4, PG19), hardware (TPUv2 to V100), and codebases (T5, Lingvo, T2T).
  • The two key modifications—squared ReLU and depthwise convolutions after Q/K/V projections—account for most of the performance gains.
  • Primer’s compute savings increase with scale and follow a power law with respect to model quality when using optimally sized models.
  • Primer-EZ (simplified version) performs well in T5, but the full Primer outperforms it in other codebases like Lingvo and T2T, suggesting broader applicability.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.