Is Flash Attention Stable?

Fuente: arXiv
Saved in:
Bibliographic Details
Main Authors: Golden, Alicia, Hsia, Samuel, Sun, Fei, Acun, Bilge, Hosmer, Basil, Lee, Yejin, DeVito, Zachary, Johnson, Jeff, Wei, Gu-Yeon, Brooks, David, Wu, Carole-Jean
Format: Preprint
Published: 2024
Subjects:
Online Access:
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866913341612490752
author Golden, Alicia
Hsia, Samuel
Sun, Fei
Acun, Bilge
Hosmer, Basil
Lee, Yejin
DeVito, Zachary
Johnson, Jeff
Wei, Gu-Yeon
Brooks, David
Wu, Carole-Jean
author_facet Golden, Alicia
Hsia, Samuel
Sun, Fei
Acun, Bilge
Hosmer, Basil
Lee, Yejin
DeVito, Zachary
Johnson, Jeff
Wei, Gu-Yeon
Brooks, David
Wu, Carole-Jean
contents Training large-scale machine learning models poses distinct system challenges, given both the size and complexity of today's workloads. Recently, many organizations training state-of-the-art Generative AI models have reported cases of instability during training, often taking the form of loss spikes. Numeric deviation has emerged as a potential cause of this training instability, although quantifying this is especially challenging given the costly nature of training runs. In this work, we develop a principled approach to understanding the effects of numeric deviation, and construct proxies to put observations into context when downstream effects are difficult to quantify. As a case study, we apply this framework to analyze the widely-adopted Flash Attention optimization. We find that Flash Attention sees roughly an order of magnitude more numeric deviation as compared to Baseline Attention at BF16 when measured during an isolated forward pass. We then use a data-driven analysis based on the Wasserstein Distance to provide upper bounds on how this numeric deviation impacts model weights during training, finding that the numerical deviation present in Flash Attention is 2-5 times less significant than low-precision training.
format Preprint
id arxiv_https___arxiv_org_abs_2405_02803
institution arXiv
publishDate 2024
record_format arxiv
spellingShingle Is Flash Attention Stable?
Golden, Alicia
Hsia, Samuel
Sun, Fei
Acun, Bilge
Hosmer, Basil
Lee, Yejin
DeVito, Zachary
Johnson, Jeff
Wei, Gu-Yeon
Brooks, David
Wu, Carole-Jean
Machine Learning
Distributed, Parallel, and Cluster Computing
Training large-scale machine learning models poses distinct system challenges, given both the size and complexity of today's workloads. Recently, many organizations training state-of-the-art Generative AI models have reported cases of instability during training, often taking the form of loss spikes. Numeric deviation has emerged as a potential cause of this training instability, although quantifying this is especially challenging given the costly nature of training runs. In this work, we develop a principled approach to understanding the effects of numeric deviation, and construct proxies to put observations into context when downstream effects are difficult to quantify. As a case study, we apply this framework to analyze the widely-adopted Flash Attention optimization. We find that Flash Attention sees roughly an order of magnitude more numeric deviation as compared to Baseline Attention at BF16 when measured during an isolated forward pass. We then use a data-driven analysis based on the Wasserstein Distance to provide upper bounds on how this numeric deviation impacts model weights during training, finding that the numerical deviation present in Flash Attention is 2-5 times less significant than low-precision training.
title Is Flash Attention Stable?
topic Machine Learning
Distributed, Parallel, and Cluster Computing
url https://arxiv.org/abs/2405.02803